Class StringUtils
java.lang.Object
com.dlsc.gemsfx.util.StringUtils
Minimal string utility methods that cover the subset of
org.apache.commons.lang3.StringUtils used by GemsFX.-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcapitalize(String str) Capitalises the first character ofstrusingCharacter.toTitleCase(char).static booleanReturnstrueif the two strings are equal.static booleanequalsIgnoreCase(String str1, String str2) Returnstrueif the two strings are equal ignoring case.static booleanReturnstrueifstrisnull, empty, or contains only whitespace characters (as defined byCharacter.isWhitespace(char)).static booleanReturnstrueifstrisnullor its length is 0.static booleanisNotBlank(String str) static booleanisNotEmpty(String str) Returnstrueifstris neithernullnor empty.static StringJoins the elements ofarraywithseparatorbetween each pair.static StringreplaceEach(String text, String[] searchList, String[] replacementList) Replaces each string insearchListwith the corresponding entry inreplacementListwithintext.static String[]Splitsstron whitespace, discarding empty tokens.static String[]Splitsstrat boundaries where the character type (as returned byCharacter.getType(char)) changes, with the additional camel-case rule: when transitioning fromCharacter.UPPERCASE_LETTERtoCharacter.LOWERCASE_LETTER, the split is placed before the last uppercase character so that acronym prefixes are kept together with the following word (e.g.static booleanstartsWithIgnoreCase(String str, String prefix) Returnstrueifstrstarts withprefix, ignoring case.
-
Method Details
-
isEmpty
Returnstrueifstrisnullor its length is 0.- Parameters:
str- the string to test- Returns:
trueif the string is empty
-
isNotEmpty
Returnstrueifstris neithernullnor empty.- Parameters:
str- the string to test- Returns:
trueif the string is not empty
-
isBlank
Returnstrueifstrisnull, empty, or contains only whitespace characters (as defined byCharacter.isWhitespace(char)).- Parameters:
str- the string to test- Returns:
trueif the string is blank
-
isNotBlank
- Parameters:
str- the string to test- Returns:
trueif the string is not blank
-
capitalize
Capitalises the first character ofstrusingCharacter.toTitleCase(char). Returnsstrunchanged when it isnullor empty.- Parameters:
str- the string to capitalize- Returns:
- the capitalized string
-
split
-
join
Joins the elements ofarraywithseparatorbetween each pair. Anullseparator is treated as an empty string. Returnsnullwhenarrayisnull.- Parameters:
array- the strings to joinseparator- the separator to use- Returns:
- the joined string
-
startsWithIgnoreCase
Returnstrueifstrstarts withprefix, ignoring case. Null-safe: twonullvalues are considered equal, otherwise anullargument yieldsfalse.- Parameters:
str- the string to testprefix- the prefix to look for- Returns:
trueif the string starts with the prefix
-
equals
-
equalsIgnoreCase
-
replaceEach
Replaces each string insearchListwith the corresponding entry inreplacementListwithintext. Replacements are applied in order; each operates on the result of the previous one. Returnstextunchanged when any argument isnullor the two lists have different lengths.- Parameters:
text- the text to processsearchList- the strings to search forreplacementList- the replacement strings- Returns:
- the processed string
-
splitByCharacterTypeCamelCase
Splitsstrat boundaries where the character type (as returned byCharacter.getType(char)) changes, with the additional camel-case rule: when transitioning fromCharacter.UPPERCASE_LETTERtoCharacter.LOWERCASE_LETTER, the split is placed before the last uppercase character so that acronym prefixes are kept together with the following word (e.g."ASFRules"→["ASF", "Rules"]).Returns
nullwhenstrisnulland an empty array whenstris empty.- Parameters:
str- the string to split- Returns:
- the split parts
-