Package com.axelor.common
Class StringUtils
java.lang.Object
com.axelor.common.StringUtils
This class provides static helper methods for
CharSequence.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAscii(char c) Returnstrueif the character is in the ASCII charset.static booleanisAscii(CharSequence text) Returnstrueif the text is in the ASCII charset.static booleanisBlank(CharSequence value) Check whether the given string value is blank.static booleanisEmpty(CharSequence value) Check whether the given string value is empty.static StringnormalizeLanguageTag(String languageTag) Normalizes a language tag to a valid IETF BCP 47 language tag.static booleannotBlank(CharSequence value) Check whether the given string value is not blank.static booleannotEmpty(CharSequence value) Check whether the given string value is not empty.static String[]splitToArray(String text, String delimiter) Split the given text into an array using the given delimiter.static String[]splitToArray(String text, String delimiter, boolean trimResult, boolean ignoreEmpty) Split the given text into an array using the given delimiter.static StringstripAccent(CharSequence value) Remove diacritics (accents) from aCharSequence.static StringstripIndent(CharSequence text) Strip the leading indentation from the given text.static StringstripMargin(CharSequence text) Strip leading whitespace/control characters followed by '|' from every line in the given text.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
isEmpty
Check whether the given string value is empty. The value is empty if null or length is 0.- Parameters:
value- the string value to test- Returns:
- true if empty false otherwise
-
notEmpty
Check whether the given string value is not empty. The value is empty if null or length is 0.- Parameters:
value- the string value to test- Returns:
- true if not empty false otherwise
-
isBlank
Check whether the given string value is blank. The value is blank if null or contains white spaces only.- Parameters:
value- the string value to test- Returns:
- true if empty false otherwise
-
notBlank
Check whether the given string value is not blank. The value is blank if null or contains white spaces only.- Parameters:
value- the string value to test- Returns:
- true if not empty false otherwise
-
stripAccent
Remove diacritics (accents) from aCharSequence.- Parameters:
value- the string to be stripped- Returns:
- text with diacritics removed
-
stripIndent
Strip the leading indentation from the given text.The line with the least number of leading spaces determines the number to remove. Lines only containing whitespace are ignored when calculating the number of leading spaces to strip.
- Parameters:
text- the text to strip indent from- Returns:
- stripped text
-
stripMargin
Strip leading whitespace/control characters followed by '|' from every line in the given text.- Parameters:
text- the text to strip the margin from- Returns:
- the stripped String
-
isAscii
Returnstrueif the text is in the ASCII charset.- Parameters:
text- the text to check- Returns:
trueif the text is in the ASCII charset;falseotherwise
-
isAscii
public static boolean isAscii(char c) Returnstrueif the character is in the ASCII charset.- Parameters:
c- the character to check- Returns:
trueif the character is in the ASCII charset;falseotherwise
-
splitToArray
Split the given text into an array using the given delimiter.The result parts are trimmed and empty part omitted.
- Parameters:
text- the text to slipdelimiter- the delimiter- Returns:
- array of string
-
splitToArray
public static String[] splitToArray(String text, String delimiter, boolean trimResult, boolean ignoreEmpty) Split the given text into an array using the given delimiter.- Parameters:
text- the text to slipdelimiter- the delimitertrimResult- whether to trim the result partsignoreEmpty- whether to omit empty part- Returns:
- array of string
-
normalizeLanguageTag
Normalizes a language tag to a valid IETF BCP 47 language tag. For example:fr_fr"will be normalized to"fr-FR".- Parameters:
languageTag- the language tag to normalize- Returns:
- the normalized language tag
-