|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object spiffy.core.lang.StringHelper
public class StringHelper
Helper methods for string manipulations and/or string representations of various entities
Constructor Summary | |
---|---|
StringHelper()
|
Method Summary | |
---|---|
static boolean |
in(String searchString,
String... searchStringList)
Given a string check to see if it is in a collection of strings (using equals()) |
static boolean |
inAndNonEmpty(String searchString,
String... searchStringList)
Given a string, trim it, and if different from the string "", check to see if it is in a collection of strings (using equals()). |
static String |
join(String delimiter,
Iterator<?> iterator)
Join 0..n strings separated by a delimiter. |
static String |
join(String delimiter,
String... strings)
Join 0..n strings separated by a delimiter. |
static String |
removeAll(String baseString,
Character... removeChars)
Remove all occurrences of all specified characters. |
static String |
repeatLeftJoin(String baseString,
int endSize,
String... joinStrings)
Create a string by repeatedly joining/appending one or more strings in front of the string until the resulting string is equal to or as close possible to some length. |
static String |
repeatRightJoin(String baseString,
int endSize,
String... joinStrings)
Create a string by repeatedly joining/appending one or more strings at the end of the string until the resulting string is equal to or as close possible to some length. |
static String |
toString(Throwable throwable)
Returns a string representation of any throwable (e.g. exceptions) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringHelper()
Method Detail |
---|
public static boolean in(String searchString, String... searchStringList)
searchString
- string to search for. If null false is returned.searchStringList
- list of strings to search within
IllegalArgumentException
- when argument SearchStringList has length > 0public static boolean inAndNonEmpty(String searchString, String... searchStringList)
This is quite often used in web programming, where input on the server side may either be null, "" or some string.
searchString
- string to search forsearchStringList
- list of strings to search within
IllegalArgumentException
- when argument SearchStringList has length > 0in(String, String[])
public static String join(String delimiter, Iterator<?> iterator)
join(iterator)becomes
"a, b, c"
delimiter
- the delimiter to insert between each string.iterator
- the iterator of elements to concatenate.
public static String join(String delimiter, String... strings)
join(", ", "a", "b", "c")becomes
"a, b, c"
delimiter
- the delimiter to insert between each string.strings
- the array of strings to concatenate.
public static String removeAll(String baseString, Character... removeChars)
This is an easy way to e.g. remove all formatting chars such as ' ', '\t', '\n' from Strings for easy comparison of code generated String.
baseString
- the string to trimremoveChars
- the characters to remove
public static String repeatLeftJoin(String baseString, int endSize, String... joinStrings)
repeatLeftJoin("100", 6, "#"));
yields "fully fill", "###100"
repeatLeftJoin("100", 6, "##"));
Yields "##100",
- Parameters:
baseString
- the string to join strings ontoendSize
- the resulting sizejoinStrings
- one or more strings to join onto the basestring. If the empty list is given, the baseString is returned.
- Returns:
- a joined string
public static String repeatRightJoin(String baseString, int endSize, String... joinStrings)
repeatLeftJoin("100", 6, "#"));Yields
"fully fill", "###100"
repeatLeftJoin("100", 6, "##"));Yields
"##100",
baseString
- the string to join strings ontoendSize
- the resulting sizejoinStrings
- one or more strings to join onto the basestring. If the empty list is given, the baseString is
returned.
public static String toString(Throwable throwable)
throwable
- the throwable/exception to get a representation from
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |