public final class StringTools extends Object
| Modifier and Type | Method and Description |
|---|---|
static <O1,O2> String |
couplesToString(Map<O1,O2> couples,
String separatorKeysValues,
String separatorCouples)
Create a string representing a list of couples (key + value)
|
static <T> Comparator<T> |
createStringComparator()
Create a comparator according to the toString method
|
static int |
length(String string)
Null-safe string length
|
static Iterator<String> |
lineIterator(String string)
Create a line iterator, without null or empty lines
|
static Iterator<String> |
lineIterator(StringBuilder stringBuilder)
Create a line iterator, without null or empty lines
|
static String |
listToString(List<? extends Object> list,
String delimiter)
Display a list of objects
|
static String |
replaceAccents(String string)
Replace accented characters by their corresponding non-accented characters
|
static String |
replaceConsecutiveWhitespaces(String string)
Replace consecutive whitespaces by a single whitespace
|
static String |
replaceConsecutiveWhitespacesByUnderscore(String string)
Replace consecutive whitespaces by an underscore
|
static String |
replaceNonAlpha(String string)
Replace non alpha characters by a whitespace (accentuated characters are considered as non alpha characters)
|
static String |
truncate(StringBuilder toTruncate,
String truncation)
Truncate a string by the end
|
static String |
truncate(String toTruncate,
String truncation)
Truncate a string by the end
|
public static <O1,O2> String couplesToString(Map<O1,O2> couples, String separatorKeysValues, String separatorCouples)
O1 - Keys typeO2 - Values typecouples - Couples (key + value)separatorKeysValues - Separator between keys and valuesseparatorCouples - Separator between couplespublic static String listToString(List<? extends Object> list, String delimiter)
list - The list to browseddelimiter - The delimiter between each objectpublic static int length(String string)
string - Stringpublic static Iterator<String> lineIterator(String string)
string - Stringpublic static Iterator<String> lineIterator(StringBuilder stringBuilder)
stringBuilder - Stringpublic static String replaceAccents(String string)
string - Accented stringpublic static String replaceConsecutiveWhitespaces(String string)
string - String to transformpublic static String replaceConsecutiveWhitespacesByUnderscore(String string)
string - String to transformpublic static String replaceNonAlpha(String string)
string - String to transformpublic static String truncate(String toTruncate, String truncation)
toTruncate - String to truncatetruncation - String to deletepublic static String truncate(StringBuilder toTruncate, String truncation)
toTruncate - String to truncatetruncation - String to deletepublic static <T> Comparator<T> createStringComparator()
T - TypeCopyright © 2009-2013 IRD. All Rights Reserved.