org.apache.xerces.impl.dv.xs

Class AbstractDateTimeDV

public abstract class AbstractDateTimeDV extends TypeValidator

This is the base class of all date/time datatype validators. It implements common code for parsing, validating and comparing datatypes. Classes that extend this class, must implement parse() method. REVISIT: There are many instance variables, which would cause problems when we support grammar caching. A grammar is possibly used by two parser instances at the same time, then the same simple type decl object can be used to validate two strings at the same time. -SG

Version: $Id: AbstractDateTimeDV.java,v 1.40 2005/07/19 04:32:40 mrglavas Exp $

Author: Elena Litani Len Berman Gopal Sharma, SUN Microsystems Inc.

UNKNOWN:

Field Summary
protected static intDAY
protected DatatypeFactoryfactory
protected static intMONTH
protected static intYEAR
Method Summary
protected voidappend(StringBuffer message, int value, int nch)
protected voidappend(StringBuffer message, double value)
intcompare(Object value1, Object value2)
protected shortcompareDates(AbstractDateTimeDV.DateTimeData date1, AbstractDateTimeDV.DateTimeData date2, boolean strict)
Compare algorithm described in dateDime (3.2.7).
protected shortcompareOrder(AbstractDateTimeDV.DateTimeData date1, AbstractDateTimeDV.DateTimeData date2)
Given normalized values, determines order-relation between give date/time objects.
protected StringdateToString(AbstractDateTimeDV.DateTimeData date)
protected intfindUTCSign(String buffer, int start, int end)
Return index of UTC char: 'Z', '+', '-'
protected intfQuotient(int a, int b)
protected intfQuotient(int temp, int low, int high)
shortgetAllowedFacets()
protected intgetDate(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)
Parses date CCYY-MM-DD
protected DurationgetDuration(AbstractDateTimeDV.DateTimeData data)
protected voidgetTime(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData data)
Parses time hh:mm:ss.sss and time zone if any
protected voidgetTimeZone(String buffer, AbstractDateTimeDV.DateTimeData data, int sign, int end)
Parses time zone: 'Z' or {+,-} followed by hh:mm
protected XMLGregorianCalendargetXMLGregorianCalendar(AbstractDateTimeDV.DateTimeData data)
protected intgetYearMonth(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)
Parses date CCYY-MM
protected intindexOf(String buffer, int start, int end, char ch)
Computes index of given char within StringBuffer
booleanisIdentical(Object value1, Object value2)
protected booleanisNextCharUTCSign(String buffer, int start, int end)
Returns true if the character at start is 'Z', '+' or '-'.
protected intmaxDayInMonthFor(int year, int month)
Given {year,month} computes maximum number of days for given month
protected intmod(int a, int b, int quotient)
protected intmodulo(int temp, int low, int high)
protected voidnormalize(AbstractDateTimeDV.DateTimeData date)
If timezone present - normalize dateTime [E Adding durations to dateTimes]
protected intparseInt(String buffer, int start, int end)
Given start and end position, parses string value
protected intparseIntYear(String buffer, int end)
protected doubleparseSecond(String buffer, int start, int end)
protected voidparseTimeZone(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)
Shared code from Date and YearMonth datatypes.
protected voidresetDateObj(AbstractDateTimeDV.DateTimeData data)
Resets object representation of date/time
protected voidsaveUnnormalized(AbstractDateTimeDV.DateTimeData date)
protected voidvalidateDateTime(AbstractDateTimeDV.DateTimeData data)
Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601 Conventions]

Field Detail

DAY

protected static final int DAY

factory

protected DatatypeFactory factory

MONTH

protected static final int MONTH

YEAR

protected static final int YEAR

Method Detail

append

protected void append(StringBuffer message, int value, int nch)

append

protected void append(StringBuffer message, double value)

compare

public int compare(Object value1, Object value2)

compareDates

protected short compareDates(AbstractDateTimeDV.DateTimeData date1, AbstractDateTimeDV.DateTimeData date2, boolean strict)
Compare algorithm described in dateDime (3.2.7). Duration datatype overwrites this method

Parameters: date1 normalized date representation of the first value date2 normalized date representation of the second value strict

Returns: less, greater, less_equal, greater_equal, equal

compareOrder

protected short compareOrder(AbstractDateTimeDV.DateTimeData date1, AbstractDateTimeDV.DateTimeData date2)
Given normalized values, determines order-relation between give date/time objects.

Parameters: date1 date/time object date2 date/time object

Returns: 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2

dateToString

protected String dateToString(AbstractDateTimeDV.DateTimeData date)

findUTCSign

protected int findUTCSign(String buffer, int start, int end)
Return index of UTC char: 'Z', '+', '-'

Parameters: start end

Returns: index of the UTC character that was found

fQuotient

protected int fQuotient(int a, int b)

fQuotient

protected int fQuotient(int temp, int low, int high)

getAllowedFacets

public short getAllowedFacets()

getDate

protected int getDate(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)
Parses date CCYY-MM-DD

Parameters: buffer start start position end end position date

Throws: RuntimeException

getDuration

protected Duration getDuration(AbstractDateTimeDV.DateTimeData data)

getTime

protected void getTime(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData data)
Parses time hh:mm:ss.sss and time zone if any

Parameters: start end data

Throws: RuntimeException

getTimeZone

protected void getTimeZone(String buffer, AbstractDateTimeDV.DateTimeData data, int sign, int end)
Parses time zone: 'Z' or {+,-} followed by hh:mm

Parameters: data sign

Throws: RuntimeException

getXMLGregorianCalendar

protected XMLGregorianCalendar getXMLGregorianCalendar(AbstractDateTimeDV.DateTimeData data)

getYearMonth

protected int getYearMonth(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)
Parses date CCYY-MM

Parameters: buffer start start position end end position date

Throws: RuntimeException

indexOf

protected int indexOf(String buffer, int start, int end, char ch)
Computes index of given char within StringBuffer

Parameters: start end ch character to look for in StringBuffer

Returns: index of ch within StringBuffer

isIdentical

public boolean isIdentical(Object value1, Object value2)

isNextCharUTCSign

protected final boolean isNextCharUTCSign(String buffer, int start, int end)
Returns true if the character at start is 'Z', '+' or '-'.

maxDayInMonthFor

protected int maxDayInMonthFor(int year, int month)
Given {year,month} computes maximum number of days for given month

Parameters: year month

Returns: integer containg the number of days in a given month

mod

protected int mod(int a, int b, int quotient)

modulo

protected int modulo(int temp, int low, int high)

normalize

protected void normalize(AbstractDateTimeDV.DateTimeData date)
If timezone present - normalize dateTime [E Adding durations to dateTimes]

Parameters: date CCYY-MM-DDThh:mm:ss+03

Returns: CCYY-MM-DDThh:mm:ssZ

parseInt

protected int parseInt(String buffer, int start, int end)
Given start and end position, parses string value

Parameters: buffer string to parse start start position end end position

Returns: return integer representation of characters

parseIntYear

protected int parseIntYear(String buffer, int end)

parseSecond

protected double parseSecond(String buffer, int start, int end)

parseTimeZone

protected void parseTimeZone(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)
Shared code from Date and YearMonth datatypes. Finds if time zone sign is present

Parameters: end date

Throws: RuntimeException

resetDateObj

protected void resetDateObj(AbstractDateTimeDV.DateTimeData data)
Resets object representation of date/time

Parameters: data date/time object

saveUnnormalized

protected void saveUnnormalized(AbstractDateTimeDV.DateTimeData date)

Parameters: date

validateDateTime

protected void validateDateTime(AbstractDateTimeDV.DateTimeData data)
Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601 Conventions]

Parameters: data

Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.