public class StringUtil extends Object
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
capitalize(String str)
Converts first character in
str to uppercase. |
static boolean |
equalsIgnoreCase(String s1,
String s2) |
static String |
fromLiteral(String str) |
static String[] |
getTokens(String str,
String delim,
boolean trim)
Splits given string into tokens with delimiters specified.
|
static boolean |
isEmpty(CharSequence str)
returns true if
str is null or
its length is zero |
static boolean |
isWhitespace(CharSequence str)
returns true if
str is null or
it contains only whitespaces. |
static <T> String |
join(Iterator<T> iter) |
static <T> String |
join(Iterator<T> iter,
String separator) |
static <T> String |
join(Iterator<T> iter,
String separator,
Convertor<T,String> convertor) |
static <T> String |
join(T[] array) |
static <T> String |
join(T[] array,
String separator) |
static <T> String |
join(T[] array,
String separator,
Convertor<T,String> convertor) |
static String |
ordinalize(int number)
Turns a non-negative number into an ordinal string used to
denote the position in an ordered sequence, such as 1st, 2nd,
3rd, 4th
|
static String |
suggest(Filter<String> filter,
String pattern,
boolean tryEmptyVar)
the pattern specified must have variable part ${i}
example: test${i}.txt
it will find a string using pattern, which is accepted by the specified filter.
|
static int[] |
toCodePoints(String str) |
static String |
toLiteral(char ch,
boolean useRaw) |
static String |
toLiteral(CharSequence str,
boolean useRaw) |
static String |
toString(Object obj)
if
obj is null, returns empty string. |
static String |
underscore(String camelCaseWord)
Makes an underscored form from the expression in the string.
|
public static String toString(Object obj)
obj is null, returns empty string.
otherwise returns obj.toString()public static boolean isEmpty(CharSequence str)
str is null or
its length is zeropublic static boolean isWhitespace(CharSequence str)
str is null or
it contains only whitespaces.
Character.isWhitespace(char) is used
to test for whitespace
public static String[] getTokens(String str, String delim, boolean trim)
str - string to be tokenizeddelim - delimiters used for tokenizingtrim - trim the tokenspublic static String suggest(Filter<String> filter, String pattern, boolean tryEmptyVar)
public static String capitalize(String str)
str to uppercase.
This method can be called on string of any length.
str - string to be convertedpublic static String underscore(String camelCaseWord)
Examples:
underscore("activeRecord") // "active_record"
underscore("ActiveRecord") // "active_record"
underscore("firstName") // "first_name"
underscore("FirstName") // "first_name"
underscore("name") // "name"
camelCaseWord - the camel-cased word that is to be converted;public static String ordinalize(int number)
number - the non-negative numberpublic static int[] toCodePoints(String str)
public static <T> String join(T[] array)
public static <T> String join(Iterator<T> iter, String separator, Convertor<T,String> convertor)
public static String toLiteral(char ch, boolean useRaw)
public static String toLiteral(CharSequence str, boolean useRaw)
Copyright © 2021. All rights reserved.