|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object consciouscode.util.Strings
public final class Strings
Utility methods for String manipulation.
Field Summary | |
---|---|
static String[] |
EMPTY_ARRAY
|
Constructor Summary | |
---|---|
Strings()
|
Method Summary | |
---|---|
static String |
cleanup(String string,
String emptyValue)
Trims any whitespace from a String, converting empty results to a specific value. |
static boolean |
containsDigits(String string)
Determine whether a string has any digit characters. |
static String |
emptyToNull(String string)
Return null if a String equals "", return the String otherwise. |
static boolean |
equal(String left,
String right)
Compare two Strings for equality. |
static String |
join(Iterator<?> elements,
String separator)
Deprecated. Use Apache Commons StringUtils.join(Iterator,String) |
static void |
join(Iterator<?> elements,
String separator,
StringBuffer buffer)
Concatenates elements into a StringBuffer, inserting
separator between elements. |
static String |
join(Object elements,
String separator)
Concatenates a collection of elements into one String,
inserting separator between elements. |
static void |
join(Object elements,
String separator,
StringBuffer buffer)
Concatenates elements into a StringBuffer, inserting
separator between elements. |
static double |
parseDouble(String stringValue,
double defaultResult)
Attempts to parse a String into a double . |
static float |
parseFloat(String stringValue,
float defaultResult)
Attempts to parse a String into a float . |
static int |
parseInt(String stringValue,
int defaultResult)
Attempts to parse a String into an int . |
static ArrayList<String> |
splitAndCleanup(String joinedStrings,
String delim)
Splits a single string into a sequence. |
static ArrayList<String> |
splitAndCleanup(String joinedStrings,
String delim,
String emptyValue)
Splits a single string into a sequence. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String[] EMPTY_ARRAY
Constructor Detail |
---|
public Strings()
Method Detail |
---|
public static boolean equal(String left, String right)
null
, return false
.
public static String emptyToNull(String string)
public static String cleanup(String string, String emptyValue)
emptyValue
- is the result if string
is null or empty
after being trimmed.public static String join(Object elements, String separator)
elements
into one String,
inserting separator
between elements.
Each element is converted to a String value using
Object.toString()
. Empty strings are not removed.
elements
- must be one of: Iterator, Enumeration, Collection, Map,
Object[], or primitive array.IteratorUtils.getIterator(java.lang.Object)
@Deprecated public static String join(Iterator<?> elements, String separator)
StringUtils.join(Iterator,String)
elements
into one String, inserting
separator
between elements.
Each element is converted to a String value using
Object.toString()
. Empty strings are not removed.
public static void join(Object elements, String separator, StringBuffer buffer)
elements
into a StringBuffer, inserting
separator
between elements.
Each element is converted to a String value using
Object.toString()
. Empty strings are not removed.
elements
- must be one of: Iterator, Enumeration, Collection, Map,
Object[], or primitive array.IteratorUtils.getIterator(java.lang.Object)
public static void join(Iterator<?> elements, String separator, StringBuffer buffer)
elements
into a StringBuffer, inserting
separator
between elements.
Each element is converted to a String value using
Object.toString()
. Empty strings are not removed.
public static ArrayList<String> splitAndCleanup(String joinedStrings, String delim)
delim
argument are the delimiters for separating tokens. Delimiter
characters themselves will not be treated as tokens.
Each element string is trimmed of leading and trailing whitespace. Any empty strings are removed from the list.
This method is primarily a wrapper around a StringTokenizer
.
splitAndCleanup(String, String, String)
public static ArrayList<String> splitAndCleanup(String joinedStrings, String delim, String emptyValue)
delim
argument are the delimiters for separating tokens. Delimiter
characters themselves will not be treated as tokens.
Each element string is trimmed of leading and trailing whitespace. Any
empty strings (after trimming) are replaced by emptyValue
and left in the list.
This method is primarily a wrapper around a StringTokenizer
.
splitAndCleanup(String, String)
public static boolean containsDigits(String string)
public static int parseInt(String stringValue, int defaultResult)
String
into an int
.
stringValue
,
or defaultResult
if stringValue
is null or
has an illegal format.Integer.parseInt(java.lang.String)
public static float parseFloat(String stringValue, float defaultResult)
String
into a float
.
stringValue
,
or defaultResult
if stringValue
is null or
has an illegal format.Float.parseFloat(java.lang.String)
public static double parseDouble(String stringValue, double defaultResult)
String
into a double
.
stringValue
,
or defaultResult
if stringValue
is null or
has an illegal format.Double.parseDouble(java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |