|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jutil.TString
public final class TString
This is the TString utility code class.
This code conforms to the code guides for org.jutil Utility Code
org.jutiltest.TStringTest| Field Summary | |
|---|---|
static char[] |
ILLEGAL_NUMBER_CHARS
|
| Constructor Summary | |
|---|---|
TString()
Ensure that no one can create instances of this Class. |
|
| Method Summary | |
|---|---|
static java.lang.String |
capitalize(java.lang.String input)
Capitalize the first letter of a word. |
static java.lang.String |
getKey(java.lang.String str)
getValue: get the key portion from a key/value java.lang.String pair e.g "myKey=myValue" using the default delim char '=' as the divider returns key portion of the java.lang.String |
static java.lang.String |
getKey(java.lang.String str,
char delim)
get the key portion from a key/value String pair e.g "myKey=myValue" using the delim char as the divider returns key portion of the String |
static java.lang.String |
getValue(java.lang.String str)
getValue: get the value portion from a key/value java.lang.String pair e.g "myKey=myValue" using the default delim char '=' as the divider returns value portion of the java.lang.String |
static java.lang.String |
getValue(java.lang.String str,
char delim)
getValue: get the value portion from a key/value java.lang.String pair e.g "myKey=myValue" using the delim char as the divider returns value portion of the java.lang.String |
static int |
hash(java.lang.String str)
returns an int hashed value of String str |
static java.lang.String |
hexDecode(java.lang.String hex)
Decode a hexadecimal String into its orgibnal form |
static java.lang.String |
hexEncode(java.lang.String data)
Code a String into a hexadecimal repsentation. |
static boolean |
isEmpty(java.lang.String str)
returns false is String is null or length < 1 |
static java.lang.String |
padLeft(java.lang.String str,
int len,
char pad)
Pad the left hand side of a String str with the pad char to the len length |
static java.lang.String |
padRight(java.lang.String str,
int len,
char pad)
Pad the right hand side of a String str with the pad char to the len length |
static java.lang.String |
proper(java.lang.String name)
converts the first letter of a java.lang.String to uppercase |
static java.lang.String |
removeChars(java.lang.String input,
char[] remove)
|
static java.lang.String |
removeExcessSpace(java.lang.String input)
|
static java.lang.String |
removeExcessWhiteSpace(java.lang.String input)
|
static java.lang.String |
removeNewLine(java.lang.String input)
|
static java.lang.String |
removeTabs(java.lang.String input)
|
static java.lang.String |
replace(java.lang.String input,
char flag,
char replacement)
replace all char flag in java.lang.String input with char repacement |
static java.lang.String |
replace(java.lang.String input,
char flag,
java.lang.String replacement)
replace all char flag in java.lang.String input with java.lang.String repacement |
static java.lang.String |
replace(java.lang.String input,
java.lang.String flag,
char replacement)
replace all java.lang.String flag in java.lang.String input with char repacement |
static java.lang.String |
replace(java.lang.String input,
java.lang.String flag,
java.lang.String replacement)
replace all java.lang.String flag in java.lang.String input with java.lang.String repacement |
static java.lang.String |
snipLeft(java.lang.String str,
int size)
Pare the String str to the length size, by removing charcters on the left hand side |
static java.lang.String |
snipRight(java.lang.String str,
int size)
Pare the String str to the length size, by removing charcters on the right hand side |
static java.lang.String |
stripLeft(java.lang.String str,
java.lang.String strip)
Remove the strip String from the left hand side of the str String str |
static java.lang.String |
stripLeft(java.lang.String input,
java.lang.String strip,
int count)
Remove the strip String from the left hand side of the String str recurse count times
Usage:org.jutil.TString.stripLeft("aabcd", "a", 1); |
static java.lang.String |
stripRight(java.lang.String str,
java.lang.String strip)
Remove the strip String from the right hand side of the String str |
static java.lang.String |
stripRight(java.lang.String input,
java.lang.String strip,
int count)
Remove the strip String from the right hand side of the String str recurse count times |
static java.lang.String[] |
toArray(java.lang.String str)
converts a java.lang.String to a java.lang.String[] splitting on the default ',' char |
static java.lang.String[] |
toArray(java.lang.String input,
char delim)
toArray converts a java.lang.String to a java.lang.String[] splitting on the delim char |
static boolean |
tob(java.lang.String str)
Convert String to boolean value |
static boolean |
tob(java.lang.String str,
boolean defaultValue)
Convert String to boolean value |
static java.lang.Boolean |
toBoolean(java.lang.String str)
Convert String to Boolean value |
static java.lang.Boolean |
toBoolean(java.lang.String str,
boolean defaultValue)
Convert String to Boolean value |
static double |
tod(java.lang.String str)
Convert String to double value: |
static double |
tod(java.lang.String str,
double defaultValue)
Convert String to double value |
static java.lang.Double |
toDouble(java.lang.String str)
Convert String to Double value |
static java.lang.Double |
toDouble(java.lang.String str,
double defaultValue)
Convert String to Double |
static float |
tof(java.lang.String str)
Convert String to float value: |
static float |
tof(java.lang.String str,
float defaultValue)
Convert String to float value |
static java.lang.Float |
toFloat(java.lang.String str)
Convert String to Float value |
static java.lang.Float |
toFloat(java.lang.String str,
float defaultValue)
Convert String to Float |
static int |
toi(java.lang.String str)
Convert String to int value |
static int |
toi(java.lang.String str,
int defaultValue)
Convert String to int value |
static java.lang.Integer |
toInteger(java.lang.String str)
Convert String to Integer value |
static java.lang.Integer |
toInteger(java.lang.String str,
int defaultValue)
Convert String to Integer |
static long |
tol(java.lang.String str)
Convert String to long value: |
static long |
tol(java.lang.String str,
long defaultValue)
Convert String to long value |
static java.lang.Long |
toLong(java.lang.String str)
Convert String to Long value |
static java.lang.Long |
toLong(java.lang.String str,
long defaultValue)
Convert String to Long |
static java.lang.Object[] |
toObjectArray(java.lang.String str)
|
static java.lang.String[] |
wrap(java.lang.String source,
int wrapAt)
String[] desc = TString.wrap("12345678910123456789", 4); lineSep == System.getProperty("line.separator") |
static java.lang.String[] |
wrap(java.lang.String source,
int wrapAt,
java.lang.String lineSep)
String[] desc = TString.wrap("12345678910123456789", 4, "\n"); lineSep can be null |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char[] ILLEGAL_NUMBER_CHARS
| Constructor Detail |
|---|
public TString()
| Method Detail |
|---|
public static java.lang.String capitalize(java.lang.String input)
org.jutil.TString.capitalize(String input);
Stringbuffer result = new StringBuffer();
StringTokenizer st = new StringTokenizer( "one two three" );
while ( st.hasMoreTokens() ) {
result.append( org.jutil.TString.capitalize( st.nextToken() ) );
}
System.out.println( "capitalize result==" + result.toString() );
input - java.lang.String
java.lang.String
public static final java.lang.String replace(java.lang.String input,
java.lang.String flag,
java.lang.String replacement)
java.lang.String flag in java.lang.String input java.lang.String repacement org.jutil.TString.replace(String input, String flag, String replacement)
input - source java.lang.Stringflag - java.lang.String to be replacedreplacement - java.lang.String to replace flag java.lang.String
java.lang.String
public static final java.lang.String replace(java.lang.String input,
char flag,
char replacement)
char flag in java.lang.String input char repacement org.jutil.TString.replace(String input, char flag, char replacement)
input - source java.lang.Stringflag - char to be replacedreplacement - char to replace flag char
java.lang.String
public static final java.lang.String removeChars(java.lang.String input,
char[] remove)
public static final java.lang.String removeNewLine(java.lang.String input)
public static final java.lang.String removeExcessSpace(java.lang.String input)
public static final java.lang.String removeExcessWhiteSpace(java.lang.String input)
public static final java.lang.String removeTabs(java.lang.String input)
public static final java.lang.String replace(java.lang.String input,
char flag,
java.lang.String replacement)
char flag in java.lang.String input java.lang.String repacement org.jutil.TString.replace(String input, char flag, String replacement)
input - source java.lang.Stringflag - char to be replacedreplacement - java.lang.String to replace flag char
java.lang.String
public static final java.lang.String replace(java.lang.String input,
java.lang.String flag,
char replacement)
java.lang.String flag in java.lang.String input char repacement org.jutil.TString.replace(String input, String flag, char replacement)
input - source java.lang.Stringflag - java.lang.String to be replacedreplacement - char to replace flag java.lang.String
java.lang.Stringpublic static final java.lang.String proper(java.lang.String name)
java.lang.String to uppercase org.jutil.TString.proper(java.lang.String name)
input - name java.lang.String
java.lang.Stringpublic static final java.lang.Object[] toObjectArray(java.lang.String str)
public static final java.lang.String[] toArray(java.lang.String str)
java.lang.String to a java.lang.String[] splitting char org.jutil.TString.toArray("item1,item2,item3");
str - java.lang.String
java.lang.String[]
public static final java.lang.String[] toArray(java.lang.String input,
char delim)
java.lang.String to a java.lang.String[] char org.jutil.TString.toArray("item1,item2,item3", ',');
str - java.lang.Stringdelim - char
java.lang.String[]public static final java.lang.String getValue(java.lang.String str)
java.lang.String char '=' as the divider java.lang.String org.jutil.TString.getValue(String str);
public static final java.lang.String getValue(java.lang.String str,
char delim)
java.lang.String char as the divider java.lang.String org.jutil.TString.getValue(String str, '=');
public static final java.lang.String getKey(java.lang.String str)
java.lang.String pair char '=' as the divider java.lang.String
org.jutil.TString.getKey(String str);
public static final java.lang.String getKey(java.lang.String str,
char delim)
String pair e.g "myKey=myValue" char as the divider String org.jutil.TString.getKey(String str);
public static final int toi(java.lang.String str)
String to int value
org.jutil.TString.toi(String str);returns -1 if number format error occurs
public static final int toi(java.lang.String str,
int defaultValue)
String to int value
org.jutil.TString.toi(String str);returns defaultValue if number format error occurs
public static final java.lang.Integer toInteger(java.lang.String str)
throws java.lang.NumberFormatException
String to Integer value org.jutil.TString.toInteger( final String str);
throws java.lang.NumberFormatException if number format error occurs
java.lang.NumberFormatException
public static final java.lang.Integer toInteger(java.lang.String str,
int defaultValue)
String to Integer
org.jutil.TString.toInteger( final String str, int default);returns defaultValue if number format error occurs or str is empty
public static final long tol(java.lang.String str)
String to long value: org.jutil.TString.tol( final String str);returns -1l if number format error occurs
public static final long tol(java.lang.String str,
long defaultValue)
String to long value
org.jutil.TString.tol( final String str, long default);returns defaultValue if number format error occurs or str is empty
public static final java.lang.Long toLong(java.lang.String str)
throws java.lang.NumberFormatException
String to Long value
org.jutil.TString.toLong( final String str);throws java.lang.NumberFormatException if number format error occurs
java.lang.NumberFormatException
public static final java.lang.Long toLong(java.lang.String str,
long defaultValue)
String to Long
org.jutil.TString.toLong( final String str, long defaultValue);returns defaultValue if number format error occurs or str is empty
public static final double tod(java.lang.String str)
String to double value: org.jutil.TString.tod( final String str);returns -1d if number format error occurs
public static final double tod(java.lang.String str,
double defaultValue)
String to double value
org.jutil.TString.tod( final String str, double default);returns defaultValue if number format error occurs or str is empty
public static final java.lang.Double toDouble(java.lang.String str)
throws java.lang.NumberFormatException
String to Double value
org.jutil.TString.toDouble( final String str);throws java.lang.NumberFormatException if number format error occurs
java.lang.NumberFormatException
public static final java.lang.Double toDouble(java.lang.String str,
double defaultValue)
String to Double
org.jutil.TString.toDouble( final String str, double defaultValue);returns defaultValue if number format error occurs or str is empty
public static final float tof(java.lang.String str)
String to float value: org.jutil.TString.tof( final String str);returns -1.00f if number format error occurs
public static final float tof(java.lang.String str,
float defaultValue)
String to float value
org.jutil.TString.tof( final String str, float defaultValue);returns defaultValue if number format error occurs or str is empty
public static final java.lang.Float toFloat(java.lang.String str)
throws java.lang.NumberFormatException
String to Float value
org.jutil.TString.toFloat( final String str);throws java.lang.NumberFormatException if number format error occurs
java.lang.NumberFormatException
public static final java.lang.Float toFloat(java.lang.String str,
float defaultValue)
String to Float
org.jutil.TString.toFloat( final String str, float defaultValue);returns defaultValue if number format error occurs or str is empty
public static final boolean tob(java.lang.String str)
String to boolean value
org.jutil.TString.tob( final String str);returns false if str is empty, if the str is not "true" or "false" (case irrelevent) returns false
public static final boolean tob(java.lang.String str,
boolean defaultValue)
String to boolean value
org.jutil.TString.tob( final String str, true);returns defaultValue if str is empty, if the str is not "true" or "false" (case irrelevent) returns false
public static final java.lang.Boolean toBoolean(java.lang.String str)
String to Boolean value
org.jutil.TString.toBoolean( final String str);
public static final java.lang.Boolean toBoolean(java.lang.String str,
boolean defaultValue)
String to Boolean value
org.jutil.TString.toBoolean( final String str, true);returns defaultValue if str is empty
public static final java.lang.String snipLeft(java.lang.String str,
int size)
String str to the length size, by removing charcters on the left hand side
org.jutil.TString.snipLeft("aabcd", 3);
result: "bcd"
public static final java.lang.String snipRight(java.lang.String str,
int size)
String str to the length size, by removing charcters on the right hand side
org.jutil.TString.snipRight("aabcd", 3);
result: "aab"
public static final java.lang.String stripLeft(java.lang.String str,
java.lang.String strip)
String from the left hand side of the String str org.jutil.TString.stripLeft("aabcd", "a");
result: "bcd"
public static final java.lang.String stripLeft(java.lang.String input,
java.lang.String strip,
int count)
String from the left hand side of the String str recurse count times
result: "abcd"
public static final java.lang.String stripRight(java.lang.String str,
java.lang.String strip)
String from the right hand side of the String str
org.jutil.TString.stripRight("abcdd", "d");
public static final java.lang.String stripRight(java.lang.String input,
java.lang.String strip,
int count)
String from the right hand side of the String str recurse count times
org.jutil.TString.stripRight("abcdd", "d", 1);
org.jutil.TString.stripRight("abcdd", "d", 2);
public static final java.lang.String padLeft(java.lang.String str,
int len,
char pad)
String str with the pad char to the len length
org.jutil.TString.padLeft("95", 10, '0');
result: "0000000095"
public static final java.lang.String padRight(java.lang.String str,
int len,
char pad)
String str with the pad char to the len length
org.jutil.TString.padRight("95", 10, '0');
result: "9500000000"
public static final int hash(java.lang.String str)
String str
org.jutil.TString.hash("123456");
public static final boolean isEmpty(java.lang.String str)
String is null or length < 1
org.jutil.TString.isEmpty("123456");white space is considered empty
public static final java.lang.String[] wrap(java.lang.String source,
int wrapAt)
String[] desc = TString.wrap("12345678910123456789", 4);
public static final java.lang.String[] wrap(java.lang.String source,
int wrapAt,
java.lang.String lineSep)
String[] desc = TString.wrap("12345678910123456789", 4, "\n");
public static final java.lang.String hexEncode(java.lang.String data)
String into a hexadecimal repsentation.
org.jutil.TString.hexEncode("some data");
data - String to encode
String for the specified encoding.public static final java.lang.String hexDecode(java.lang.String hex)
String into its orgibnal form
String str = org.jutil.TString.hexDecode("546869732069732061206C6F6E6720737472696E67");
hex - String to decode
String
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||