Class StringUtils
- java.lang.Object
-
- ch.systemsx.cisd.common.shared.basic.string.StringUtils
-
public final class StringUtils extends java.lang.ObjectSome utilities forString.Can be used from GWT code.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEMPTY_STRINGstatic java.lang.String[]EMPTY_STRING_ARRAY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringabbreviate(java.lang.String value, int maxLength)static java.lang.Stringcapitalize(java.lang.String word)static java.lang.StringdefaultIfBlank(java.lang.String str, java.lang.String defaultStr)Returns defaultStr, if str is blank, or otherwise it returns str itself.static java.lang.StringemptyIfNull(java.lang.String stringOrNull)Returns an empty string if given stringOrNull isnull, otherwise it returns stringOrNull itself.static java.lang.Stringescape(java.lang.String text, char... escapedChars)Escapes escapedChars characters in specified text.static booleanisBlank(java.lang.Object value)Whether given value is blank or not.static booleanisBlank(java.lang.String value)Whether given value is blank or not.static booleanisNotBlank(java.lang.String value)Whether given value is not blank.static java.lang.Stringjoin(java.lang.Object[] array, java.lang.String separator)Joins the elements of the provided array into a singleStringcontaining the provided list of elements.static java.lang.StringjoinList(java.util.List<java.lang.String> list)Joins the elements using comma as a separator.static java.lang.StringjoinList(java.util.List<java.lang.String> list, java.lang.String separator)Joins the elements using comma as a separator.static booleanmatches(java.lang.String regExp, java.lang.String value)Returnstrueif given regExp could be found in given value.static booleanmatches(java.lang.String regExp, java.lang.String value, java.lang.String modifiers)Returnstrueif given regExp could be found in given value.static java.lang.StringnullIfBlank(java.lang.String value)Returnsnullif given value is blank.static java.util.List<java.lang.String>tokenize(java.lang.String str)Returns the tokens found in str, where tokens are separated by white spaces.static java.lang.StringtoStringEmptyIfNull(java.lang.Object objectOrNull)Returns an empty string if given objectOrNull isnull, otherwise it returns result ofObject.toString()on the object.static java.lang.StringtoStringOrNull(java.lang.Object objectOrNull)Returns null if given objectOrNull isnull, otherwise it returns result ofObject.toString()on the object.static java.lang.StringtrimToNull(java.lang.String value)Trims given value tonull.
-
-
-
Field Detail
-
EMPTY_STRING
public static final java.lang.String EMPTY_STRING
- See Also:
- Constant Field Values
-
EMPTY_STRING_ARRAY
public static final java.lang.String[] EMPTY_STRING_ARRAY
-
-
Method Detail
-
isBlank
public static final boolean isBlank(java.lang.String value)
Whether given value is blank or not.
-
isBlank
public static final boolean isBlank(java.lang.Object value)
Whether given value is blank or not.
-
isNotBlank
public static final boolean isNotBlank(java.lang.String value)
Whether given value is not blank.
-
joinList
public static final java.lang.String joinList(java.util.List<java.lang.String> list)
Joins the elements using comma as a separator.
Example: "a", "b", "c" -> "a, b, c"
-
joinList
public static final java.lang.String joinList(java.util.List<java.lang.String> list, java.lang.String separator)Joins the elements using comma as a separator.
Example: "a", "b", "c" -> "a, b, c"
-
join
public static final java.lang.String join(java.lang.Object[] array, java.lang.String separator)Joins the elements of the provided array into a singleStringcontaining the provided list of elements.
-
capitalize
public static final java.lang.String capitalize(java.lang.String word)
-
abbreviate
public static final java.lang.String abbreviate(java.lang.String value, int maxLength)
-
trimToNull
public static final java.lang.String trimToNull(java.lang.String value)
Trims given value tonull.- Returns:
nullif given value is blank.
-
nullIfBlank
public static final java.lang.String nullIfBlank(java.lang.String value)
Returnsnullif given value is blank.
-
emptyIfNull
public static final java.lang.String emptyIfNull(java.lang.String stringOrNull)
Returns an empty string if given stringOrNull isnull, otherwise it returns stringOrNull itself.
-
toStringEmptyIfNull
public static final java.lang.String toStringEmptyIfNull(java.lang.Object objectOrNull)
Returns an empty string if given objectOrNull isnull, otherwise it returns result ofObject.toString()on the object.
-
toStringOrNull
public static final java.lang.String toStringOrNull(java.lang.Object objectOrNull)
Returns null if given objectOrNull isnull, otherwise it returns result ofObject.toString()on the object.
-
defaultIfBlank
public static final java.lang.String defaultIfBlank(java.lang.String str, java.lang.String defaultStr)Returns defaultStr, if str is blank, or otherwise it returns str itself.
-
escape
public static final java.lang.String escape(java.lang.String text, char... escapedChars)Escapes escapedChars characters in specified text.
-
tokenize
public static final java.util.List<java.lang.String> tokenize(java.lang.String str)
Returns the tokens found in str, where tokens are separated by white spaces.
-
matches
public static final boolean matches(java.lang.String regExp, java.lang.String value, java.lang.String modifiers)Returnstrueif given regExp could be found in given value.Allowed modifiers are:
- i - Perform case-insensitive matching
- g - Perform a global match (find all matches rather than stopping after the first match)
- m - Perform multiline matching
-
matches
public static final boolean matches(java.lang.String regExp, java.lang.String value)Returnstrueif given regExp could be found in given value.
-
-