it.could.util
Class StringTools

java.lang.Object
  extended byit.could.util.StringTools

public final class StringTools
extends Object

An utility class providing various static methods operating on Strings.

This class implement the Encodable interface from which it inherits its default encoding.

Author:
Pier Fumagalli

Method Summary
static int findFirst(String source, String delimiters)
          Find the first occurrence of one of the specified delimiter characters in the specified source string.
static String formatHttpDate(Date date)
          Format a Date according to the HTTP/1.1 RFC.
static String formatIsoDate(Date date)
          Format a Date according to the ISO 8601 specification.
static String formatNumber(Number number)
          Format a Number into a String making sure that NullPointerExceptions are not thrown.
static Date parseHttpDate(String string)
          Parse a String into a Date according to the HTTP/1.1 RFC (Mon, 31 Jan 2000 11:59:00 GMT).
static Date parseIsoDate(String string)
          Parse a String into a Date according to the ISO 8601 specification (2000-12-31T11:59:00Z).
static Long parseNumber(String string)
          Parse a String into a Long.
static String[] splitAll(String source, char delimiter)
          Split the specified string according to the specified delimiter, and any resulting path of zero length will be converted to null.
static String[] splitOnce(String source, char delimiter, boolean noDelimReturnSecond)
          Split the specified string in two parts according to the specified delimiter, and any resulting path of zero length will be converted to null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

formatNumber

public static String formatNumber(Number number)

Format a Number into a String making sure that NullPointerExceptions are not thrown.

Parameters:
number - the Number to format.
Returns:
a String instance or null if the object was null.

parseNumber

public static Long parseNumber(String string)

Parse a String into a Long.

Parameters:
string - the String to parse.
Returns:
a Long instance or null if the date was null or if there was an error parsing the specified String.

formatHttpDate

public static String formatHttpDate(Date date)

Format a Date according to the HTTP/1.1 RFC.

Parameters:
date - the Date to format.
Returns:
a String instance or null if the date was null.

formatIsoDate

public static String formatIsoDate(Date date)

Format a Date according to the ISO 8601 specification.

Parameters:
date - the Date to format.
Returns:
a String instance or null if the date was null.

parseHttpDate

public static Date parseHttpDate(String string)

Parse a String into a Date according to the HTTP/1.1 RFC (Mon, 31 Jan 2000 11:59:00 GMT).

Parameters:
string - the String to parse.
Returns:
a Date instance or null if the date was null or if there was an error parsing the specified String.

parseIsoDate

public static Date parseIsoDate(String string)

Parse a String into a Date according to the ISO 8601 specification (2000-12-31T11:59:00Z).

Parameters:
string - the String to parse.
Returns:
a Date instance or null if the date was null or if there was an error parsing the specified String.

splitOnce

public static String[] splitOnce(String source,
                                 char delimiter,
                                 boolean noDelimReturnSecond)

Split the specified string in two parts according to the specified delimiter, and any resulting path of zero length will be converted to null.


splitAll

public static String[] splitAll(String source,
                                char delimiter)

Split the specified string according to the specified delimiter, and any resulting path of zero length will be converted to null.


findFirst

public static int findFirst(String source,
                            String delimiters)

Find the first occurrence of one of the specified delimiter characters in the specified source string.