Novell exteNd
Director 5.2 API

com.sssw.fw.util
Class EboParse

java.lang.Object
 |
 +--com.sssw.fw.util.EboParse

public final class EboParse
extends Object

The EboParse class provides static methods to perform parsing of the strings representing long, double, date, time and timestamp objects. It tries to "intelligently" parse the string - if the specified style or pattern doesn't work, we try a list of our own common styles and patterns.

Note that expontial notation is not currently supported for BigDecimals.


Field Summary
static int TYPE_BIGDECIMAL
          The big decimal type value for the type parameter of the parse methods.
static int TYPE_DATE
          The date type value for the type parameter of the parse methods.
static int TYPE_DOUBLE
          The double type value for the type parameter of the parse methods.
static int TYPE_INT
          The integer type value for the type parameter of the parse methods.
static int TYPE_LONG
          The long type value for the type parameter of the parse methods.
static int TYPE_TIME
          The time type value for the type parameter of the parse methods.
static int TYPE_TIMESTAMP
          The timestamp type value for the type parameter of the parse methods.
 
Constructor Summary
EboParse()
           
 
Method Summary
static void allow2DigitYears(boolean allow2DigitYears)
          Turns on or off the ability to enter years from 1 to 99.
static int get2DigitYearWindow()
          Gets the 2-digit year "sliding window" value, which determines how 2-digit years are parsed
static Object parse(int type, String parseStr, String pattern)
          Parses a string and produces respective object, e.g.
static Object parse(int type, String parseStr, String pattern, int style)
          Parses a string and produces respective object
static Object parse(int type, String parseStr, String pattern, int timeStyle, int dateStyle)
          Parses a string and produces respective object
static Object parse(int type, String parseStr, String pattern, int style1, int style2, Locale locale, String zoneStr)
          Parses a string and produces respective object
static Object parse(int type, String parseStr, String pattern, int style1, int style2, String lang, String country, String variant, String zoneStr)
          Parses a string and produces respective object
static void set2DigitYearWindow(int value)
          Sets the 2-digit year "sliding window" value, which determines how 2-digit years are parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_INT

public static final int TYPE_INT
The integer type value for the type parameter of the parse methods.

TYPE_LONG

public static final int TYPE_LONG
The long type value for the type parameter of the parse methods.

TYPE_DOUBLE

public static final int TYPE_DOUBLE
The double type value for the type parameter of the parse methods.

TYPE_DATE

public static final int TYPE_DATE
The date type value for the type parameter of the parse methods.

TYPE_TIME

public static final int TYPE_TIME
The time type value for the type parameter of the parse methods.

TYPE_TIMESTAMP

public static final int TYPE_TIMESTAMP
The timestamp type value for the type parameter of the parse methods.

TYPE_BIGDECIMAL

public static final int TYPE_BIGDECIMAL
The big decimal type value for the type parameter of the parse methods.
Constructor Detail

EboParse

public EboParse()
Method Detail

parse

public static Object parse(int type,
                           String parseStr,
                           String pattern)
                    throws IllegalArgumentException
Parses a string and produces respective object, e.g.
 Timestamp ts = (Timestamp)EboParse.parse(EboParse.TYPE_TIMESTAMP,
     "1992-10-10 20:20:20 PST", "yyyy-MM-dd hh:mm:ss z");
 


Please see the JDK documentation on NumberFormat, DateFormat, DecimalFormat and SimpleDateFormat for more details.
Parameters:
type - the data type to parse out of the string
parseStr - the string to parse
pattern - string's pattern
Returns:
the parsed out object
Throws:
IllegalArgumentException -  

parse

public static Object parse(int type,
                           String parseStr,
                           String pattern,
                           int style)
                    throws IllegalArgumentException
Parses a string and produces respective object
Parameters:
type - the data type to parse out of the string
parseStr - the string to parse
pattern - describes the pattern of the data contained in the string, overrides the default pattern
style - overrides the default style
Returns:
the parsed out object
Throws:
IllegalArgumentException -  

parse

public static Object parse(int type,
                           String parseStr,
                           String pattern,
                           int timeStyle,
                           int dateStyle)
                    throws IllegalArgumentException
Parses a string and produces respective object
Parameters:
type - the type of data contained in the string
parseStr - the string to parse
pattern - overrides default pattern
timeStyle - overrides default style for time
dateStyle - overrides default style for date
Returns:
the parsed out object
Throws:
IllegalArgumentException -  

parse

public static Object parse(int type,
                           String parseStr,
                           String pattern,
                           int style1,
                           int style2,
                           String lang,
                           String country,
                           String variant,
                           String zoneStr)
                    throws IllegalArgumentException
Parses a string and produces respective object
Parameters:
type - the type of the data contained in the string
parseStr - the string to parse
pattern - overrides default pattern
style1 - overrides default style for time
style2 - overrides default style for date
lang - overrides default language (part of Locale)
country - overrides default country (part of Locale)
variant - overrides default variant (part of Locale)
zoneStr - overrides default time zone
Returns:
object
Throws:
IllegalArgumentException -  

parse

public static Object parse(int type,
                           String parseStr,
                           String pattern,
                           int style1,
                           int style2,
                           Locale locale,
                           String zoneStr)
                    throws IllegalArgumentException
Parses a string and produces respective object
Parameters:
type - the type to parse out of the string
parseStr - the string to parse
pattern - describes the pattern of the data
style1 - overrides default style for time
style2 - overrides default style for date
locale - overrides default locale
zoneStr - overrides default time zone
Returns:
the parsed out object
Throws:
IllegalArgumentException -  

allow2DigitYears

public static void allow2DigitYears(boolean allow2DigitYears)
Turns on or off the ability to enter years from 1 to 99. Otherwise, "99" will be interpreted as 1999 (or 2099, depending on the value set in the set2DigitYearWindow method).
Parameters:
allow2DigitYears - if true, 2-digit years are allowed

set2DigitYearWindow

public static void set2DigitYearWindow(int value)
Sets the 2-digit year "sliding window" value, which determines how 2-digit years are parsed. Numbers below this value are interpreted as 21st-century dates; numbers equal to or above this value are interpreted as 20th-century dates.

For example, if the window value is 50 (the default), then:

To turn windowing off, so that all 2-digit years are interpreted as 20th-centry dates, set this value to zero.

Note that if the user enters a 4-digit year, this window value is ignored, and the year is always parsed correctly.

Parameters:
value - the 2-digit year "sliding window" value

get2DigitYearWindow

public static int get2DigitYearWindow()
Gets the 2-digit year "sliding window" value, which determines how 2-digit years are parsed
Returns:
the 2-digit year "sliding window" value
See Also:
EboParse.set2DigitYearWindow(int)

Novell exteNd
Director 5.2 API