public final class StringUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EMPTY_STRING
Constant for an empty String.
|
static java.lang.String[] |
EMPTY_STRING_ARRAY
Constant for an empty String array.
|
static java.lang.String |
FALSE
Constant for the value false.
|
static char |
SPACE
a space.
|
static java.lang.String |
TRUE
Constant for the value true.
|
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
capitalize(java.lang.String str)
Capitalizes the first character of the provided string.
|
static java.lang.String |
convertDotToUnderscore(java.lang.String dottedProperty)
Replace the dots in the property with underscore and
transform to uppercase.
|
static java.lang.String |
convertDotToUnderscore(java.lang.String dottedProperty,
boolean uppercase)
Replace the dots in the property with underscore and
transform to uppercase based on given flag.
|
static boolean |
hasText(java.lang.CharSequence str)
Return whether the given string has non whitespace characters.
|
static java.util.List<java.lang.String> |
internListOf(java.lang.Object... objects)
Converts the given objects into a set of interned strings contained within an internal pool of sets.
|
static java.util.Map<java.lang.String,java.lang.Object> |
internMapOf(java.lang.Object... values)
Converts the given objects into a map of interned strings.
|
static boolean |
isDigits(java.lang.String str)
Is the given string a series of digits.
|
static boolean |
isEmpty(java.lang.CharSequence str)
Return whether the given string is empty.
|
static boolean |
isNotEmpty(java.lang.CharSequence str)
Return whether the given string is not empty.
|
static boolean |
isTrue(java.lang.String booleanString)
Is the boolean string true.
|
static java.lang.String |
prependUri(java.lang.String baseUri,
java.lang.String uri)
Prepends a partial uri and normalizes / characters.
|
static java.lang.String[] |
tokenizeToStringArray(java.lang.String str,
java.lang.String delimiters)
Tokenize the given String into a String array via a StringTokenizer.
|
static java.lang.String[] |
tokenizeToStringArray(java.lang.String str,
java.lang.String delimiters,
boolean trimTokens,
boolean ignoreEmptyTokens)
Tokenize the given String into a String array via a StringTokenizer.
|
static java.lang.String |
trimToNull(java.lang.String string)
Trims the supplied string.
|
public static final java.lang.String TRUE
public static final java.lang.String FALSE
public static final java.lang.String[] EMPTY_STRING_ARRAY
public static final java.lang.String EMPTY_STRING
public static final char SPACE
public static boolean isEmpty(@Nullable java.lang.CharSequence str)
str
- The stringpublic static boolean isNotEmpty(@Nullable java.lang.CharSequence str)
str
- The stringpublic static boolean hasText(@Nullable java.lang.CharSequence str)
str
- The stringpublic static java.util.List<java.lang.String> internListOf(java.lang.Object... objects)
String.intern()
.objects
- The objectspublic static java.util.Map<java.lang.String,java.lang.Object> internMapOf(java.lang.Object... values)
String.intern()
.values
- The objectsCollectionUtils.mapOf(Object...)
public static boolean isDigits(java.lang.String str)
str
- The stringpublic static java.lang.String[] tokenizeToStringArray(java.lang.String str, java.lang.String delimiters)
The given delimiters string is supposed to consist of any number of
delimiter characters. Each of those characters can be used to separate
tokens. A delimiter is always a single character; for multi-character
delimiters, consider using delimitedListToStringArray
Copied from the Spring Framework while retaining all license, copyright and author information.
str
- the String to tokenizedelimiters
- the delimiter characters, assembled as String
(each of those characters is individually considered as delimiter).StringTokenizer
,
String.trim()
public static java.lang.String[] tokenizeToStringArray(java.lang.String str, java.lang.String delimiters, boolean trimTokens, boolean ignoreEmptyTokens)
The given delimiters string is supposed to consist of any number of
delimiter characters. Each of those characters can be used to separate
tokens. A delimiter is always a single character; for multi-character
delimiters, consider using delimitedListToStringArray
Copied from the Spring Framework while retaining all license, copyright and author information.
str
- the String to tokenizedelimiters
- the delimiter characters, assembled as String
(each of those characters is individually considered as delimiter)trimTokens
- trim the tokens via String's trim
ignoreEmptyTokens
- omit empty tokens from the result array
(only applies to tokens that are empty after trimming; StringTokenizer
will not consider subsequent delimiters as token in the first place).null
if the input String
was null
)StringTokenizer
,
String.trim()
public static java.lang.String convertDotToUnderscore(java.lang.String dottedProperty)
dottedProperty
- The property with dots, example - a.b.cpublic static java.lang.String convertDotToUnderscore(java.lang.String dottedProperty, boolean uppercase)
dottedProperty
- The property with dots, example - a.b.cuppercase
- To transform to uppercase stringpublic static java.lang.String prependUri(java.lang.String baseUri, java.lang.String uri)
baseUri
- The uri to prepend. Eg. /foouri
- The uri to combine with the baseUri. Eg. /barpublic static java.lang.String capitalize(java.lang.String str)
str
- The string to capitalize@Nullable public static java.lang.String trimToNull(@Nullable java.lang.String string)
string
- the string to trimpublic static boolean isTrue(java.lang.String booleanString)
booleanString
- The boolean string