public class StringUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EMPTY_STRING |
static java.lang.String |
NULL_STRING |
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
countMatches(java.lang.String str,
char ch)
Return count of matching character in
str . |
static boolean |
hasLength(java.lang.CharSequence str)
Return true if
str is neither null nor empty. |
static boolean |
hasText(java.lang.CharSequence str)
Check whether
str is a meaningful string or not. |
static boolean |
isEmpty(java.lang.CharSequence str)
Return true if
str is either null or meaningless string. |
static java.lang.String |
join(java.lang.Iterable<?> values,
java.lang.String token)
Concat
values to token . |
static java.lang.String |
join(java.lang.Object[] values,
java.lang.String token)
Concat
values to token . |
static int |
length(java.lang.CharSequence str)
Get length of
str . |
static java.lang.String |
ltrim(java.lang.String str)
Remove space in left of the
str . |
static void |
multiply(java.lang.StringBuilder buffer,
java.lang.String word,
int repeat)
Make a string by repeating
symbol n times. |
static java.lang.String |
multiply(java.lang.String word,
int repeat)
Make a string by repeating
symbol n times. |
static java.lang.String |
nvl(java.lang.String... strs)
Return an
non-null string by inspecting array strs . |
static java.lang.String |
removePrefix(java.lang.String str,
java.lang.String prefix)
Remove prefix if exists.
|
static java.lang.String |
removeSuffix(java.lang.String str,
java.lang.String suffix)
Remove suffix if exists.
|
static java.lang.String |
repeat(java.lang.String word,
int repeat)
Alias of
multiply(String, int) . |
static java.lang.String |
rtrim(java.lang.String str)
Remove space in right of the
str . |
static java.util.List<java.lang.String> |
split(java.lang.String string,
java.lang.String delimiter)
Split
string with a delimiter . |
static java.lang.String |
split(java.lang.String string,
java.lang.String delimiter,
int index)
Split
string with a delimiter and return index -th string. |
static java.lang.String |
trim(java.lang.String str)
Remove space on both sides of
str . |
static java.lang.String |
uncapitalize(java.lang.String str)
Set 1st character to lower case.
|
public static final java.lang.String NULL_STRING
public static final java.lang.String EMPTY_STRING
public static boolean isEmpty(java.lang.CharSequence str)
str
is either null or meaningless string. Otherwise return false.str
- string to inspecthasText(CharSequence)
public static int length(java.lang.CharSequence str)
Get length of str
. If str
is null
, then return 0.
str
- string to get lengthstr
public static boolean hasLength(java.lang.CharSequence str)
str
is neither null
nor empty. Otherwise, return
false.str
- string to inspectpublic static boolean hasText(java.lang.CharSequence str)
str
is a meaningful string or not.str
- string to inspectisEmpty(CharSequence)
public static java.lang.String nvl(java.lang.String... strs)
non-null
string by inspecting array strs
. If
strs
is null, return empty string ""
.strs
- variable argument of stringpublic static java.util.List<java.lang.String> split(java.lang.String string, java.lang.String delimiter)
string
with a delimiter
.string
- string to splitdelimiter
- a delimiterpublic static java.lang.String split(java.lang.String string, java.lang.String delimiter, int index)
string
with a delimiter
and return index
-th string.string
- string to splitdelimiter
- a delimiterindex
- string indexpublic static java.lang.String ltrim(java.lang.String str)
str
.str
- target stringpublic static java.lang.String rtrim(java.lang.String str)
str
.str
- target stringpublic static java.lang.String trim(java.lang.String str)
str
.str
- target stringpublic static java.lang.String join(java.lang.Iterable<?> values, java.lang.String token)
Concat values
to token
. If values
is empty, return an empty string.
values
- Iterable
which contain stringstoken
- concat targetpublic static java.lang.String join(java.lang.Object[] values, java.lang.String token)
Concat values
to token
. If values
is empty, return an empty string.
values
- Object
which contain stringstoken
- concat targetpublic static java.lang.String multiply(java.lang.String word, int repeat)
symbol
n
times.word
- word to repeatrepeat
- repeat timespublic static void multiply(java.lang.StringBuilder buffer, java.lang.String word, int repeat)
symbol
n
times.buffer
- StringBuilder
to append wordword
- word to repeatrepeat
- repeat timespublic static java.lang.String repeat(java.lang.String word, int repeat)
multiply(String, int)
.word
- word to repeatrepeat
- repeat timesmultiply(String, int)
public static java.lang.String uncapitalize(java.lang.String str)
str
- target stringpublic static int countMatches(java.lang.String str, char ch)
str
.str
- target stringch
- character to matchpublic static java.lang.String removePrefix(java.lang.String str, java.lang.String prefix)
str
- string to removeprefix
- prefix to removepublic static java.lang.String removeSuffix(java.lang.String str, java.lang.String suffix)
str
- string to removesuffix
- suffix to remove