public final class StringUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
asListOfChars(String value) |
static int |
compare(String one,
String two)
Compares two strings with
String.compare(). |
static boolean |
equals(String original,
String compare)
compares two strings if equal (
String.equals method) |
static boolean |
equals(String original,
String compare,
boolean ignoreCase)
compares two strings if equal (
String.equals or
String.equalsIgnoreCase method) |
static List<String> |
getWords(String text)
Extracts words from text removing non alpha characters
|
static boolean |
isNullOrEmpty(String value)
Checks if string is
null or empty == "" |
static boolean |
isNullOrEmptyTrimmed(String value)
Checks if string is null, empty or contains only spaces
|
static boolean |
isWord(String word)
Checks if given string is a single word (doesn't accepts words with "-" as a single word!)
|
static String |
join(HashMap<String,String> params,
String separator) |
static String |
join(List<?> list,
String separator)
Joins list of string items to a single string, where items are separated
with a defined separator.
|
static String |
join(Object[] args,
String separator)
Joins list of string items to a single string, where items are separated
with a defined separator.
|
static String |
join(Set<String> items,
String separator)
Joins list of string items to a single string, where items are separated
with a defined separator.
|
static String |
toStringOrNull(Object value) |
static String |
trim(String value)
null resilient trim
|
static String |
trimAll(String text,
String toBeTrimmed) |
static String |
trimDoubleSpaces(String value)
Additionally to outer
trim() double spaces are removed. |
static String |
trimEnd(String text)
Trims only end of text
|
static String |
trimInner(String value)
Additionally to outer
trim() all inner spaces are removed. |
static String |
trimStart(String text) |
static String |
trimTextDown(String text,
int size)
Reduces text to max given size preserving words
|
static String |
trimToNull(String text)
Trims down text to null if empty
|
public static boolean isNullOrEmpty(String value)
null or empty == ""value - string to testtrue if null or empty,
false otherwise.public static boolean isNullOrEmptyTrimmed(String value)
value - string to testtrue if null, empty or spaces only,
false otherwise.public static boolean equals(String original, String compare)
String.equals method)original - string to compare againstcompare - string to compare totrue if equal or both null,
false otherwisepublic static boolean equals(String original, String compare, boolean ignoreCase)
String.equals or
String.equalsIgnoreCase method)original - string to compare againstcompare - string to compare toignoreCase - true equalsIgnoreCase is used, false
equals is usedtrue if equal or both null,
false otherwisepublic static int compare(String one, String two)
String.compare(). Method allows
null values.one - to comparetwo - to comparenull, -1 if one
is null, 1 if two is
null, otherwise String.compare() is
calledpublic static String trim(String value)
value - trims value or returns null if nullpublic static String trimDoubleSpaces(String value)
trim() double spaces are removed.value - to remove double spaces frompublic static String trimInner(String value)
trim() all inner spaces are removed.value - to remove inner spaces frompublic static String trimEnd(String text)
text - to be trimmed at the endpublic static String trimToNull(String text)
text - to be trimmedpublic static String join(List<?> list, String separator)
list - to join into stringseparator - to be used between elementspublic static String join(Object[] args, String separator)
args - to join into stringseparator - to be used between elementspublic static String join(Set<String> items, String separator)
items - to join into stringseparator - to be used between elementspublic static List<String> getWords(String text)
text - to extract words frompublic static String trimTextDown(String text, int size)
text - to trim downsize - max desired sizepublic static boolean isWord(String word)
word - to testCopyright © 2015. All rights reserved.