|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.util.WTStringUtilities
WTStringUtilities Additional String functions
Field Summary | |
private static String |
versionID
|
Constructor Summary | |
WTStringUtilities()
|
Method Summary | |
static String |
ascii2native(String in,
String encoding)
Not thoroughly tested. |
static String |
capitalize(String string)
Capitalize a string. |
static String |
doubleQuote(String aString)
|
static void |
doubleQuote(StringBuffer buf,
String aString)
|
static String |
escapeNewLines(String original)
Insert escapes prior to each existence of a new line character. |
static String |
getterName(String root)
Convert a field name to its getter method name. |
static String |
getterName(String root,
String type)
Convert a field name to its getter method name. |
static String |
insert(String original,
String insert,
char beforeChar)
Insert a string into another string, before a specified character. |
static String |
insert(String original,
String insert,
int beforeIndex)
Insert a string into another string, before a specified character. |
static String |
insertEscapeChars(String theString)
Insert escapes prior to each existence of a character that needs to be escaped. |
static String |
insertEscapeChars(String aString,
String characters)
Insert escapes prior to each existence of the each of the characters in a string. |
static boolean |
isEmpty(String target)
Check a string to see if it contains anything. |
static String |
loadConvert(String theString)
|
static String |
native2ascii(String in,
String encoding)
Not thoroughly tested. |
static String |
padRight(String aString,
int length,
boolean trim)
Pad the string to be the specified length, adding spaces to the end. |
static String |
replace(String original,
String insert,
String remove)
Replace a substring, within a string, with another string. |
static String |
replaceAll(String original,
String insert,
String remove)
Replace all occurances of a substring, within a string, with another string. |
static String |
singleQuote(String aString)
|
static void |
singleQuote(StringBuffer buf,
String aString)
|
static String |
tail(String aString,
char aSeparator)
|
static String |
tail(String aString,
char aSeparator,
int level)
Pull off the trailing token following the supplied separator to the level supplied. |
static String |
tail(String aString,
String separators)
Pull off the trailing token following the last separator, of the supplied separator. |
static String[] |
toArray(String delimitedlist,
String separators)
Convert a delimited String into a String array. |
static String |
toConstant(String string)
Convert a name to its constant name. |
static String |
toDisplayName(String string)
Convert a "programming" name to a displayable name. |
static String |
trimTail(String aString,
char aSeparator)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String versionID
Constructor Detail |
public WTStringUtilities()
Method Detail |
public static String ascii2native(String in, String encoding)
public static String capitalize(String string)
Example Usage: WTStringUtilities.capitalize( "attribute" ) // returns "Attribute"
string
- - a String
public static String doubleQuote(String aString)
public static void doubleQuote(StringBuffer buf, String aString)
public static String escapeNewLines(String original)
Example Usage: WTStringUtilities.escapeNewLines( "a"+ '\n' + "c" ) // returns "a\nc"
original
- - the String to which escapes will be inserted
public static String getterName(String root)
Example Usage: WTStringUtilities.getterName( "attribute" ) // returns "getAttribute" WTStringUtilities.getterName( "theRole" ) // returns "getRole"
public static String getterName(String root, String type)
Example Usage: WTStringUtilities.getterName( "valid", "boolean" ) // returns "isValid" WTStringUtilities.getterName( "attribute", "String" ) // returns "getAttribute" WTStringUtilities.getterName( "theRole", "Object" ) // returns "getRole"
type
- - a String, which is a Java type
public static String insert(String original, String insert, char beforeChar)
Example Usage: WTStringUtilities.insert( "abef", "cd", 'e' ) // returns "abcdef" WTStringUtilities.insert( "abef", "cd", 'x' ) // returns "abefcd" WTStringUtilities.insert( "abef", "cd", 'a' ) // returns "cdabef" WTStringUtilities.insert( "af", "bcde", 'f' ) // returns "abcdef"
original
- the string into which another string will be insertedinsert
- the string to insert into the original stringbeforeChar
- the char before which the "insert" be placed
public static String insert(String original, String insert, int beforeIndex)
Example Usage: WTStringUtilities.insert( "abef", "cd", 3 ) // returns "abcdef" WTStringUtilities.insert( "abef", "cd", 5 ) // returns "abefcd" WTStringUtilities.insert( "abef", "cd", -1 ) // returns "abefcd" WTStringUtilities.insert( "abef", "cd", 1 ) // returns "cdabef" WTStringUtilities.insert( "af", "bcde", 2' ) // returns "abcdef"
original
- the string into which another string will be insertedinsert
- the string to insert into the original stringbeforeIndex
- the index before which the "insert" be placed
public static String insertEscapeChars(String theString)
Example Usage: WTStringUtilities.insertEscapeChars( "a\"b\"c\n" ) // returns "a\"b\"c\n"
theString
- - the String to which escapes will be inserted
public static String insertEscapeChars(String aString, String characters)
Example Usage: WTStringUtilities.insertEscapeChars( "a\"b\"c", "\"" ) // returns "a\"b\"c"
aString
- - the String to which escapes will be insertedcharacters
- - the characters to escape
public static String loadConvert(String theString)
public static String native2ascii(String in, String encoding)
public static String padRight(String aString, int length, boolean trim)
Example Usage: WTStringUtilities.padRight( "abc", 5, true ) // returns "abc " WTStringUtilities.padRight( "abc", 2, true ) // returns "ab" WTStringUtilities.padRight( "abc", 2, false ) // returns "abc"
aString
- - the String to searchlength
- - the desired length of the returned stringtrim
- - if true, returned string not exceed desired length
public static String replace(String original, String insert, String remove)
Example Usage: WTStringUtilities.replace( "abef", "cd", "e" ) // returns "abcdf" WTStringUtilities.replace( "abef", "cd", "x" ) // returns "abef" WTStringUtilities.replace( "abef", "c", "ab" ) // returns "cef" WTStringUtilities.replace( "af", "bcde", "f" ) // returns "abcde" WTStringUtilities.replace( "abcc", "cd", "cc" ) // returns "abcd"
original
- the string into which another substring will be replacedinsert
- the string to insert into the original stringremove
- the substring that will be replaced by the insert string
public static String replaceAll(String original, String insert, String remove)
Example Usage: WTStringUtilities.replace( "abef", "cd", "e" ) // returns "abcdf" WTStringUtilities.replace( "abef", "cd", "x" ) // returns "abef" WTStringUtilities.replace( "abef", "cba", "ab" )// returns "cbaef" WTStringUtilities.replace( "afbaf","z", "af" ) // returns "zbz" WTStringUtilities.replace( "abcc", "d", "c" ) // returns "abdd"
original
- the string into which another substring will be replacedinsert
- the string to insert into the original stringremove
- the substring that will be replaced by the insert string
public static String singleQuote(String aString)
public static void singleQuote(StringBuffer buf, String aString)
public static String tail(String aString, char aSeparator)
public static String tail(String aString, char aSeparator, int level)
Example Usage: WTStringUtilities.tail( "wt.doc.WTDocument", '.', 2 ) // returns "doc.WTDocument"
aString
- - the String to convertaSeparator
- - the separator to considerlevel
- - the level to consider
public static String tail(String aString, String separators)
Example Usage: WTStringUtilities.tail( "x.y.z", "." ) // returns "z" WTStringUtilities.tail( "x.y>z", "." ) // returns "y>z" WTStringUtilities.tail( "x.y>z", ".>" ) // returns "z"
aString
- - the String to searchseparators
- - the separators to consider
public static String[] toArray(String delimitedlist, String separators)
Example Usage: WTStringUtilities.toArray( "x,y,z", "," ) // returns ["x","y","z"] WTStringUtilities.toArray( "x,y z", "," ) // returns ["x","y z"] WTStringUtilities.toArray( "x,y z", ", " ) // returns ["x","y","z"]
delimitedlist
- - the String to convertseparators
- - the separators to consider
public static String toConstant(String string)
Example Usage: WTStringUtilities.toConstant( "valid" ) // returns "VALID" WTStringUtilities.toConstant( "anAttribute" ) // returns "AN_ATTRIBUTE" WTStringUtilities.toConstant( "theRole" ) // returns "ROLE" WTStringUtilities.toConstant( "AProperty" ) // returns "APROPERTY"
string
- - a String name
public static String toDisplayName(String string)
Example Usage: WTStringUtilities.toDisplayName( "valid" ) // returns "Valid" WTStringUtilities.toDisplayName( "anAttribute" ) // returns "An Attribute" WTStringUtilities.toDisplayName( "theRole" ) // returns "Role" WTStringUtilities.toDisplayName( "myOwnProperty" ) // returns "My Own Property"
string
- - a String name
public static boolean isEmpty(String target)
Example Usage: WTStringUtilities.isEmpty( null ) // returns true WTStringUtilities.isEmpty( "" ) // returns true WTStringUtilities.isEmpty( " " ) // returns false
target
- the string to check
public static String trimTail(String aString, char aSeparator)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |