|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.empire.commons.StringUtils
public class StringUtils
This class contains common functions for comparing and converting values of type String.
Method Summary | |
---|---|
static String |
arrayToString(Object[] array,
String separator)
Converts an array of objects to a string. |
static String |
coalesce(String preferred,
String alternative)
Returns the preferred String if it is not empty ot the alternative String otherwise. |
static boolean |
compareEqual(String s1,
String s2,
boolean ignoreCase)
Compares two Strings with each other - either with or without character case. |
static boolean |
isEmpty(String s)
Checks if a string is empty |
static boolean |
isNotEmpty(String s)
Checks if a string is not null or empty |
static boolean |
isValid(String s)
Deprecated. this has been renamed to isNotEmpty |
static String |
nullIfEmpty(Object value)
Returns null if the value supplied is null or an empty String. |
static String |
replace(String source,
String find,
String replace)
Replaces all occurences of find in source by replace. |
static String |
replaceAll(String source,
String find,
String replace)
Returns a String with all occurrences of from within orig replaced with to . |
static String |
toString(Object value)
Converts a value to a string. |
static String |
toString(Object[] array)
Converts an array of objects to a string. |
static String |
toString(Object[] array,
String defValue)
Converts an array of objects to a string. |
static String |
toString(Object value,
String defValue)
Converts a value to a string. |
static String |
validate(String s)
Validates a given string. |
static String |
valueOf(Object value)
Converts a value to a string. |
static String |
valueOf(Object[] array)
Converts an objects to a string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String toString(Object value, String defValue)
value
- the value to convertdefValue
- default value which to return if value is null
public static String toString(Object value)
value
- the value to convert
public static String toString(Object[] array, String defValue)
array
- array of objectsdefValue
- default value which to return if array is null
public static String toString(Object[] array)
array
- array of objects
public static String valueOf(Object value)
value
- the value to convert
public static String valueOf(Object[] array)
array
- array of objects
public static String coalesce(String preferred, String alternative)
preferred
- the preferred Stringalternative
- the alternative String if the preferred String is not valid
public static String nullIfEmpty(Object value)
value
- the value to check
public static String arrayToString(Object[] array, String separator)
array
- array of objectsseparator
- the separator to put between the object strings
public static boolean isEmpty(String s)
s
- the String to check
null
@Deprecated public static boolean isValid(String s)
s
- the string to validate
public static boolean isNotEmpty(String s)
s
- the string to validate
public static boolean compareEqual(String s1, String s2, boolean ignoreCase)
s1
- the first Strings2
- the second StringignoreCase
- whether to ignore the character casing or not
public static String validate(String s)
s
- the string to validate
public static String replace(String source, String find, String replace)
source
- the original String.find
- the String to be replacedreplace
- the replacement string
find
in source
replaced by replace
public static String replaceAll(String source, String find, String replace)
from
within orig
replaced with to
.
If orig
contains no occurrences of from
, or if from
is equal to
to
,orig
itself is returned rather than a copy being made. If orig is null
,
null
is returned.
source
- the original String.find
- the String to be replacedreplace
- the replacement string
find
in source
replaced by replace
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |