public class StringUtil extends Object
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
allValuesAreEmpty(String[] inArray) |
static String |
applySubstitutionMap(CharSequence inString,
Map<String,String> inSubstitutionMap) |
static String |
applySubstitutionMap(CharSequence inString,
Map<String,String> inSubstitutionMap,
String inDelimiter) |
static String |
capitalize(String inString)
Returns the input string with the first character capitalized.
|
static int |
computeLevenshteinDistance(CharSequence inString1,
CharSequence inString2)
Calculates the Levenshtein distance between two Strings.
|
static boolean |
containsLowerCase(String inString)
Returns whether or not the specified string contains a lower-case letter.
|
static boolean |
containsUpperCase(String inString)
Returns whether or not the specified string contains an upper-case letter.
|
static String |
generateLocalizedNumberString(Number inValue) |
static String |
generateLocalizedNumberString(Number inValue,
Locale inLocale) |
static String |
generateRandomEgyptianHieroglyphics(int inLength) |
static String |
generateRandomString(Character.UnicodeScript inScript,
int inLength) |
static String |
generateRandomString(CharSequence inAlphabet,
int inLength)
Returns a random string of the specified length using the specified alphabet of characters.
|
static List<Integer> |
getCharactersForUnicodeScript(Character.UnicodeScript inScript) |
static int |
getCharCount(CharSequence inString,
char inChar)
Returns the number of times the specified character appears in the specified String.
|
static Range<Integer> |
getRangeForUnicodeBlock(Character.UnicodeBlock inBlock) |
static String |
getSystemLineSeparator() |
static boolean |
isNumber(CharSequence inString) |
static boolean |
isQuoted(CharSequence inString)
Returns whether or not the specified String is contained within surrounding quotes.
|
static boolean |
isSet(CharSequence inString)
Returns whether the specified String contains non-whitespace content.
|
static String |
join(Collection pieces,
String inSeperator)
Joins the elements of a Collection together using the specified String.
|
static String |
join(int[] inArray,
String inSeperator)
Joins the elements of a int[] together using the specified String.
|
static String |
join(Object[] inArray,
String inSeperator)
Joins the elements of an Object[] together using the specified String.
|
static String |
join(String[] pieces)
Joins the elements of a String[] together using a space as the separator.
|
static String |
join(String[] pieces,
String inSeperator)
Joins the elements of a String[] together using the specified String.
|
static String |
joinIncludeSingleQuote(Collection pieces,
String inSeperator)
Joins the elements of a Collection together using the specified String.
|
static String[] |
lines(CharSequence inString) |
static String |
polyChar(char inChar,
int inNum)
Returns a String composed of inChar repeated inNum times.
|
static String |
polyString(String inString,
int inNum)
Returns a String composed of inString repeated inNum times.
|
static String |
quote(Object inObject)
Returns the specified String surrounded by quotes and escaping any internal quotes.
|
static String |
removeWhitespace(CharSequence inString) |
static String |
replaceAll(CharSequence inString,
String inTarget,
String inReplacement)
Returns a String where all instances of inTarget in inString are replaced by
inReplacement.
|
static String |
replaceAllRegexp(CharSequence inString,
Pattern inPattern,
String inReplacement)
Returns a String where all portions of inString matching the inPattern
are replaced by inReplacement.
|
static String |
replaceAllRegexp(CharSequence inString,
String inRegexpTarget,
String inReplacement)
Returns a String where all portions of inString matching the inTargetRegexp
are replaced by inReplacement.
|
static String |
replaceWhitespace(CharSequence inString,
CharSequence inWhitespaceReplacementString) |
static String |
scramble(CharSequence inString) |
static String |
singleQuote(Object inObject)
Returns the specified String surrounded by single quotes and escaping any internal single quotes.
|
static String |
stripHTMLTags(String inString) |
static String |
toSubscript(int inNumericValue)
Returns a unicode string for the specified number as a subscript.
|
static String |
toSubscript(String inString)
Returns a unicode string for the specified number as a subscript.
|
static String |
toSuperscript(int inNumericValue)
Returns a unicode string for the specified number as a superscript.
|
static String |
toSuperscript(String inString)
Returns a unicode string for the specified number as a superscript.
|
static String |
trimTrailingWhitespace(CharSequence inString) |
static String |
truncate(String inString,
int inMaxLength)
If the specified string is longer than the specified maximum length, a truncated
string is returned.
|
static String |
truncateWithEllipsis(String inString,
int inMaxLength)
Truncates the string and adds an ellipsis (…) if it exceeds the specified length.
|
static String |
unquote(CharSequence inString)
Returns the specified String while removing surrounding quotes if present.
|
static String |
wrap(String inString,
int inMaxLineLength) |
public StringUtil()
public static String getSystemLineSeparator()
public static boolean isSet(CharSequence inString)
public static String join(String[] pieces)
public static String join(String[] pieces, String inSeperator)
public static String join(Object[] inArray, String inSeperator)
public static String join(int[] inArray, String inSeperator)
public static String join(Collection pieces, String inSeperator)
public static String joinIncludeSingleQuote(Collection pieces, String inSeperator)
public static String polyString(String inString, int inNum)
public static String polyChar(char inChar, int inNum)
public static String replaceAll(CharSequence inString, String inTarget, String inReplacement)
public static String replaceAllRegexp(CharSequence inString, String inRegexpTarget, String inReplacement)
public static String replaceAllRegexp(CharSequence inString, Pattern inPattern, String inReplacement)
public static String trimTrailingWhitespace(CharSequence inString)
public static String removeWhitespace(CharSequence inString)
public static String replaceWhitespace(CharSequence inString, CharSequence inWhitespaceReplacementString)
public static String quote(Object inObject)
public static String singleQuote(Object inObject)
public static boolean isQuoted(CharSequence inString)
public static String unquote(CharSequence inString)
public static int getCharCount(CharSequence inString, char inChar)
public static String scramble(CharSequence inString)
public static String applySubstitutionMap(CharSequence inString, Map<String,String> inSubstitutionMap)
public static String applySubstitutionMap(CharSequence inString, Map<String,String> inSubstitutionMap, String inDelimiter)
public static String stripHTMLTags(String inString)
public static String truncate(String inString, int inMaxLength)
inString
- the original string valueinMaxLength
- the maximum lenght allowed for the stringpublic static String truncateWithEllipsis(String inString, int inMaxLength)
inString
- the string to be truncatedinMaxLength
- the length beyond which the specified string should be truncatedpublic static boolean containsLowerCase(String inString)
inString
- the string value to be checkedpublic static boolean containsUpperCase(String inString)
inString
- the string value to be checkedpublic static String capitalize(String inString)
inString
- the string value to be capitalizedpublic static String toSuperscript(int inNumericValue)
inNumericValue
- the numeric value to be superscriptedpublic static String toSuperscript(String inString)
inString
- the numeric value to be superscriptedpublic static String toSubscript(int inNumericValue)
inNumericValue
- the numeric value to be subscriptedpublic static String toSubscript(String inString)
inString
- the numeric value to be subscriptedpublic static String[] lines(CharSequence inString)
public static String generateRandomString(CharSequence inAlphabet, int inLength)
inAlphabet
- a string of the allowed charactersinLength
- the length of the random string to be composedpublic static String generateRandomString(Character.UnicodeScript inScript, int inLength)
public static String generateRandomEgyptianHieroglyphics(int inLength)
public static Range<Integer> getRangeForUnicodeBlock(Character.UnicodeBlock inBlock)
public static List<Integer> getCharactersForUnicodeScript(Character.UnicodeScript inScript)
public static String generateLocalizedNumberString(Number inValue)
public static String generateLocalizedNumberString(Number inValue, Locale inLocale)
public static boolean isNumber(CharSequence inString)
public static boolean allValuesAreEmpty(String[] inArray)
public static int computeLevenshteinDistance(CharSequence inString1, CharSequence inString2)
inString1
- the first string for comparisoninString2
- the second string for comparison