|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.util.Strings
public final class Strings
A collection of String methods.
Constructor Summary | |
---|---|
Strings()
|
Method Summary | |
---|---|
static boolean |
areEqual(java.lang.String s1,
java.lang.String s2)
Return true if the two String arguments are equal, where either or both of the arguments may be null. |
static java.lang.String |
expand(java.lang.String expr,
java.lang.String fmt)
Expand the string |
static java.lang.String[] |
fragmentString(java.lang.String longString,
int fragmentSize)
Rip a String into equal sized fragments. |
static boolean |
isAlpha(java.lang.String string)
Return a boolean true response if String is Alpha |
static boolean |
isDecimal(java.lang.String string)
Return a boolean true response if String is a Decimal value (Numeric, '.') |
static boolean |
isEmpty(java.lang.String s)
Return true if string is null, empty, or all space characters. |
static boolean |
isMoney(java.lang.String string)
Return a boolean true response if String is a Money value (Numeric, '.') |
static boolean |
isNumeric(java.lang.String string)
Return a boolean true response if String is an Integer. |
static java.lang.String |
leftFill(java.lang.String orig,
int newLength,
char padChar)
Left fill given string to newLength positions using pad character padChar. |
static java.lang.String |
noNull(java.lang.String s)
Return the original String if not null or an empty String if it was null. |
static java.lang.String |
nullIfEmpty(java.lang.String s)
Return null if the given String is null or zero length, otherwise return the String. |
static java.lang.String[] |
paginateString(java.lang.String string,
java.lang.String breakString,
int columns)
Return an array of strings representing the original string but having been: split into multiple lines based on the given breakString, word-wrapped around the number of columns on a line. |
static java.lang.String |
replace(java.lang.String s,
java.lang.String find,
java.lang.String replace)
String replace. |
static java.lang.String |
rightFill(java.lang.String s,
int l,
char pad)
Right fill string to given length. |
static java.lang.String |
stripChar(java.lang.String s,
char ch)
Compact given string by removing specified character. |
static java.lang.String |
stripNonDecimal(java.lang.String string)
Return a String that represents the numbers only. |
static java.lang.String |
stripNonLetter(java.lang.String string)
Return a new String based on the given one but without any non-letter characters removed. |
static java.lang.String |
stripNonLetterOrDigit(java.lang.String string)
Return a new String based on the given one but without any non-letter or digit characters removed. |
static java.lang.String |
stripNonNumeric(java.lang.String string)
Return a new String based on the given one but without any non-digit characters removed. |
static java.lang.String[] |
toArray(java.lang.String expr,
java.lang.String delim)
Convert string with delimiter into array of Strings. |
static java.lang.String |
trim(java.lang.String s)
Returned a whitespace trimmed version of the given String unless it is null, in which case return null. |
static java.lang.String |
upper(java.lang.String s)
Return the given String converted to uppercase. |
static java.lang.String[] |
wrapString(java.lang.String string,
int columns)
Return an array of strings representing the original string 'word wrapped' around the specified column. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Strings()
Method Detail |
---|
public static boolean areEqual(java.lang.String s1, java.lang.String s2)
s1
- The first of the two Strings.s2
- The second of the two Strings.
public static java.lang.String noNull(java.lang.String s)
s
- The string to test.
public static java.lang.String nullIfEmpty(java.lang.String s)
Many XML applications return an empty string instead of null, so this helps convert it to null.
s
- The string to test for null or empty.
public static java.lang.String replace(java.lang.String s, java.lang.String find, java.lang.String replace)
Does a lazy create on the underlying StringBuffer, so that if nothing is replaced it just returns the original String. This saves CPU time by not allocating lots of little objects that won't be used.
s
- Original string.find
- String to search for and replace if found.replace
- Replacement text.
public static java.lang.String stripChar(java.lang.String s, char ch)
This always creates a StringBuffer, it could be improved by only creating it when there are characters to remove.
s
- The string to remove certain characters from.ch
- The character to remove from s.
public static java.lang.String leftFill(java.lang.String orig, int newLength, char padChar)
Example:
leftFill ("23", 5, '0')This will return "00023".
orig
- The original String.newLength
- The desired length to make the string.padChar
- The character to left-fill orig with.
public static boolean isEmpty(java.lang.String s)
s
- The string to test.
public static java.lang.String rightFill(java.lang.String s, int l, char pad)
s
- The string to right-fill.l
- The new length.pad
-
public static java.lang.String[] toArray(java.lang.String expr, java.lang.String delim)
expr
- The string containing a list of delimited fields, such as "one|two|three".delim
- The delimiter text.
public static java.lang.String[] paginateString(java.lang.String string, java.lang.String breakString, int columns)
string
- The string to word-wrap.breakString
- A pattern which if matched forces a line break.columns
- The maximum line length.
public static java.lang.String[] wrapString(java.lang.String string, int columns)
string
- The string to perform wrapping on.columns
- The column number to wrap on.
public static java.lang.String expand(java.lang.String expr, java.lang.String fmt)
eg: expandChars ("19960912", "@@@@-@@-@@") yields "1996-09-12"
expr
- A string of input characters.fmt
- A format composed of '@' placeholders.
public static java.lang.String[] fragmentString(java.lang.String longString, int fragmentSize)
longString
- A long string to break apart.fragmentSize
- The size in characters of each fragment.
public static java.lang.String stripNonLetterOrDigit(java.lang.String string)
What's a letter? Anything for which Character.isLetter (ch) returns true! What's a digit? Anything for which Character.isDigit (ch) returns true!
string
- A string, non null.
public static java.lang.String stripNonNumeric(java.lang.String string)
string
- A string, non null.
public static java.lang.String stripNonLetter(java.lang.String string)
What's a letter? Anything for which Character.isLetter (ch) returns true!
string
- A string, non null.
public static java.lang.String trim(java.lang.String s)
This is usefull mostly when accessing ResultSet String objects that may be null, and if not must be trimmed.
s
- The String to trim if not null.
public static java.lang.String upper(java.lang.String s)
s
- The string to convert, possibly null.
public static boolean isNumeric(java.lang.String string)
string
- A string, non null.
public static boolean isAlpha(java.lang.String string)
string
- A string, non null.
public static boolean isMoney(java.lang.String string)
string
- A string, non null.
public static boolean isDecimal(java.lang.String string)
string
- A string, non null.
public static java.lang.String stripNonDecimal(java.lang.String string)
string
- A string, non null.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |