|
2004.04.29 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--jdc.java.lang.Object
|
+--com.jdc.lang.ObjectHelper
|
+--com.jdc.type.StringHelper
StringHelper is a utility class that provides advanced String
manipulation methods to simplify the manipulation of String objects.
The following methods are available:
String value for an Decimal value.String value for an Integer value.String value to an int value.String value for single quotes or double quotes.String value.String value.String value. If a null value is
passed to a StringHelper method as a parameter, an empty String
value is returned to the caller.
The following default character values are in use unless overridden by the caller:
ObjectHelper,
Serialized Form| Constructor Summary | |
StringHelper()
Constructs a new StringHelper instance. |
|
StringHelper(String quoteCharacter)
Constructs a new StringHelper instance with the specified
default quote character. |
|
| Method Summary | |
String |
addCommas(String[] array)
Returns a comma-delimited String corresponding to String
array with the String array values trimmed and a space
(blank) added between the comma-delimited values. |
String |
addCommas(String[] array,
boolean trim,
boolean addSpace)
Returns a comma-delimited String corresponding to String
array. |
String |
addDoubleQuotes(String string)
Returns the String value with double quotes added, if not
already present. |
String |
addParentheses(String string)
Returns the String value with parentheses added, if not
already present. |
String |
addQuotes(String string)
Returns the String value with quotes added, if not
already present. |
String |
addSingleQuotes(String string)
Returns the String value with single quotes added, if not
already present. |
int |
intValue(String string)
Returns the value of this String as an int. |
boolean |
isDecimal(String string)
Returns true if the String field contains a
Decimal value. |
boolean |
isDoubleQuoted(String string)
Returns true if the String value is enclosed in
one or more pairs of double quotes. |
boolean |
isInteger(String string)
Returns true if the String field contains an
Integer value. |
boolean |
isQuoted(String string)
Returns true if the String value is enclosed in
one or more pairs of the default quote character. |
boolean |
isSingleQuoted(String string)
Returns true if the String value is enclosed in
one or more pairs of single quotes. |
static void |
main(String[] args)
Executes unit tests for the StringHelper class. |
String |
removeAllQuotes(String string)
Returns the specified String value with all matching
single and double quote characters, if any, removed. |
String |
removeDoubleQuotes(String string)
Returns the specified String value with all matching
double quote characters, if any, removed. |
String |
removeParentheses(String string)
Returns the specified String value with all matching
parenthesis characters, if any, removed. |
String |
removeQuotes(String string)
Returns the specified String value with all matching
quote characters, if any, removed. |
String |
removeSingleQuotes(String string)
Returns the specified String value with all matching
single quote characters, if any, removed. |
StringHelper |
setDelimiter(String delimiter)
Sets the default String delimiter character(s). |
StringHelper |
setQuote(String quoteCharacter)
Sets the default quote character. |
String[] |
toArray(ArrayList list)
Returns a String array corresponding to the ArrayList. |
| Methods inherited from class com.jdc.lang.ObjectHelper |
equals, isNoValue, isValue, noValue, toValue |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public StringHelper()
StringHelper instance.
public StringHelper(String quoteCharacter)
StringHelper instance with the specified
default quote character.
| Method Detail |
public String addCommas(String[] array)
String corresponding to String
array with the String array values trimmed and a space
(blank) added between the comma-delimited values.
String.
public String addCommas(String[] array,
boolean trim,
boolean addSpace)
String corresponding to String
array. Optionally, you may specify that the String array values
be trimmed and/or that a space (blank) be added between the delimited values.
String value.public String addDoubleQuotes(String string)
String value with double quotes added, if not
already present. If the String value is already enclosed in
double quotes, the original String value is returned with any
leading or trailing blanks (spaces) removed.
String value enclosed in double quotes.public String addParentheses(String string)
String value with parentheses added, if not
already present. If the String value is already enclosed in
parentheses, the original String value is returned with any
leading or trailing blanks (spaces) removed.
String value enclosed in parentheses.public String addQuotes(String string)
String value with quotes added, if not
already present. If the String value is already enclosed in
quotes, the original String value is returned with any
leading or trailing blanks (spaces) removed.
String value enclosed in quotes.public String addSingleQuotes(String string)
String value with single quotes added, if not
already present. If the String value is already enclosed in
single quotes, the original String value is returned with any
leading or trailing blanks (spaces) removed.
String value enclosed in single quotes.public int intValue(String string)
String as an int. If
the String field does not contain a valid int
value, 0 (zero) is returned.
int value represented by the String field. isInteger(java.lang.String)public boolean isDecimal(String string)
true if the String field contains a
Decimal value.
True if the String field contains a Decimal value. False if the String field does not contain a Decimal value. isInteger(java.lang.String)public boolean isDoubleQuoted(String string)
true if the String value is enclosed in
one or more pairs of double quotes.
True if the String value is enclosed in double quotes.False if the String value is not enclosed in double quotes.public boolean isInteger(String string)
true if the String field contains an
Integer value.
True if the String field contains an Integer value. False if the String field does not contain an Integer value. intValue(java.lang.String)public boolean isSingleQuoted(String string)
true if the String value is enclosed in
one or more pairs of single quotes.
True if the String value is enclosed in single quotes.False if the String value is not enclosed in single quotes.public boolean isQuoted(String string)
true if the String value is enclosed in
one or more pairs of the default quote character.
True if the String value is enclosed in quotes.False if the String value is not enclosed in quotes.public String removeAllQuotes(String string)
String value with all matching
single and double quote characters, if any, removed. If the String
value is not enclosed in single or double quotes, the original
String value is returned.
String value without any quotes.public String removeDoubleQuotes(String string)
String value with all matching
double quote characters, if any, removed. If the String value
is not enclosed in double quotes, the original String
value is returned.
String value without double quotes.public String removeParentheses(String string)
String value with all matching
parenthesis characters, if any, removed. If the String value
is not enclosed in parentheses, the original String
value is returned.
String value without parentheses.public String removeQuotes(String string)
String value with all matching
quote characters, if any, removed. If the String value
is not enclosed in quotes, the original String value
is returned.
String value without quotes.public String removeSingleQuotes(String string)
String value with all matching
single quote characters, if any, removed. If the String value
is not enclosed in single quotes, the original String
value is returned.
String value without single quotes.public StringHelper setQuote(String quoteCharacter)
public StringHelper setDelimiter(String delimiter)
String delimiter character(s).
public String[] toArray(ArrayList list)
String array corresponding to the ArrayList.
with the String array values trimmed, i.e. leading and trailing
spaces (blanks) are removed.
String array.public static void main(String[] args)
StringHelper class.
|
2004.04.29 |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||