public final class StringUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Comparator<String> |
CASE_INSENSITIVE_COMPARATOR
Comparator that orders
String objects as by compareToIgnoreCase . |
static String |
RESOURCE_KEY_NOT_FOUND_PREFIX |
static String |
RESOURCE_KEY_NOT_FOUND_SUFFIX |
static String |
SEPARATOR_COLON |
static char |
SEPARATOR_COLON_CHAR |
static String |
SEPARATOR_COMMA |
static char |
SEPARATOR_COMMA_CHAR |
static String |
SEPARATOR_DOT |
static char |
SEPARATOR_DOT_CHAR |
static String |
SEPARATOR_FORWARD_SLASH |
static char |
SEPARATOR_FORWARD_SLASH_CHAR
Forward slash character.
|
Modifier and Type | Method and Description |
---|---|
static String |
camelCase(String text)
Converts the given String to camel case.
|
static String |
camelCase(String text,
char separator)
Converts the given String to camel case.
|
static String |
capitalize(String in)
Capitalize by uppercasing the first letter of the given String (e.g.
|
static String |
decapitalize(String in)
Decapitalize without using
java.beans , as that package is not available on all
target platforms. |
static String |
quietValueOf(Object object)
Version of
String.valueOf that fails 'quietly' for null Strings and
returns an empty String rather than a String saying null . |
static String |
substringAfter(String text,
String after)
Returns the portion of the overall string that comes after the first occurance of the given
string.
|
static String |
substringAfterLast(String text,
char after)
Returns the portion of the overall string that comes after the last occurance of the given
string.
|
static String |
substringAfterLast(String text,
String after)
Returns the portion of the overall string that comes after the last occurance of the given
string.
|
static String |
substringBefore(String text,
String before)
Returns the portion of the overall string that comes before the given string.
|
static String |
uncamelCase(String camelCase)
Converts the given string from camel case.
|
static String |
uncamelCase(String camelCase,
char separator)
Converts the given string from camel case.
|
public static final char SEPARATOR_FORWARD_SLASH_CHAR
For environments that use the fully qualified class name (eg. SwingMetawidget) as part of the path, we must use '/' not '.' as the separator.
public static final String SEPARATOR_FORWARD_SLASH
public static final char SEPARATOR_DOT_CHAR
public static final String SEPARATOR_DOT
public static final char SEPARATOR_COMMA_CHAR
public static final String SEPARATOR_COMMA
public static final char SEPARATOR_COLON_CHAR
public static final String SEPARATOR_COLON
public static final String RESOURCE_KEY_NOT_FOUND_PREFIX
public static final String RESOURCE_KEY_NOT_FOUND_SUFFIX
public static final Comparator<String> CASE_INSENSITIVE_COMPARATOR
String
objects as by compareToIgnoreCase
.
Like String.CASE_INSENSITIVE_COMPARATOR but sorts case sensitively within case insensitive groups, thereby ensuring comparing 'Foo' to 'foo' does not equal 0. This is important if the Comparator is used within, say, a TreeMap. Otherwise the TreeMap will 'collapse' case insensitive keys.
public static String decapitalize(String in)
java.beans
, as that package is not available on all
target platforms.
Following the rules defined in java.beans.Introspector: "This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone. Thus 'FooBah' becomes 'fooBah' and 'X' becomes 'x', but 'URL' stays as 'URL'"
public static String capitalize(String in)
The rules for capitalizing are not clearly defined in java.beans.Introspector, but
we try to make capitalize
the inverse of decapitalize
(this
includes the 'second character' clause). For example, in Eclipse if you define a property
'aB123' and then 'generate getters' Eclipse will generate a method called 'getaB123'
not 'getAB123'. See: https://community.jboss.org/thread/203202?start=0&tstart=0
public static String uncamelCase(String camelCase)
For example, converts fooBar1
into Foo Bar 1
. Used primarily to
convert property names and paths into human-readable UI labels.
public static String uncamelCase(String camelCase, char separator)
For example, converts fooBar1
into Foo Bar 1
. Used primarily to
convert property names and paths into human-readable UI labels.
public static String camelCase(String text)
The first letter following a separator is capitalized, as per Java convention. Non alpha numeric characters are also stripped. However no attempt is made to de capitalize the first name, because that gets very ambiguous with names like 'URL', 'ID' etc.
Used primarily to convert property paths into ids.
public static String camelCase(String text, char separator)
The first letter following a separator is capitalized, as per Java convention. Non alpha numeric characters are also stripped. The start of the String is decapitalized.
Used primarily to convert property paths into ids.
public static String quietValueOf(Object object)
String.valueOf
that fails 'quietly' for null
Strings and
returns an empty String rather than a String saying null
.public static String substringBefore(String text, String before)
public static String substringAfter(String text, String after)
public static String substringAfterLast(String text, char after)
Copyright © 2015. All Rights Reserved.