FileDocCategorySizeDatePackage
StringUtils.javaAPI DocAndroid 1.5 API1643Wed May 06 22:41:16 BST 2009com.google.wireless.gdata.data

StringUtils

public final class StringUtils extends Object
Utility class for working with and manipulating Strings.

Fields Summary
Constructors Summary
private StringUtils()

    
Methods Summary
public static booleanisEmpty(java.lang.String string)
Returns whether or not the String is empty. A String is considered to be empty if it is null or if it has a length of 0.

param
string The String that should be examined.
return
Whether or not the String is empty.

        return ((string == null) || (string.length() == 0));
    
public static booleanisEmptyOrWhitespace(java.lang.String string)
Returns {@code true} if the given string is null, empty, or comprises only whitespace characters, as defined by {@link Character#isWhitespace(char)}.

param
string The String that should be examined.
return
{@code true} if {@code string} is null, empty, or consists of whitespace characters only

        if (string == null) {
            return true;
        }
        int length = string.length();
        for (int i = 0; i < length; i++) {
            if (!Character.isWhitespace(string.charAt(i))) {
                return false;
            }
        }
        return true;
    
public static intparseInt(java.lang.String string, int defaultValue)

        if (string != null) {
            try {
                return Integer.parseInt(string);
            } catch (NumberFormatException nfe) {
                // ignore
            }
        }
        return defaultValue;