|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.boylesoftware.cb2.util.TextUtils
Collection of useful text and string processing static functions.
| Nested Class Summary | |
static class |
TextUtils.MapValueGetter
Standard implementation of ValueGetter interface, which
takes values for macros from a map object. |
static interface |
TextUtils.ValueGetter
Interface used by the replaceMacros methods to get values
for macros. |
| Constructor Summary | |
TextUtils()
|
|
| Method Summary | |
static java.lang.String |
arrayToString(java.lang.Object[] src)
Calls arrayToString(src, 0, src.length). |
static java.lang.String |
arrayToString(java.lang.Object[] src,
int startIndex,
int length)
Returns string representation of data in the specified array of objects. |
static java.lang.String |
getNullIfEmpty(java.lang.String s)
If the input string is not null, not zero length and
does not consist of only whitespace characters, this method trims it
and returns the result. |
static boolean |
isEmpty(java.lang.String s)
Checks if the specified string is "empty". |
static boolean |
isValidEmailAddress(java.lang.String s)
Tells if the specified string is valid email address. |
static java.lang.String |
replaceMacros(java.lang.CharSequence input,
TextUtils.ValueGetter valueGetter)
This method replaces all occurencies of ${name} in the
input string with respective values provided by the specified
value getter. |
static java.lang.String |
replaceMacros(java.lang.CharSequence input,
TextUtils.ValueGetter valueGetter,
boolean leaveNotFoundMacros)
This method replaces all occurencies of ${name} in the
input string with respective values provided by the specified
value getter. |
static java.lang.String |
timeIntervalToString(long interval)
Render a readable string representation of a time interval. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TextUtils()
| Method Detail |
public static java.lang.String replaceMacros(java.lang.CharSequence input,
TextUtils.ValueGetter valueGetter)
${name} in the
input string with respective values provided by the specified
value getter. If no value is returned by the getter for the name
name then the ${name} is replaced with
an empty string.
input - the input string containing macros in the form
${name}.valueGetter - implementation of TextUtils.ValueGetter
interface, which provides values for macros.
public static java.lang.String replaceMacros(java.lang.CharSequence input,
TextUtils.ValueGetter valueGetter,
boolean leaveNotFoundMacros)
${name} in the
input string with respective values provided by the specified
value getter.
input - the input string containing macros in the form
${name}.valueGetter - implementation of TextUtils.ValueGetter
interface, which provides values for macros.leaveNotFoundMacros - if true and no value was
found for the macro, that is the value getter returned
null, the macro tag is copied to the output
intact, otherwise the tag is replaced with an empty string.
public static java.lang.String arrayToString(java.lang.Object[] src)
arrayToString(src, 0, src.length).
src - the input array.
public static java.lang.String arrayToString(java.lang.Object[] src,
int startIndex,
int length)
src - the input array.startIndex - index of the first element in the array.length - number of array elements to process.
public static java.lang.String timeIntervalToString(long interval)
Examples of the method's output:
0.028s 50.315s 00:40:53 15:20:45 21d 15:20:45
interval - the time interval in milliseconds.
public static boolean isEmpty(java.lang.String s)
null, zero length or consists of
only whitespace characters.
s - string to check, can be null.
true if the specified string is empty.public static java.lang.String getNullIfEmpty(java.lang.String s)
null, not zero length and
does not consist of only whitespace characters, this method trims it
and returns the result. Otherwise, it returns null.
s - the input string, can be null.
null if the input string
is "empty" in terms of TextUtils.isEmpty method.public static boolean isValidEmailAddress(java.lang.String s)
s - the string to test, should be trimmed, allowed
to be null.
true if the specified string is not
null and denotes a syntactically valid email
address.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||