com.fullspan.util
Class StringUtil

java.lang.Object
  extended bycom.fullspan.util.StringUtil

public class StringUtil
extends java.lang.Object

Static utility methods for strings (this class has a private constructor and cannot be instantiated).

Version:
$Revision: 1.3 $, $Date: 2004/11/20 08:14:05 $
Author:
Mitch Stuart

Field Summary
static java.lang.String[] EMPTY_STRING_ARRAY
          A zero-element String array.
 
Method Summary
static java.lang.String concatStringParts(java.lang.String[] parts)
          Concatenate a list of Strings into a single String
static java.lang.String concatStringParts(java.lang.String[] parts, java.lang.String separator)
          Concatenate a list of Strings into a single String, separated by a given separator String.
static java.lang.String getStringNoNull(java.lang.Object o)
          Return the String value of the argument o.
static java.lang.String[] getStringParts(java.lang.String text)
          Splits a String into parts and returns an array of the parts.
static java.lang.String[] getStringParts(java.lang.String text, java.lang.String delim)
          Splits a String into parts and returns an array of the parts.
static java.lang.String[] getStringParts(java.lang.String text, java.lang.String delim, boolean returnDelims)
          Splits a String into parts and returns an array of the parts.
static java.lang.String getStringWithNull(java.lang.Object o)
          Return the String value of the argument o.
static java.lang.String getTrimmedStringNoNull(java.lang.Object o)
          Return the whitespace-trimmed String value of o.
static java.lang.String getTrimmedStringWithNull(java.lang.Object o)
          Return the whitespace-trimmed String value of o.
static boolean isEmpty(java.lang.Object o)
          Check if the string is null or empty
static boolean isEmptyTrimmed(java.lang.Object o)
          Check if the string is null or empty
static int parseIntSafe(java.lang.Object o)
           
static long parseLongSafe(java.lang.Object o)
           
static java.lang.String truncate(java.lang.String input, int maxlen)
           
static java.lang.String truncate(java.lang.String input, int maxlen, java.lang.String marker)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY
A zero-element String array.

Method Detail

concatStringParts

public static java.lang.String concatStringParts(java.lang.String[] parts)
Concatenate a list of Strings into a single String

Parameters:
parts - the strings to concatenate
Returns:
a String containing the parts, separated by the separator

concatStringParts

public static java.lang.String concatStringParts(java.lang.String[] parts,
                                                 java.lang.String separator)
Concatenate a list of Strings into a single String, separated by a given separator String.

Parameters:
parts - the strings to concatenate
separator - the separator
Returns:
a String containing the parts, separated by the separator

getStringParts

public static java.lang.String[] getStringParts(java.lang.String text)
Splits a String into parts and returns an array of the parts.

Equivalent to calling getStringParts(text, " \t\n\r\f")

Parameters:
text - the input String
Returns:
an array of Strings, one for each String delmited by delim in the input text argument
See Also:
getStringParts(String, String)

getStringParts

public static java.lang.String[] getStringParts(java.lang.String text,
                                                java.lang.String delim)
Splits a String into parts and returns an array of the parts.

Equivalent to calling getStringParts(text, delim, false)

Parameters:
text - the input String
delim - the delimiter String passed to the StringTokenizer to split the input String
Returns:
an array of Strings, one for each String delmited by delim in the input text argument
See Also:
getStringParts(String, String, boolean)

getStringParts

public static java.lang.String[] getStringParts(java.lang.String text,
                                                java.lang.String delim,
                                                boolean returnDelims)
Splits a String into parts and returns an array of the parts. Uses a StringTokenizer to split the input String.

Parameters:
text - the input String
delim - the delimiter String passed to the StringTokenizer to split the input String
returnDelims - true to include the delimiters in the array of returned Strings; false to not include the delimiters
Returns:
an array of Strings, one for each String delmited by delim in the input text argument

isEmpty

public static boolean isEmpty(java.lang.Object o)
Check if the string is null or empty

Parameters:
o - the object that will be tested
Returns:
true if the object is null, or if its string value is null, or if its string length is 0, otherwise false

isEmptyTrimmed

public static boolean isEmptyTrimmed(java.lang.Object o)
Check if the string is null or empty

Parameters:
o - the object that will be tested
Returns:
true if the object is null, or if its string value is null, or if its string length is 0, otherwise false

getStringNoNull

public static java.lang.String getStringNoNull(java.lang.Object o)
Return the String value of the argument o.

Parameters:
o - the Object whose String value will be returned
Returns:
the String value of o, or an empty (zero-length) String if o is null

getTrimmedStringNoNull

public static java.lang.String getTrimmedStringNoNull(java.lang.Object o)
Return the whitespace-trimmed String value of o.

Parameters:
o - the Object whose String value will be returned
Returns:
the whitespace-trimmed String value of o, or an empty (zero-length) String if o is null

getStringWithNull

public static java.lang.String getStringWithNull(java.lang.Object o)
Return the String value of the argument o.

Parameters:
o - the Object whose String value will be returned
Returns:
null if o is null, or if the String value of 0 is an empty (zero-length) string

getTrimmedStringWithNull

public static java.lang.String getTrimmedStringWithNull(java.lang.Object o)
Return the whitespace-trimmed String value of o.

Parameters:
o - the object whose String value will be returned
Returns:
null if o is null; null if the String representation of o is an empty (zero-length) string; otherwise the trimmed String representation of o
See Also:
String.trim()

parseIntSafe

public static int parseIntSafe(java.lang.Object o)

parseLongSafe

public static long parseLongSafe(java.lang.Object o)

truncate

public static java.lang.String truncate(java.lang.String input,
                                        int maxlen)

truncate

public static java.lang.String truncate(java.lang.String input,
                                        int maxlen,
                                        java.lang.String marker)