org.apache.muse.util.xml
Class XsdUtils

java.lang.Object
  extended by org.apache.muse.util.xml.XsdUtils

public class XsdUtils
extends Object

XsdUtils is a collection of utility methods related to XML Schema.

Author:
Dan Jemiolo (danj)

Field Summary
static QName ANY_TYPE_QNAME
           
static QName ANY_URI_QNAME
           
static QName ATTRIBUTE_GROUP_QNAME
           
static QName ATTRIBUTE_QNAME
           
static String BASE
           
static QName BOOLEAN_QNAME
           
static QName COMPLEX_CONTENT_QNAME
           
static QName COMPLEX_TYPE_QNAME
           
static QName DATE_QNAME
           
static QName DATE_TIME_QNAME
           
static QName DOUBLE_QNAME
           
static QName DURATION_QNAME
           
static QName ELEMENT_QNAME
           
static QName EXTENSION_QNAME
           
static QName FLOAT_QNAME
           
static QName IMPORT_QNAME
           
static QName INCLUDE_QNAME
           
static QName INT_QNAME
           
static QName INTEGER_QNAME
           
static QName LONG_QNAME
           
static String MAX_OCCURS
           
static String MIN_OCCURS
           
static long MS_IN_A_DAY
           
static long MS_IN_A_HOUR
           
static long MS_IN_A_MINUTE
           
static long MS_IN_A_MONTH
           
static long MS_IN_A_YEAR
           
static String NAME
           
static String NAMESPACE
           
static String NAMESPACE_URI
          The XML Schema namespace URI.
static QName NC_NAME_QNAME
           
static QName NIL_QNAME
           
static String NILLABLE
           
static String PREFIX
           
static QName QNAME_QNAME
           
static String REF
           
static String SCHEMA_LOCATION
           
static QName SCHEMA_QNAME
           
static QName SEQUENCE_QNAME
           
static QName SHORT_QNAME
           
static QName SIMPLE_TYPE_QNAME
           
static QName STRING_QNAME
           
static String TYPE
           
static String UNBOUNDED
           
 
Constructor Summary
XsdUtils()
           
 
Method Summary
static String getDuration(Date before, Date after)
           
static String getDuration(long totalTime)
           
static long getDuration(String durationString)
          Parses an xsd:duration string into its time value (in millseconds).
static Date getLocalTime(String dateTimeString)
          Parses the given XSD date string into a Date object.
static String getLocalTimeString()
          This is a convenience method that returns the text version of the current time, in standard XSD format.
static String getLocalTimeString(Date date)
          Returns the text version of the given date, in standard XSD format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE_URI

public static final String NAMESPACE_URI
The XML Schema namespace URI.

See Also:
Constant Field Values

PREFIX

public static final String PREFIX
See Also:
Constant Field Values

ANY_TYPE_QNAME

public static final QName ANY_TYPE_QNAME

ANY_URI_QNAME

public static final QName ANY_URI_QNAME

ATTRIBUTE_GROUP_QNAME

public static final QName ATTRIBUTE_GROUP_QNAME

ATTRIBUTE_QNAME

public static final QName ATTRIBUTE_QNAME

BOOLEAN_QNAME

public static final QName BOOLEAN_QNAME

COMPLEX_TYPE_QNAME

public static final QName COMPLEX_TYPE_QNAME

COMPLEX_CONTENT_QNAME

public static final QName COMPLEX_CONTENT_QNAME

EXTENSION_QNAME

public static final QName EXTENSION_QNAME

DATE_QNAME

public static final QName DATE_QNAME

DATE_TIME_QNAME

public static final QName DATE_TIME_QNAME

DOUBLE_QNAME

public static final QName DOUBLE_QNAME

DURATION_QNAME

public static final QName DURATION_QNAME

ELEMENT_QNAME

public static final QName ELEMENT_QNAME

FLOAT_QNAME

public static final QName FLOAT_QNAME

IMPORT_QNAME

public static final QName IMPORT_QNAME

INCLUDE_QNAME

public static final QName INCLUDE_QNAME

INT_QNAME

public static final QName INT_QNAME

INTEGER_QNAME

public static final QName INTEGER_QNAME

LONG_QNAME

public static final QName LONG_QNAME

MAX_OCCURS

public static final String MAX_OCCURS
See Also:
Constant Field Values

MIN_OCCURS

public static final String MIN_OCCURS
See Also:
Constant Field Values

MS_IN_A_DAY

public static final long MS_IN_A_DAY
See Also:
Constant Field Values

MS_IN_A_HOUR

public static final long MS_IN_A_HOUR
See Also:
Constant Field Values

MS_IN_A_MINUTE

public static final long MS_IN_A_MINUTE
See Also:
Constant Field Values

MS_IN_A_MONTH

public static final long MS_IN_A_MONTH
See Also:
Constant Field Values

MS_IN_A_YEAR

public static final long MS_IN_A_YEAR
See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values

NAMESPACE

public static final String NAMESPACE
See Also:
Constant Field Values

NC_NAME_QNAME

public static final QName NC_NAME_QNAME

NIL_QNAME

public static final QName NIL_QNAME

NILLABLE

public static final String NILLABLE
See Also:
Constant Field Values

QNAME_QNAME

public static final QName QNAME_QNAME

REF

public static final String REF
See Also:
Constant Field Values

BASE

public static final String BASE
See Also:
Constant Field Values

SCHEMA_LOCATION

public static final String SCHEMA_LOCATION
See Also:
Constant Field Values

SCHEMA_QNAME

public static final QName SCHEMA_QNAME

SEQUENCE_QNAME

public static final QName SEQUENCE_QNAME

SHORT_QNAME

public static final QName SHORT_QNAME

SIMPLE_TYPE_QNAME

public static final QName SIMPLE_TYPE_QNAME

STRING_QNAME

public static final QName STRING_QNAME

TYPE

public static final String TYPE
See Also:
Constant Field Values

UNBOUNDED

public static final String UNBOUNDED
See Also:
Constant Field Values
Constructor Detail

XsdUtils

public XsdUtils()
Method Detail

getDuration

public static String getDuration(Date before,
                                 Date after)
Parameters:
before -
after -
Returns:
A valid xsd:duration value that represents the time between the two dates. If the second time is before the first one, the duration will have a '-' prefix, meaning it is negative.

getDuration

public static String getDuration(long totalTime)
Parameters:
totalTime -
Returns:
A valid xsd:duration value that represents the given time. If the value is negative, the duration will have a '-' prefix, meaning it is negative.

getDuration

public static long getDuration(String durationString)
Parses an xsd:duration string into its time value (in millseconds). The format of a xsd:duration is:

(-)PaYbMcD(TxHyMzS)

Where a, b, and c are the years, months, and days, respectively. The time value (following the 'T') is optional. Its values - x, y, and z - are the hours, minutes, and seconds, respectively. The value of the duration may be negative.

Parameters:
durationString - A valid xsd:duration string.
Returns:
The time, in milliseconds, represented by the given xsd:duration.

getLocalTime

public static Date getLocalTime(String dateTimeString)
                         throws ParseException
Parses the given XSD date string into a Date object.

Parameters:
dateTimeString - The text description of a date, in standard XSD format.
Returns:
The Date equivalent of the date string.
Throws:
ParseException -
  • If the format of the date string was incorrect.

getLocalTimeString

public static String getLocalTimeString()
This is a convenience method that returns the text version of the current time, in standard XSD format.

See Also:
getLocalTimeString(Date)

getLocalTimeString

public static String getLocalTimeString(Date date)
Returns the text version of the given date, in standard XSD format. It will include a +/- suffix that adds or subtracts hours from the UTC time in order to express local time.

Parameters:
date - The date to serialize into text.
Returns:
A string that describes the given date, in XSD format, with a +/- suffix to denote the local time.


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.