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
append
protected void append(StringBuffer message,
double value)
append
protected void append(StringBuffer message,
int value,
int nch)
compareDates
protected short compareDates(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date1,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date2,
boolean strict)
Compare algorithm described in dateDime (3.2.7).
Duration datatype overwrites this method
date1
- normalized date representation of the first valuedate2
- normalized date representation of the second valuestrict
-
- less, greater, less_equal, greater_equal, equal
compareOrder
protected short compareOrder(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date1,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date2)
Given normalized values, determines order-relation
between give date/time objects.
date1
- date/time objectdate2
- date/time object
- 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(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
fQuotient
protected int fQuotient(int a,
int b)
fQuotient
protected int fQuotient(int temp,
int low,
int high)
findUTCSign
protected int findUTCSign(String buffer,
int start,
int end)
Return index of UTC char: 'Z', '+', '-'
- index of the UTC character that was found
getDate
protected int getDate(String buffer,
int start,
int end,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
throws RuntimeException
Parses date CCYY-MM-DD
buffer
- start
- start positionend
- end positiondate
-
getDuration
protected Duration getDuration(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
getTime
protected void getTime(String buffer,
int start,
int end,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
throws RuntimeException
Parses time hh:mm:ss.sss and time zone if any
getTimeZone
protected void getTimeZone(String buffer,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data,
int sign,
int end)
throws RuntimeException
Parses time zone: 'Z' or {+,-} followed by hh:mm
getXMLGregorianCalendar
protected XMLGregorianCalendar getXMLGregorianCalendar(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
getYearMonth
protected int getYearMonth(String buffer,
int start,
int end,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
throws RuntimeException
Parses date CCYY-MM
buffer
- start
- start positionend
- end positiondate
-
indexOf
protected int indexOf(String buffer,
int start,
int end,
char ch)
Computes index of given char within StringBuffer
start
- end
- ch
- character to look for in StringBuffer
- index of ch within StringBuffer
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
- 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(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
If timezone present - normalize dateTime [E Adding durations to dateTimes]
date
- CCYY-MM-DDThh:mm:ss+03
parseInt
protected int parseInt(String buffer,
int start,
int end)
throws NumberFormatException
Given start and end position, parses string value
buffer
- string to parsestart
- start positionend
- end position
- return integer representation of characters
parseIntYear
protected int parseIntYear(String buffer,
int end)
parseSecond
protected double parseSecond(String buffer,
int start,
int end)
throws NumberFormatException
parseTimeZone
protected void parseTimeZone(String buffer,
int start,
int end,
org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
throws RuntimeException
Shared code from Date and YearMonth datatypes.
Finds if time zone sign is present
resetDateObj
protected void resetDateObj(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
Resets object representation of date/time
saveUnnormalized
protected void saveUnnormalized(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
validateDateTime
protected void validateDateTime(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
Validates given date/time object accoring to W3C PR Schema
[D.1 ISO 8601 Conventions]