Modifier and Type | Method and Description |
---|---|
static String |
capitalize(String name)
Returns a new string with the first character in upper case.
|
static String |
checkNotBlank(String string,
String stringName)
Deprecated.
|
static String |
emptyToNull(String string)
If the string is
empty , returns null ,
otherwise returns the given string. |
static List<String> |
getTokens(String css)
Returns a list of trimmed tokens from given token list.
|
static boolean |
isEmpty(String string)
Returns
true if the string argument is null or it contains whitespace
characters only, otherwise returns false . |
static boolean |
isNotEmpty(String string)
Returns
false if the string argument is null or it contains
whitespace characters only, otherwise returns true . |
static String |
join(Iterable<?> iterable,
String separator)
Joins given list of items with given separator.
|
static String |
join(Object[] array,
String separator)
Joins given list of items with given separator.
|
static StringBuilder |
join(StringBuilder builder,
Iterable<?> iterable,
String separator)
Joins given iterable of items with given separator.
|
static StringBuilder |
join(StringBuilder builder,
Object[] array,
String separator)
Joins given array of items with given separator.
|
static String |
limitLength(String str,
int maxLength)
Limits the length of a string to a given length if the length of the string
is greater then the maximal desired length.
|
static String |
ltrim(String s)
Returns the left-side trim of the given string.
|
static String |
nullToEmpty(String string)
If the given string is
null , returns an empty string,
otherwise returns the given string. |
static String |
rtrim(String s)
Returns the right-side trim of the given string.
|
static String |
toNullAwareString(String string)
Returns given string with enclosing apostrophes (e.g.
'manager' ) if the string argument is not null, otherwise it
returns null (string). |
@Deprecated public static String checkNotBlank(String string, String stringName)
Assert.checkNotBlank(String, String)
null
and does not contain just whitespace characters).string
- the string to check if it is not blankstringName
- the name of the string variable that is checked (used for
displaying in a thrown exception)NullPointerException
- (unchecked)
if the string
argument is null
IllegalArgumentException
- (unchecked)
if the string
argument contains just whitespace
characterspublic static boolean isEmpty(String string)
true
if the string
argument is null
or it contains whitespace
characters only, otherwise returns false
. This method is the complement of the
isNotEmpty(String)
method.string
- any String
instance. Can be null
true
if the string
argument is null
or it contains whitespace
characters only, otherwise false
public static boolean isNotEmpty(String string)
false
if the string
argument is null
or it contains
whitespace characters only, otherwise returns true
. This method is the complement of
the isEmpty(String)
method.string
- any String
instance. Can be null
false
if the string
argument is null
or it contains
whitespace characters only, otherwise true
public static String nullToEmpty(String string)
null
, returns an empty string,
otherwise returns the given string.string
- public static String emptyToNull(String string)
empty
, returns null
,
otherwise returns the given string.string
- null
public static String toNullAwareString(String string)
'manager'
) if the string argument is not null, otherwise it
returns null
(string).string
- the string to be checked for null
null
(string) if the string argument is null
public static List<String> getTokens(String css)
css
- a comma-separated list of strings, may be nullnull
, may be empty.public static String join(Object[] array, String separator)
join(["foo",
"bar", "baz"], ", ")
(note the space after comma.
null
items are represented as empty strings.
array
- the items, not null. String.valueOf(Object)
is used on the items to convert it to string.separator
- the separator character to usenull
if null array inputpublic static StringBuilder join(StringBuilder builder, Object[] array, String separator)
builder
- not nullarray
- not nullseparator
- public static String join(Iterable<?> iterable, String separator)
join(["foo",
"bar", "baz"], ", ")
(note the space after comma.
null
items are represented as empty strings.
iterable
- the items, not null. String.valueOf(Object)
is used on the items to convert it to string.separator
- the separator character to use, not null.null
if null array inputpublic static StringBuilder join(StringBuilder builder, Iterable<?> iterable, String separator)
builder
- not nulliterable
- not nullseparator
- public static String limitLength(String str, int maxLength)
str
- the string the length of which should be limited to the maximal
lengthmaxLength
- the desired maximal length of the stringmaxLength
parameter. If the string
is null
then null
is returned.IllegalArgumentException
- if the maxLength
is negativepublic static String ltrim(String s)
s
- public static String rtrim(String s)
s
- Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.