Multivalent API

phelps.lang
Class Strings

java.lang.Object
  extended by phelps.lang.Strings

public class Strings
extends java.lang.Object

Extensions to String.

Version:
$Revision: 1.4 $ $Date: 2003/06/01 07:58:08 $

Field Summary
static java.util.Comparator<java.lang.String> DICTIONARY_CASE_INSENSITIVE_ORDER
          Comparator, as for use by Arrays, that sorts in dictionary order, with case insensitively.
static java.util.Comparator<java.lang.String> DICTIONARY_ORDER
          Comparator, as for use by Arrays, that sorts in dictionary order.
static java.lang.String PUNCT
           
static java.lang.String[] STRING0
           
 
Method Summary
static java.lang.String casify(java.lang.String words, java.lang.String wordbreak, java.util.Map<java.lang.String,java.lang.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(java.lang.String s1, java.lang.String s2, boolean caseinsensitive)
          Compares one String to another in "dictionary order", which means alphabetics compared lexicographically and embedded numbers numerically.
static java.lang.String escape(java.lang.String str, java.lang.String esc, char with)
           
static java.lang.String fromPigLatin(java.lang.String str)
          Translate word from Pig Latin.
static byte[] getBytes8(java.lang.String s)
          Returns byte array of low byte of each character.
static java.lang.String join(java.lang.String[] strs, java.lang.String join)
           
static int minEditDistance(java.lang.String a, java.lang.String b)
          Returns the minimum number of operations to transform one string into the other.
static java.lang.String removeWhitespace(java.lang.String txt)
          Returns string which has all whitespace characters from txt.
static java.lang.String toASCII7(java.lang.String txt)
          Returns Unicode translation to 7-bit Latin-1 ASCII by keeping 7-bit characters (0 <= char <= 127) as is, removing accents (e.g., "Á" => "A"), splitting ligatures (e.g, "fi" single glyph => "f" and "i" as separate characters), replacing curly quotes with straight quotes, and making other character substitutions (e.g., "©" => "(C)").
static java.lang.String trim(java.lang.String txt, java.lang.String chars)
          Trim letters in passed chars from ends of word.
static java.lang.String trim(java.lang.String txt, java.lang.String chars, int start, int end)
           
static java.lang.String trimPunct(java.lang.String txt)
          Trim off punctuation (actually, non-letter or -digit) from ends of txt.
static java.lang.String trimWhitespace(java.lang.String txt)
           
static java.lang.String trimWhitespace(java.lang.String txt, int start, int end)
          Can save a String create over String.trim().
static java.lang.String valueOf(byte[] b)
           
static java.lang.String valueOf(char ch)
           
static java.lang.String valueOf(java.lang.String str)
          Canonicalizes String instances of a single character <= u00ff and those created recently.
static java.lang.String valueOf(java.lang.StringBuffer sb)
          Return possibly shared String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING0

public static java.lang.String[] STRING0

PUNCT

public static java.lang.String PUNCT

DICTIONARY_ORDER

public static final java.util.Comparator<java.lang.String> DICTIONARY_ORDER
Comparator, as for use by Arrays, that sorts in dictionary order.


DICTIONARY_CASE_INSENSITIVE_ORDER

public static final java.util.Comparator<java.lang.String> DICTIONARY_CASE_INSENSITIVE_ORDER
Comparator, as for use by Arrays, that sorts in dictionary order, with case insensitively.

Method Detail

getBytes8

public static byte[] getBytes8(java.lang.String s)
Returns byte array of low byte of each character. Like String.getBytes() but no encoding, and String.getBytes(int, int, byte[], int) but not deprecated.


compareDictionary

public static int compareDictionary(java.lang.String s1,
                                    java.lang.String s2,
                                    boolean caseinsensitive)
Compares one String to another in "dictionary order", which means alphabetics compared lexicographically and embedded numbers numerically.


valueOf

public static java.lang.String valueOf(java.lang.String str)
Canonicalizes String instances of a single character <= u00ff and those created recently.


valueOf

public static java.lang.String valueOf(java.lang.StringBuffer sb)
Return possibly shared String. If String is 1-character long and char<256, then guaranteed shared.


valueOf

public static java.lang.String valueOf(char ch)

valueOf

public static java.lang.String valueOf(byte[] b)

join

public static java.lang.String join(java.lang.String[] strs,
                                    java.lang.String join)

trim

public static java.lang.String trim(java.lang.String txt,
                                    java.lang.String chars)
Trim letters in passed chars from ends of word.


trim

public static java.lang.String trim(java.lang.String txt,
                                    java.lang.String chars,
                                    int start,
                                    int end)

trimWhitespace

public static java.lang.String trimWhitespace(java.lang.String txt)

trimWhitespace

public static java.lang.String trimWhitespace(java.lang.String txt,
                                              int start,
                                              int end)
Can save a String create over String.trim().


trimPunct

public static java.lang.String trimPunct(java.lang.String txt)
Trim off punctuation (actually, non-letter or -digit) from ends of txt.


removeWhitespace

public static java.lang.String removeWhitespace(java.lang.String txt)
Returns string which has all whitespace characters from txt.


escape

public static java.lang.String escape(java.lang.String str,
                                      java.lang.String esc,
                                      char with)

casify

public static java.lang.String casify(java.lang.String words,
                                      java.lang.String wordbreak,
                                      java.util.Map<java.lang.String,java.lang.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

toASCII7

public static java.lang.String toASCII7(java.lang.String txt)
Returns Unicode translation to 7-bit Latin-1 ASCII by


fromPigLatin

public static java.lang.String fromPigLatin(java.lang.String str)
Translate word from Pig Latin.


minEditDistance

public static int minEditDistance(java.lang.String a,
                                  java.lang.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.


Multivalent API