org.ucl.xpath.types
Class XSDate

java.lang.Object
  extended byorg.ucl.xpath.types.AnyType
      extended byorg.ucl.xpath.types.AnySimpleType
          extended byorg.ucl.xpath.types.AnyAtomicType
              extended byorg.ucl.xpath.types.CtrType
                  extended byorg.ucl.xpath.types.CalendarType
                      extended byorg.ucl.xpath.types.XSDate
All Implemented Interfaces:
java.lang.Cloneable, CmpEq, CmpGt, CmpLt, MathMinus, MathPlus

public class XSDate
extends CalendarType
implements CmpEq, CmpLt, CmpGt, MathMinus, MathPlus, java.lang.Cloneable

Representation of a date of the form year-month-day and optional timezone


Constructor Summary
XSDate()
          Initialises a new representation of the current date
XSDate(java.util.Calendar cal, XDTDayTimeDuration tz)
          Initialises a new represenation of a supplied date
 
Method Summary
 java.util.Calendar calendar()
          Retrieves the Calendar representation of the date stored
 java.lang.Object clone()
          Creates a copy of this date representation
 ResultSequence constructor(ResultSequence arg)
          Creates a new result sequence consisting of the retrievable date value in the supplied result sequence
 int day()
          Retrieve the day from the date stored
 boolean eq(AnyType arg)
          Equality comparison on this and the supplied dates (taking timezones into account)
 boolean gt(AnyType arg)
          Comparison on this and the supplied dates (taking timezones into account)
 boolean lt(AnyType arg)
          Comparison on this and the supplied dates (taking timezones into account)
 ResultSequence minus(ResultSequence arg)
          Mathematical minus operator between this XSDate and a supplied result sequence (XSDate, XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).
 int month()
          Retrieve the month from the date stored
static XSDate parse_date(java.lang.String str)
          Parses a String representation of a date (of the form year-month-day or year-month-day+timezone) and constructs a new XSDate representation of it.
 ResultSequence plus(ResultSequence arg)
          Mathematical addition operator between this XSDate and a supplied result sequence (XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).
 java.lang.String string_type()
          Retrive the datatype full pathname
 java.lang.String string_value()
          Retrieves a String representation of the date stored
 boolean timezoned()
          Retrieves whether this date has an optional timezone associated with it
 java.lang.String type_name()
          Retrieves the datatype name
 XDTDayTimeDuration tz()
          Retrieves the timezone associated with the date stored
 double value()
          Currently unsupported method.
 int year()
          Retrieve the year from the date stored
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSDate

public XSDate(java.util.Calendar cal,
              XDTDayTimeDuration tz)
Initialises a new represenation of a supplied date

Parameters:
cal - The Calendar representation of the date to be stored
tz - The timezone of the date to be stored.

XSDate

public XSDate()
Initialises a new representation of the current date

Method Detail

type_name

public java.lang.String type_name()
Retrieves the datatype name

Specified by:
type_name in class CtrType
Returns:
"date" which is the dataype name

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a copy of this date representation

Returns:
A copy of this date representation
Throws:
java.lang.CloneNotSupportedException

parse_date

public static XSDate parse_date(java.lang.String str)
Parses a String representation of a date (of the form year-month-day or year-month-day+timezone) and constructs a new XSDate representation of it.

Parameters:
str - The String representation of the date (and optional timezone)
Returns:
The XSDate representation of the supplied date

constructor

public ResultSequence constructor(ResultSequence arg)
                           throws DynamicError
Creates a new result sequence consisting of the retrievable date value in the supplied result sequence

Specified by:
constructor in class CtrType
Parameters:
arg - The result sequence from which to extract the date value.
Returns:
A new result sequence consisting of the date value supplied.
Throws:
DynamicError

year

public int year()
Retrieve the year from the date stored

Returns:
the year value of the date stored

month

public int month()
Retrieve the month from the date stored

Returns:
the month value of the date stored

day

public int day()
Retrieve the day from the date stored

Returns:
the day value of the date stored

timezoned

public boolean timezoned()
Retrieves whether this date has an optional timezone associated with it

Returns:
True if there is a timezone associated with this date. False otherwise.

string_value

public java.lang.String string_value()
Retrieves a String representation of the date stored

Specified by:
string_value in class AnyType
Returns:
String representation of the date stored

string_type

public java.lang.String string_type()
Retrive the datatype full pathname

Specified by:
string_type in class AnyType
Returns:
"xs:date" which is the datatype full pathname

calendar

public java.util.Calendar calendar()
Retrieves the Calendar representation of the date stored

Returns:
Calendar representation of the date stored

tz

public XDTDayTimeDuration tz()
Retrieves the timezone associated with the date stored

Returns:
the timezone associated with the date stored

eq

public boolean eq(AnyType arg)
           throws DynamicError
Equality comparison on this and the supplied dates (taking timezones into account)

Specified by:
eq in interface CmpEq
Parameters:
arg - XSDate representation of the date to compare to
Returns:
True if the two dates are represent the same exact point in time. False otherwise.
Throws:
DynamicError

lt

public boolean lt(AnyType arg)
           throws DynamicError
Comparison on this and the supplied dates (taking timezones into account)

Specified by:
lt in interface CmpLt
Parameters:
arg - XSDate representation of the date to compare to
Returns:
True if in time, this date lies before the date supplied. False otherwise.
Throws:
DynamicError

gt

public boolean gt(AnyType arg)
           throws DynamicError
Comparison on this and the supplied dates (taking timezones into account)

Specified by:
gt in interface CmpGt
Parameters:
arg - XSDate representation of the date to compare to
Returns:
True if in time, this date lies after the date supplied. False otherwise.
Throws:
DynamicError

value

public double value()
Currently unsupported method. Retrieves the date in milliseconds since the begining of epoch

Returns:
Number of milliseconds since the begining of the epoch

minus

public ResultSequence minus(ResultSequence arg)
                     throws DynamicError
Mathematical minus operator between this XSDate and a supplied result sequence (XSDate, XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).

Specified by:
minus in interface MathMinus
Parameters:
arg - The supplied ResultSequence that is on the right of the minus operator. If this is an XSDate, the result will be a XDTDayTimeDuration of the duration of time between these two dates. If arg is an XDTYearMonthDuration or an XDTDayTimeDuration the result will be a XSDate of the result of the current date minus the duration of time supplied.
Returns:
New ResultSequence consisting of the result of the mathematical minus operation.
Throws:
DynamicError - Dynamic error.

plus

public ResultSequence plus(ResultSequence arg)
                    throws DynamicError
Mathematical addition operator between this XSDate and a supplied result sequence (XDTYearMonthDuration and XDTDayTimeDuration are only valid ones).

Specified by:
plus in interface MathPlus
Parameters:
arg - The supplied ResultSequence that is on the right of the minus operator. If arg is an XDTYearMonthDuration or an XDTDayTimeDuration the result will be a XSDate of the result of the current date minus the duration of time supplied.
Returns:
New ResultSequence consisting of the result of the mathematical minus operation.
Throws:
DynamicError - Dynamic error.