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
CY
protected static final int CY
- 0
D
protected static final int D
- 2
DAY
protected static final int DAY
- 15
M
protected static final int M
- 1
MONTH
protected static final int MONTH
- 1
TOTAL_SIZE
protected static final int TOTAL_SIZE
- 8
YEAR
protected static final int YEAR
- 2000
h
protected static final int h
- 3
hh
protected static final int hh
- 0
m
protected static final int m
- 4
mm
protected static final int mm
- 1
ms
protected static final int ms
- 6
s
protected static final int s
- 5
utc
protected static final int utc
- 7
append
protected void append(StringBuffer message,
int value,
int nch)
compare
public int compare(Object value1,
Object value2)
- compare in interface TypeValidator
compareDates
protected short compareDates(int[] date1,
int[] 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(int[] date1,
int[] 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(int[] 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', '+', '-'
start
- end
-
- index of the UTC character that was found
getAllowedFacets
public short getAllowedFacets()
- getAllowedFacets in interface TypeValidator
getDate
protected int getDate(String buffer,
int start,
int end,
int[] date)
throws RuntimeException
Parses date CCYY-MM-DD
start
- end
-
getTime
protected void getTime(String buffer,
int start,
int end,
int[] data,
int[] timeZone)
throws RuntimeException
Parses time hh:mm:ss.sss and time zone if any
start
- end
- data
-
getTimeZone
protected void getTimeZone(String buffer,
int[] data,
int sign,
int end,
int[] timeZone)
throws RuntimeException
Parses time zone: 'Z' or {+,-} followed by hh:mm
data
- sign
-
getYearMonth
protected int getYearMonth(String buffer,
int start,
int end,
int[] date)
throws RuntimeException
Parses date CCYY-MM
start
- end
-
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
maxDayInMonthFor
protected int maxDayInMonthFor(int year,
int month)
Given {year,month} computes maximum
number of days for given month
year
- 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(int[] date,
int[] timeZone)
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
start
- Start positionend
- end position
- return integer representation of characters
parseIntYear
protected int parseIntYear(String buffer,
int end)
parseTimeZone
protected void parseTimeZone(String buffer,
int start,
int end,
int[] date,
int[] timeZone)
throws RuntimeException
Shared code from Date and YearMonth datatypes.
Finds if time zone sign is present
end
- date
-
resetDateObj
protected void resetDateObj(int[] data)
Resets object representation of date/time
data
- date/time object
validateDateTime
protected void validateDateTime(int[] data,
int[] timeZone)
Validates given date/time object accoring to W3C PR Schema
[D.1 ISO 8601 Conventions]
data
-