All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.legstar.base.utils.StringUtils Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.legstar.base.utils;

/**
 * Borrowed from Apache Commons lang#StringUtils
 */
public class StringUtils {

    /**
     * 

Checks if a String is whitespace, empty ("") or null.

* *
     * StringUtils.isBlank(null)      = true
     * StringUtils.isBlank("")        = true
     * StringUtils.isBlank(" ")       = true
     * StringUtils.isBlank("bob")     = false
     * StringUtils.isBlank("  bob  ") = false
     * 
* * @param str the String to check, may be null * @return true if the String is null, empty or whitespace * @since 2.0 */ public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((Character.isWhitespace(str.charAt(i)) == false)) { return false; } } return true; } /** *

Checks if a String is not empty (""), not null and not whitespace only.

* *
     * StringUtils.isNotBlank(null)      = false
     * StringUtils.isNotBlank("")        = false
     * StringUtils.isNotBlank(" ")       = false
     * StringUtils.isNotBlank("bob")     = true
     * StringUtils.isNotBlank("  bob  ") = true
     * 
* * @param str the String to check, may be null * @return true if the String is * not empty and not null and not whitespace * @since 2.0 */ public static boolean isNotBlank(String str) { return !StringUtils.isBlank(str); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy