Package org.forgerock.openig.util
Class StringUtil
- java.lang.Object
 - 
- org.forgerock.openig.util.StringUtil
 
 
- 
public final class StringUtil extends Object
Miscellaneous string utility methods. 
- 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringasString(InputStream is, Charset charset)Reads the provided input stream as a string and then closes the stream.static Stringjoin(String separator, Iterable<?> elements)Joins a collection of elements into a single string value, with a specified separator.static Stringjoin(String separator, Object... elements)Joins an array of strings into a single string value, with a specified separator.static Stringslug(String value)Transform the input String value into a slug: a simpler adaptation that is compatible for usage inside an URI (without requiring URL encoding).static StringtoSIAbbreviation(TimeUnit timeUnit)Return the SI abbreviation from the given TimeUnit name. 
 - 
 
- 
- 
Method Detail
- 
join
public static String join(String separator, Iterable<?> elements)
Joins a collection of elements into a single string value, with a specified separator.- Parameters:
 separator- the separator to place between joined elements.elements- the collection of strings to be joined.- Returns:
 - the string containing the joined elements.
 
 
- 
join
public static String join(String separator, Object... elements)
Joins an array of strings into a single string value, with a specified separator.- Parameters:
 separator- the separator to place between joined elements.elements- the array of strings to be joined.- Returns:
 - the string containing the joined string array.
 
 
- 
asString
public static String asString(InputStream is, Charset charset) throws IOException
Reads the provided input stream as a string and then closes the stream.- Parameters:
 is- the input stream to be read.charset- the character set encoding of the input stream.- Returns:
 - the content of the stream.
 - Throws:
 IOException- If an I/O error occurs.
 
- 
slug
public static String slug(String value)
Transform the input String value into a slug: a simpler adaptation that is compatible for usage inside an URI (without requiring URL encoding).Examples:
slug("A sentence with blanks, commas and extra punctuation ! ") .equals("a-sentence-with-blanks-commas-and-extra-punctuation"); slug("{ClientHandler}/heap/2").equals(clienthandler-heap-2);- Parameters:
 value- value to be transformed- Returns:
 - A slug version of the input
 
 
 - 
 
 -