public final class StringUtils extends Object
StringUtils
.Modifier and Type | Field and Description |
---|---|
static int |
LINNEAN_YEAR |
static String |
WHITESPACES_LIST
This includes some special whitespaces which not present in standard trim list:
U+0085 Next Line (NEL)
U+00A0 No-Break Space (NBSP)
U+000C Form Feed (FF)
U+2007 Figure Space
|
Modifier and Type | Method and Description |
---|---|
static String |
decodeUtf8Garbage(String text)
Tries to decode a UTF8 string only if common UTF8 character combinations are found which are unlikely to be correctly encoded text.
|
static String |
deleteWhitespace(String str)
Removes all whitespace characters from the String.
|
static String |
emptyLowerCase(String str)
Returns an empty string or the trimmed lower case version of any input, but never NULL.
|
static String |
foldToAscii(String x)
Removes accents & diacretics and converts ligatures into several chars
|
static String |
getStackTrace(Throwable aThrowable)
Reads a stack trace from an exception and returns it as a String.
|
static String |
increase(String x)
Increase a given string by 1, i.e.
|
static String |
joinIfNotNull(String delimiter,
Object... values)
Joins a list of objects into a string, skipping null values and calling toString on each object.
|
static Boolean |
parseBoolean(String x)
Simple boolean parsing method that understands yes,y,true,t or 1 as true and respective values for false.
|
static Integer |
parseInteger(String x)
Simple integer parsing method that does not throw any exception but
returns null instead.
|
static String |
randomAuthor() |
static String |
randomEpithet() |
static String |
randomFamily() |
static String |
randomGenus() |
static String |
randomSpecies()
Creates a random species binomial with no meaning at all, but highly randomized.
|
static String |
randomSpeciesYear() |
static String |
randomString(int len)
Creates a random string in upper case of given length with purely latin characters only.
|
static String |
thenJoin(Function<String,String> fct,
String... parts)
Apply a function then join the result using a space if not null.
|
static String |
trim(String str)
Strips a set of whitespace characters from the start and end of a String.
|
static String |
unescapeUnicodeChars(String text)
Unescapes various unicode escapes if existing:
java unicode escape, four hexadecimal digits
\ uhhhh
octal escape
\nnn
The octal value nnn, where nnn stands for 1 to 3 digits between ‘0’ and ‘7’.
|
static Map<String,String> |
upper(Map<String,String> map)
Uppercases all keys and values in a Map.
|
public static final int LINNEAN_YEAR
public static final String WHITESPACES_LIST
public static String foldToAscii(String x)
x
- string to fold into ASCIIpublic static String thenJoin(Function<String,String> fct, String... parts)
fct
- the function to apply or Function.identity() if noneparts
- public static String increase(String x)
x
- public static String randomSpecies()
public static String randomGenus()
public static String randomEpithet()
public static String randomFamily()
public static String randomAuthor()
public static String randomString(int len)
len
- public static String randomSpeciesYear()
public static Integer parseInteger(String x)
x
- public static Boolean parseBoolean(String x)
x
- public static String unescapeUnicodeChars(String text)
text
- string potentially containing unicode escape charspublic static String decodeUtf8Garbage(String text)
public static String joinIfNotNull(String delimiter, Object... values)
delimiter
- to join the values withvalues
- to be joinedpublic static Map<String,String> upper(Map<String,String> map)
map
- public static String emptyLowerCase(String str)
public static String getStackTrace(Throwable aThrowable)
aThrowable
- public static String trim(String str)
str
- String to be trimmedpublic static String deleteWhitespace(String str)
str
- String to be processedCopyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.