Package org.apache.tomcat.util.buf
Class StringUtils
- java.lang.Object
-
- org.apache.tomcat.util.buf.StringUtils
-
public final class StringUtils extends java.lang.ObjectUtility methods to build a separated list from a given set (not java.util.Set) of inputs and return that list as a string or append it to an existing StringBuilder. If the given set is null or empty, an empty string will be returned.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidjoin(java.lang.Iterable<java.lang.String> iterable, char separator, java.lang.StringBuilder sb)Joins the elements of an iterable with the specified separator and appends the result to the given StringBuilder.static <T> voidjoin(java.lang.Iterable<T> iterable, char separator, java.util.function.Function<T,java.lang.String> function, java.lang.StringBuilder sb)Joins the elements of an iterable using the specified separator and function, and appends the result to the given StringBuilder.static java.lang.Stringjoin(java.lang.String[] array)Joins the elements of a string array with a comma separator.static voidjoin(java.lang.String[] array, char separator, java.lang.StringBuilder sb)Joins the elements of a string array with the specified separator and appends the result to the given StringBuilder.static java.lang.Stringjoin(java.lang.String a, java.lang.String b)Joins two strings with a comma separator.static java.lang.Stringjoin(java.util.Collection<java.lang.String> collection)Joins the elements of a collection with a comma separator.static java.lang.Stringjoin(java.util.Collection<java.lang.String> collection, char separator)Joins the elements of a collection with the specified separator.static <T> voidjoin(T[] array, char separator, java.util.function.Function<T,java.lang.String> function, java.lang.StringBuilder sb)Joins the elements of an array using the specified separator and function, and appends the result to the given StringBuilder.static java.lang.String[]splitCommaSeparated(java.lang.String s)Splits a comma-separated string into an array of String values.
-
-
-
Method Detail
-
join
public static java.lang.String join(java.lang.String a, java.lang.String b)Joins two strings with a comma separator.- Parameters:
a- the first stringb- the second string- Returns:
- the joined string
-
join
public static java.lang.String join(java.lang.String[] array)
Joins the elements of a string array with a comma separator.- Parameters:
array- the array of strings to join- Returns:
- the joined string
-
join
public static void join(java.lang.String[] array, char separator, java.lang.StringBuilder sb)Joins the elements of a string array with the specified separator and appends the result to the given StringBuilder.- Parameters:
array- the array of strings to joinseparator- the separator charactersb- the StringBuilder to append to
-
join
public static java.lang.String join(java.util.Collection<java.lang.String> collection)
Joins the elements of a collection with a comma separator.- Parameters:
collection- the collection of strings to join- Returns:
- the joined string
-
join
public static java.lang.String join(java.util.Collection<java.lang.String> collection, char separator)Joins the elements of a collection with the specified separator.- Parameters:
collection- the collection of strings to joinseparator- the separator character- Returns:
- the joined string
-
join
public static void join(java.lang.Iterable<java.lang.String> iterable, char separator, java.lang.StringBuilder sb)Joins the elements of an iterable with the specified separator and appends the result to the given StringBuilder.- Parameters:
iterable- the iterable of strings to joinseparator- the separator charactersb- the StringBuilder to append to
-
join
public static <T> void join(T[] array, char separator, java.util.function.Function<T,java.lang.String> function, java.lang.StringBuilder sb)Joins the elements of an array using the specified separator and function, and appends the result to the given StringBuilder.- Type Parameters:
T- the element type- Parameters:
array- the array to joinseparator- the separator characterfunction- the function to apply to each elementsb- the StringBuilder to append to
-
join
public static <T> void join(java.lang.Iterable<T> iterable, char separator, java.util.function.Function<T,java.lang.String> function, java.lang.StringBuilder sb)Joins the elements of an iterable using the specified separator and function, and appends the result to the given StringBuilder.- Type Parameters:
T- the element type- Parameters:
iterable- the iterable to joinseparator- the separator characterfunction- the function to apply to each elementsb- the StringBuilder to append to
-
splitCommaSeparated
public static java.lang.String[] splitCommaSeparated(java.lang.String s)
Splits a comma-separated string into an array of String values. Whitespace around the commas is removed. Null or empty values will return a zero-element array.- Parameters:
s- The string to split by commas.- Returns:
- An array of String values.
-
-