phelps.lang
Class Strings
public
class
Strings
extends Object
Extensions to java.lang.String.
- possible object sharing: valueOf, valueOf, Strings
- sorting in dictionary order: DICTIONARY_ORDER, DICTIONARY_CASE_INSENSITIVE_ORDER,
Strings
- Strings, trimWhitespace, trimPunct,
- translate/convert/format: Strings, toASCII7, fromPigLatin,
raw getBytes without character set encoding
- algorithms: Strings
Version: $Revision: 1.4 $ $Date: 2003/06/01 07:58:08 $
Method Summary |
static String | casify(String words, String wordbreak, Map<String,String> exceptions)
Transform strings of ALL UPPERCASE into Mixed-Case version,
with each character after a space kept uppercase,
and given table of exceptions.
|
static int | compareDictionary(String s1, String s2, boolean caseinsensitive)
Compares one String to another in "dictionary order", which means
alphabetics compared lexicographically and embedded numbers numerically. |
static String | fromPigLatin(String str) Translate word from Pig Latin. |
static byte[] | getBytes(String s)
Returns byte array of low byte of each character.
|
static int | minEditDistance(String a, String b)
Returns the minimum number of operations to transform one string into the other.
|
static String | removeWhitespace(String txt) Returns string which has all whitespace characters from txt. |
static String | toASCII7(String txt)
Return 7-bit ASCII transcription of Unicode by removing accents (e.g., "Á"=>"A"),
|
static String | trim(String txt, String chars) Trim letters in passed chars from ends of word. |
static String | trim(String txt, String chars, int start, int end) |
static String | trimPunct(String txt) Trim off punctuation (actually, non-letter or -digit) from ends of txt. |
static String | trimWhitespace(String txt) |
static String | trimWhitespace(String txt, int start, int end) Can save a String create over String.trim(). |
static String | valueOf(String str)
Canonicalizes java.lang.String instances of a single character <= u00ff and those created recently. |
static String | valueOf(StringBuffer sb)
Return possibly shared String.
|
static String | valueOf(char ch) |
public static final Comparator<String> DICTIONARY_CASE_INSENSITIVE_ORDER
public static final Comparator<String> DICTIONARY_ORDER
public static String PUNCT
public static String casify(String words, String wordbreak, Map<String,String> exceptions)
Transform strings of ALL UPPERCASE into Mixed-Case version,
with each character after a space kept uppercase,
and given table of
exceptions.
If a word has any lowercase initially, no case is changed in that word.
For example, UNIX manual pages typically have all uppercase section titles,
so this method transforms them into something more easily readable, passing
as exceptions a list of odd computer-industry capitalization.
See Also: ManualPage
public static int compareDictionary(String s1, String s2, boolean caseinsensitive)
Compares one String to another in "dictionary order", which means
alphabetics compared lexicographically and embedded numbers numerically.
public static String fromPigLatin(String str)
Translate word from Pig Latin.
public static byte[] getBytes(String s)
Returns byte array of low byte of each character.
Like java.lang.String#getBytes() but no encoding,
and java.lang.String#getBytes(int, int, byte[], int) but not deprecated.
public static int minEditDistance(String a, String b)
Returns the minimum number of operations to transform one string into the other.
An operation is insert character, delete character, substitute character.
Useful to determine if two strings "almost match", as in Strings.minEditDistance("Krzysztof", "Krystof") <= 3
.
public static String removeWhitespace(String txt)
Returns string which has all whitespace characters from txt.
public static String toASCII7(String txt)
Return 7-bit ASCII transcription of Unicode by removing accents (e.g., "Á"=>"A"),
and making other character substitutions (e.g., "©" => "(C)").
If no changes to remove, return txt.
public static String trim(String txt, String chars)
Trim letters in passed chars from ends of word.
public static String trim(String txt, String chars, int start, int end)
public static String trimPunct(String txt)
Trim off punctuation (actually, non-letter or -digit) from ends of txt.
public static String trimWhitespace(String txt)
public static String trimWhitespace(String txt, int start, int end)
Can save a String create over String.trim().
public static String valueOf(String str)
Canonicalizes java.lang.String instances of a single character <= u00ff and those created recently.
public static String valueOf(StringBuffer sb)
Return possibly shared String.
If String is 1-character long and char<256, then guaranteed shared.
public static String valueOf(char ch)