Class StringUtils
- java.lang.Object
-
- org.dashbuilder.common.client.StringUtils
-
public class StringUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisBlank(String str)Checks if a String is whitespace, empty ("") or null.static booleanisEmpty(String str)Checks if a String is empty ("") or null.static Stringjoin(Object[] array, String separator)Joins the elements of the provided array into a single String containing the provided list of elements.static Stringjoin(Collection strings, String delimiter)Joins a collection of string with a given delimiter.static List<String>split(String str, char separatorChar)Splits the provided text into an array, separator specified.
-
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = falseNOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().
- Parameters:
str- the String to check, may be null- Returns:
trueif the String is empty or null
-
isBlank
public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false- Parameters:
str- the String to check, may be null- Returns:
trueif the String is null, empty or whitespace
-
join
public static String join(Object[] array, String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. A
nullseparator is the same as an empty String (""). Null objects or empty strings within the array are represented by empty strings.StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], "--") = "a--b--c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join(["a", "b", "c"], "") = "abc" StringUtils.join([null, "", "a"], ',') = ",,a"
- Parameters:
array- the array of values to join together, may be nullseparator- the separator character to use, null treated as ""- Returns:
- the joined String,
nullif null array input
-
join
public static String join(Collection strings, String delimiter)
Joins a collection of string with a given delimiter.- Parameters:
strings- The collection of strings to join.delimiter- The delimiter to use to join them.- Returns:
- The string built by joining the string with the delimiter.
-
split
public static List<String> split(String str, char separatorChar)
Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer.
The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.
A
nullinput String returnsnull.StringUtils.split(null, *) = null StringUtils.split("", *) = [] StringUtils.split("a.b.c", '.') = ["a", "b", "c"] StringUtils.split("a..b.c", '.') = ["a", "b", "c"] StringUtils.split("a:b:c", '.') = ["a:b:c"] StringUtils.split("a b c", ' ') = ["a", "b", "c"]- Parameters:
str- the String to parse, may be nullseparatorChar- the character used as the delimiter- Returns:
- an list of parsed Strings,
nullif null String input
-
-