public abstract class StringUtils extends Object
String utility methods.
Mainly for internal use within the framework; consider
Apache's Commons Lang
for a more comprehensive suite of String utilities.
This class delivers some simple functionality that should really be
provided by the core Java String and StringBuilder
classes. It also provides easy-to-use methods to convert between
delimited strings, such as CSV strings, and collections and arrays.
| Modifier and Type | Field and Description |
|---|---|
private static char |
EXTENSION_SEPARATOR |
private static char |
FOLDER_SEPARATOR_CHAR |
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
capitalize(String str)
Capitalize string.
|
private static String |
changeFirstCharacterCase(String str,
boolean capitalize) |
private static boolean |
containsText(CharSequence str) |
static boolean |
containsWhitespace(CharSequence str)
Contains whitespace boolean.
|
static boolean |
containsWhitespace(String str)
Contains whitespace boolean.
|
static int |
countOccurrencesOf(String str,
String sub)
Count occurrences of int.
|
static String |
delete(String inString,
String pattern)
Delete string.
|
static String |
deleteAny(String inString,
String charsToDelete)
Delete any string.
|
static boolean |
endsWithIgnoreCase(String str,
String suffix)
Ends with ignore case boolean.
|
static String |
getFilename(String path)
Gets filename.
|
static String |
getFilenameExtension(String path)
Gets filename extension.
|
static boolean |
hasLength(CharSequence str)
Has length boolean.
|
static boolean |
hasLength(String str)
Check that the given
String is neither null nor of length 0. |
static boolean |
hasNoText(String str)
Has no text boolean.
|
static boolean |
hasText(CharSequence str)
Has text boolean.
|
static boolean |
hasText(String str)
Has text boolean.
|
static boolean |
matchesCharacter(String str,
char singleCharacter)
Matches character boolean.
|
static String |
quote(String str)
Quote string.
|
static Object |
quoteIfString(Object obj)
Quote if string object.
|
static String |
replace(String inString,
String oldPattern,
String newPattern)
Replace string.
|
static boolean |
startsWithIgnoreCase(String str,
String prefix)
Starts with ignore case boolean.
|
static String |
stripFilenameExtension(String path)
Strip filename extension string.
|
static boolean |
substringMatch(CharSequence str,
int index,
CharSequence substring)
Substring match boolean.
|
static CharSequence |
trimAllWhitespace(CharSequence text)
Trim all whitespace char sequence.
|
static String |
trimAllWhitespace(String str)
Trim all whitespace string.
|
static String |
trimLeadingCharacter(String str,
char leadingCharacter)
Trim leading character string.
|
static String |
trimLeadingWhitespace(String str)
Trim leading whitespace string.
|
static String |
trimTrailingCharacter(String str,
char trailingCharacter)
Trim trailing character string.
|
static String |
trimTrailingWhitespace(String str)
Trim trailing whitespace string.
|
static String |
trimWhitespace(String str)
Trim whitespace string.
|
static String |
uncapitalize(String str)
Uncapitalize string.
|
static String |
unqualify(String qualifiedName)
Unqualify string.
|
static String |
unqualify(String qualifiedName,
char separator)
Unqualify string.
|
private static final char FOLDER_SEPARATOR_CHAR
private static final char EXTENSION_SEPARATOR
public static boolean hasLength(CharSequence str)
str - the strpublic static boolean hasLength(String str)
String is neither null nor of length 0.
Note: this method returns true for a String that
purely consists of whitespace.
str - the String to check (may be null)true if the String is not null and has length#hasLength(CharSequence)#hasLength(CharSequence)#hasLength(CharSequence)#hasLength(CharSequence)#hasLength(CharSequence),
#hasText(String)#hasText(String)#hasText(String)#hasText(String)#hasText(String)public static boolean hasText(CharSequence str)
str - the strpublic static boolean hasText(String str)
str - the strpublic static boolean hasNoText(String str)
str - the strprivate static boolean containsText(CharSequence str)
public static boolean containsWhitespace(CharSequence str)
str - the strpublic static boolean containsWhitespace(String str)
str - the strpublic static String trimWhitespace(String str)
str - the strpublic static CharSequence trimAllWhitespace(CharSequence text)
text - the textpublic static String trimAllWhitespace(String str)
str - the strpublic static String trimLeadingWhitespace(String str)
str - the strpublic static String trimTrailingWhitespace(String str)
str - the strpublic static String trimLeadingCharacter(String str, char leadingCharacter)
str - the strleadingCharacter - the leading characterpublic static String trimTrailingCharacter(String str, char trailingCharacter)
str - the strtrailingCharacter - the trailing characterpublic static boolean matchesCharacter(String str, char singleCharacter)
str - the strsingleCharacter - the single characterpublic static boolean startsWithIgnoreCase(String str, String prefix)
str - the strprefix - the prefixpublic static boolean endsWithIgnoreCase(String str, String suffix)
str - the strsuffix - the suffixpublic static boolean substringMatch(CharSequence str, int index, CharSequence substring)
str - the strindex - the indexsubstring - the substringpublic static int countOccurrencesOf(String str, String sub)
str - the strsub - the subpublic static String replace(String inString, String oldPattern, String newPattern)
inString - the in stringoldPattern - the old patternnewPattern - the new patternpublic static String delete(String inString, String pattern)
inString - the in stringpattern - the patternpublic static String deleteAny(String inString, String charsToDelete)
inString - the in stringcharsToDelete - the chars to deletepublic static String quote(String str)
str - the strpublic static Object quoteIfString(Object obj)
obj - the objpublic static String unqualify(String qualifiedName)
qualifiedName - the qualified namepublic static String unqualify(String qualifiedName, char separator)
qualifiedName - the qualified nameseparator - the separatorpublic static String capitalize(String str)
str - the strpublic static String uncapitalize(String str)
str - the strprivate static String changeFirstCharacterCase(String str, boolean capitalize)
public static String getFilename(String path)
path - the pathpublic static String getFilenameExtension(String path)
path - the pathCopyright © 2024. All rights reserved.