org.jcoderz.commons.util
Class XsdUtil

java.lang.Object
  extended by org.jcoderz.commons.util.XsdUtil

public final class XsdUtil
extends Object

This class encapsulates util methods used for schema data type handling.

Author:
Andreas Mandel

Method Summary
static Date fromDateString(String date)
          Parses the given String as schema date representation and returns a Date object holding the given time.
static Date fromDateTimeString(String date)
          Parses the given String as schema date time representation and returns a Date object holding the given time.
static BigInteger integerFromString(String str)
          Parses the given string into a BigInteger.
static int intFromString(String str)
          Parses the given string into a int.
static boolean isValidToken(String token)
          Checks if the given string complies to the XML schema token restrictions.
static long longFromString(String str)
          Parses the given string into a long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

integerFromString

public static BigInteger integerFromString(String str)
                                    throws NumberFormatException,
                                           NullPointerException
Parses the given string into a BigInteger. This method uses BigInteger.BigInteger(java.lang.String) to parse the string, but allows a optional leading '+' for positive values.

Parameters:
str - the string to be parsed.
Returns:
a BigInteger representing the same value as the string.
Throws:
NumberFormatException - if the string can not be parsed.
NullPointerException - if the string is null.

intFromString

public static int intFromString(String str)
                         throws NumberFormatException,
                                NullPointerException
Parses the given string into a int. This method uses Integer.parseInt(java.lang.String) to parse the string, but allows a optional leading '+' for positive values.

Parameters:
str - the string to be parsed.
Returns:
a int representing the same value as the string.
Throws:
NumberFormatException - if the string can not be parsed.
NullPointerException - if the string is null.

longFromString

public static long longFromString(String str)
                           throws NumberFormatException,
                                  NullPointerException
Parses the given string into a long. This method uses Long.parseLong(java.lang.String) to parse the string, but allows a optional leading '+' for positive values.

Parameters:
str - the string to be parsed.
Returns:
a long representing the same value as the string.
Throws:
NumberFormatException - if the string can not be parsed.
NullPointerException - if the string is null.

isValidToken

public static boolean isValidToken(String token)
Checks if the given string complies to the XML schema token restrictions.

XML Schema Definition: token represents tokenized strings. The value space of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. For more information about the XML Schema datatype definition of a token see XML Schema datatype: token

Parameters:
token - the string to be checked
Returns:
true if the given string complies to the XML schema token restrictions; false otherwise.

fromDateTimeString

public static Date fromDateTimeString(String date)
Parses the given String as schema date time representation and returns a Date object holding the given time. This method must only be used after a JAXBContext has been initialized, otherwise it is likely that a NullpointerException is thrown.

Parameters:
date - the date time in schema dateTime
Returns:
a newly generated Date object representing the time given in the date.

fromDateString

public static Date fromDateString(String date)
Parses the given String as schema date representation and returns a Date object holding the given time. This method must only be used after a JAXBContext has been initialized, otherwise it is likely that a NullpointerException is thrown.

Parameters:
date - the date in schema date representation
Returns:
a newly generated Date object representing the time given in the date.


Copyright 2007 The jCoderZ Project.