|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.freeshell.zs.common.StringManipulator
public class StringManipulator
Perform string manipulation.
| Nested Class Summary | |
|---|---|
static class |
StringManipulator.Token
Represent a string token. |
| Constructor Summary | |
|---|---|
StringManipulator()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
abbreviate(java.lang.String s)
Abbreviate a specified string, by keeping only the first letter of each word. |
static java.lang.String |
centerJustify(java.lang.Object o,
int width)
Center-justify the string representation of a given object, padding with leading and trailing spaces so that its length is at least the specified width. |
static java.lang.String |
deleteExtraWhitespace(java.lang.String s)
Delete extra whitespace in a specified string, by replacing contiguous whitespace characters with a single space. |
static java.lang.String |
deletePunctuation(java.lang.String s)
Delete punctuation in a specified string, by deleting all punctuation characters. |
static java.lang.String |
deleteWhitespace(java.lang.String s)
Delete whitespace in a specified string, by deleting all whitespace characters. |
static java.lang.String |
formattedDouble(double n)
Return a formatted string representation of a given double number (format is locale-sensitive). |
static java.lang.String |
formattedLong(long n)
Return a formatted string representation of a given long number (format is locale-sensitive). |
static java.lang.String |
leftJustify(java.lang.Object o,
int width)
Left-justify the string representation of a given object, padding with trailing spaces so that its length is at least the specified width. |
static java.lang.String |
leftTrim(java.lang.String s)
Trim away whitespace on the left. |
static java.lang.String[] |
parseKeyValueString(java.lang.String s)
Parse the specified "key:value" string. |
static java.lang.String |
repeat(java.lang.Object o,
int n)
Repeat the string representation of a given object, a specified number of times. |
static java.lang.String |
reverse(java.lang.String s)
Reverse the string. |
static java.lang.String |
rightJustify(java.lang.Object o,
int width)
Right-justify the string representation of a given object, padding with leading spaces so that its length is at least the specified width. |
static java.lang.String |
rightTrim(java.lang.String s)
Trim away whitespace on the right. |
static java.lang.String |
spaceOutWords(java.lang.String s)
Space out words in a specified string, by inserting a single space between concatenated words. |
static java.lang.String |
substring(java.lang.String in,
java.lang.String format,
char rangeChar,
char delimChar)
Extract a substring from a given string, according to the specified format. |
static java.lang.String |
swapCase(java.lang.String s)
Swap the case of a specified string, by converting lower case characters to upper case and vice versa. |
static StringManipulator.Token[] |
tokenize(java.lang.String in,
java.lang.String regexDelim,
boolean includeDelimiters)
Tokenize the given string, using the specified regex delimiter pattern. |
static java.lang.String |
toTitleCase(java.lang.String s)
Convert a specified string to title case, by capitalizing only the first letter of each word. |
static java.lang.String |
trimLeadingStrings(java.lang.String s,
java.lang.String[] trimStrings)
Return a modified version of the input string with the specified strings trimmed off from its head, if found. |
static java.lang.String |
trimStrings(java.lang.String s,
java.lang.String[] trimStrings)
Return a modified version of the input string with the specified strings trimmed off from its head and tail, if found. |
static java.lang.String |
trimTrailingStrings(java.lang.String s,
java.lang.String[] trimStrings)
Return a modified version of the input string with the specified strings trimmed off from its tail, if found. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringManipulator()
| Method Detail |
|---|
public static StringManipulator.Token[] tokenize(java.lang.String in,
java.lang.String regexDelim,
boolean includeDelimiters)
in - String to be tokenizedregexDelim - Regex delimiter patternincludeDelim - If true, then delimiter tokens are returned too;
otherwise, only non-delimiter tokens are returned
public static java.lang.String substring(java.lang.String in,
java.lang.String format,
char rangeChar,
char delimChar)
in - String from which the substring is to be extractedformat - Format string describing the sequence of characters in the substringrangeChar - Range character to be useddelimChar - Delimiter character to be used
public static java.lang.String formattedLong(long n)
n - Long number to be formatted
public static java.lang.String formattedDouble(double n)
n - Double number to be formatted
public static java.lang.String centerJustify(java.lang.Object o,
int width)
o - Object to be center-justifiedwidth - Width of the resulting center-justified string
public static java.lang.String leftJustify(java.lang.Object o,
int width)
o - Object for to be left-justifiedwidth - Width of the resulting left-justified string
public static java.lang.String rightJustify(java.lang.Object o,
int width)
o - Object to be right-justifiedwidth - Width of the resulting right-justified string
public static java.lang.String repeat(java.lang.Object o,
int n)
o - Object to be repeatedn - Number of times to repeat
public static java.lang.String toTitleCase(java.lang.String s)
s - Input string
public static java.lang.String abbreviate(java.lang.String s)
s - Input string
public static java.lang.String reverse(java.lang.String s)
s - Input string
public static java.lang.String leftTrim(java.lang.String s)
s - Input string
public static java.lang.String rightTrim(java.lang.String s)
s - Input string
public static java.lang.String deleteExtraWhitespace(java.lang.String s)
s - Input string
public static java.lang.String deleteWhitespace(java.lang.String s)
s - Input string
public static java.lang.String deletePunctuation(java.lang.String s)
s - Input string
public static java.lang.String spaceOutWords(java.lang.String s)
s - Input string
public static java.lang.String swapCase(java.lang.String s)
s - Input string
public static java.lang.String trimTrailingStrings(java.lang.String s,
java.lang.String[] trimStrings)
s - Input stringtrimStrings - Strings to be trimmed off from the end of the input string;
empty strings are ignored
public static java.lang.String trimLeadingStrings(java.lang.String s,
java.lang.String[] trimStrings)
s - Input stringtrimStrings - Strings to be trimmed off from the head of the input string;
empty strings are ignored
public static java.lang.String trimStrings(java.lang.String s,
java.lang.String[] trimStrings)
s - Input stringtrimStrings - Strings to be trimmed off from the head and tail of the input
string; empty strings are ignored
public static java.lang.String[] parseKeyValueString(java.lang.String s)
s - string to be parsed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||