public class Strings extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ELLIPSIS_STRING
The correct ellipsis string.
|
static String |
NO_ELLIPSIS_STRING
A string with three dots that should is often mean
to be the ellipsis string "?" or character '?'.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Strings() |
| Modifier and Type | Method and Description |
|---|---|
static String |
abbreviateCenter(String str,
int maxLength)
Abbreviates the given string if it exceeds the given maximum lengt
by replacing its center part with an ellipsis ('…').
|
static String |
get(String str,
Object... args)
If no arguments are provided, the plain String is returned.
|
static boolean |
isBlank(String str)
Checks if the given string is whitespace, empty ("") or
null. |
static boolean |
isEmpty(String str)
Checks if the given string is empty ("") or
null. |
static boolean |
isNotBlank(String str)
Checks if the given string is not empty ("")
not
null and not whitespace only. |
static boolean |
isNotEmpty(String str)
Checks if the given string is not empty (""
and not
null. |
static boolean |
isTrimmed(String str)
Checks if the given string is
null, empty ("")
or the first and last characters are not whitespace. |
static boolean |
startsWithIgnoreCase(String str,
String prefix)
Checks if
str starts with the given prefix ignoring cases. |
public static final String NO_ELLIPSIS_STRING
ELLIPSIS_STRING,
Constant Field Valuespublic static final String ELLIPSIS_STRING
NO_ELLIPSIS_STRING,
Constant Field Valuespublic static boolean isBlank(String str)
null
str - the string to check, may be nulltrue if the string is whitespace, empt
or nullisEmpty(String)public static boolean isNotBlank(String str)
null and not whitespace only
str - the string to check, may be nulltrue if the string is not empt
and not null and not whitespace onlyisEmpty(String)public static boolean isEmpty(String str)
null
str - the string to check, may be nulltrue if the string is empty or nullisBlank(String)public static boolean isNotEmpty(String str)
null
str - the string to check, may be nulltrue if the string is not empty and not nullisBlank(String)public static boolean isTrimmed(String str)
null, empty ("")
or the first and last characters are not whitespace
str - the string to check, may be nulltrue if the string is null, empty
or the first and last characters are not whitespace.public static boolean startsWithIgnoreCase(String str, String prefix)
str starts with the given prefix ignoring cases
null is handled safely; if both arguments are null, tru
is returned, false otherwise
str - the test string to check, may be nullprefix - the prefix to check for, may be nulltrue, if the string starts with the prefix, ignoring cases
false otherwiseString.startsWith(java.lang.String)public static String abbreviateCenter(String str, int maxLength)
null or shorter than the limit
it is returned as is.str - the source stringmaxLength - the maximum length of the result stringstr if its length is less than or equal to maxLength
an abbreviated string with length maxLength wher
the center is replaced by an ellipsispublic static String get(String str, Object... args)
String.formatargs - optional format arguments forwarded to String#formatString.format(String, Object...)Copyright © 2009-2014 JGoodies Software GmbH. All Rights Reserved.