public final class StringUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
EMPTY_STRING
Constant for an empty String.
|
static String[] |
EMPTY_STRING_ARRAY
Constant for an empty String array.
|
static String |
FALSE
Constant for the value false.
|
static char |
SPACE
a space.
|
static String |
TRUE
Constant for the value true.
|
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
capitalize(String str)
Capitalizes the first character of the provided string.
|
static String |
convertDotToUnderscore(String dottedProperty)
Replace the dots in the property with underscore and
transform to uppercase.
|
static String |
convertDotToUnderscore(String dottedProperty,
boolean uppercase)
Replace the dots in the property with underscore and
transform to uppercase based on given flag.
|
static boolean |
hasText(CharSequence str)
Return whether the given string has non whitespace characters.
|
static List<String> |
internListOf(Object... objects)
Converts the given objects into a set of interned strings contained within an internal pool of sets.
|
static Map<String,Object> |
internMapOf(Object... values)
Converts the given objects into a map of interned strings.
|
static boolean |
isDigits(String str)
Is the given string a series of digits.
|
static boolean |
isEmpty(CharSequence str)
Return whether the given string is empty.
|
static boolean |
isNotEmpty(CharSequence str)
Return whether the given string is not empty.
|
static boolean |
isTrue(String booleanString)
Is the boolean string true.
|
static String |
prependUri(String baseUri,
String uri)
Prepends a partial uri and normalizes / characters.
|
static String[] |
tokenizeToStringArray(String str,
String delimiters)
Tokenize the given String into a String array via a StringTokenizer.
|
static String[] |
tokenizeToStringArray(String str,
String delimiters,
boolean trimTokens,
boolean ignoreEmptyTokens)
Tokenize the given String into a String array via a StringTokenizer.
|
static String |
trimToNull(String string)
Trims the supplied string.
|
public static final String TRUE
public static final String FALSE
public static final String[] EMPTY_STRING_ARRAY
public static final String EMPTY_STRING
public static final char SPACE
public static boolean isEmpty(@Nullable CharSequence str)
str
- The stringpublic static boolean isNotEmpty(@Nullable CharSequence str)
str
- The stringpublic static boolean hasText(@Nullable CharSequence str)
str
- The stringpublic static List<String> internListOf(Object... objects)
String.intern()
.objects
- The objectspublic static Map<String,Object> internMapOf(Object... values)
String.intern()
.values
- The objectsCollectionUtils.mapOf(Object...)
public static boolean isDigits(String str)
str
- The stringpublic static String[] tokenizeToStringArray(String str, 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 String[] tokenizeToStringArray(String str, 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 String convertDotToUnderscore(String dottedProperty)
dottedProperty
- The property with dots, example - a.b.cpublic static String convertDotToUnderscore(String dottedProperty, boolean uppercase)
dottedProperty
- The property with dots, example - a.b.cuppercase
- To transform to uppercase stringpublic static String prependUri(String baseUri, String uri)
baseUri
- The uri to prepend. Eg. /foouri
- The uri to combine with the baseUri. Eg. /barpublic static String capitalize(String str)
str
- The string to capitalize@Nullable public static String trimToNull(@Nullable String string)
string
- the string to trimpublic static boolean isTrue(String booleanString)
booleanString
- The boolean string