Package org.apache.xerces.impl.dv.xs
Class AbstractDateTimeDV
- java.lang.Object
-
- org.apache.xerces.impl.dv.xs.TypeValidator
-
- org.apache.xerces.impl.dv.xs.AbstractDateTimeDV
-
- Direct Known Subclasses:
DateTimeDV,DayDV,DurationDV,MonthDayDV,MonthDV,TimeDV,YearDV,YearMonthDV
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. -SGINTERNAL:
- Usage of this class is not supported. It may be altered or removed at any time.
- Version:
- $Id: AbstractDateTimeDV.java 965250 2010-07-18 16:04:58Z mrglavas $
- Author:
- Elena Litani, Len Berman, Gopal Sharma, SUN Microsystems Inc.
-
-
Field Summary
Fields Modifier and Type Field Description protected static javax.xml.datatype.DatatypeFactorydatatypeFactoryprotected static intDAYprotected static intMONTHprotected static intYEAR-
Fields inherited from class org.apache.xerces.impl.dv.xs.TypeValidator
EQUAL, GREATER_THAN, INDETERMINATE, LESS_THAN
-
-
Constructor Summary
Constructors Constructor Description AbstractDateTimeDV()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappend(java.lang.StringBuffer message, double value)protected voidappend(java.lang.StringBuffer message, int value, int nch)protected voidappend2(java.lang.StringBuffer message, double value)intcompare(java.lang.Object value1, java.lang.Object value2)protected shortcompareDates(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).protected shortcompareOrder(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.protected java.lang.StringdateToString(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)protected intfindUTCSign(java.lang.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(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)Parses date CCYY-MM-DDprotected javax.xml.datatype.DurationgetDuration(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)protected java.math.BigDecimalgetFractionalSecondsAsBigDecimal(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)protected voidgetTime(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)Parses time hh:mm:ss.sss and time zone if anyprotected voidgetTimeZone(java.lang.String buffer, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data, int sign, int end)Parses time zone: 'Z' or {+,-} followed by hh:mmprotected javax.xml.datatype.XMLGregorianCalendargetXMLGregorianCalendar(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)protected intgetYearMonth(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)Parses date CCYY-MMprotected intindexOf(java.lang.String buffer, int start, int end, char ch)Computes index of given char within StringBufferbooleanisIdentical(java.lang.Object value1, java.lang.Object value2)protected booleanisNextCharUTCSign(java.lang.String buffer, int start, int end)Returnstrueif the character at start is 'Z', '+' or '-'.protected intmaxDayInMonthFor(int year, int month)Given {year,month} computes maximum number of days for given monthprotected intmod(int a, int b, int quotient)protected intmodulo(int temp, int low, int high)protected voidnormalize(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)If timezone present - normalize dateTime [E Adding durations to dateTimes]protected intparseInt(java.lang.String buffer, int start, int end)Given start and end position, parses string valueprotected intparseIntYear(java.lang.String buffer, int end)protected doubleparseSecond(java.lang.String buffer, int start, int end)protected voidparseTimeZone(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)Shared code from Date and YearMonth datatypes.protected voidresetDateObj(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)Resets object representation of date/timeprotected voidsaveUnnormalized(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)protected voidvalidateDateTime(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601 Conventions]-
Methods inherited from class org.apache.xerces.impl.dv.xs.TypeValidator
checkExtraRules, getActualValue, getDataLength, getDigit, getFractionDigits, getTotalDigits, isDigit
-
-
-
-
Field Detail
-
YEAR
protected static final int YEAR
- See Also:
- Constant Field Values
-
MONTH
protected static final int MONTH
- See Also:
- Constant Field Values
-
DAY
protected static final int DAY
- See Also:
- Constant Field Values
-
datatypeFactory
protected static final javax.xml.datatype.DatatypeFactory datatypeFactory
-
-
Method Detail
-
getAllowedFacets
public short getAllowedFacets()
- Specified by:
getAllowedFacetsin classTypeValidator
-
isIdentical
public boolean isIdentical(java.lang.Object value1, java.lang.Object value2)- Overrides:
isIdenticalin classTypeValidator
-
compare
public int compare(java.lang.Object value1, java.lang.Object value2)- Overrides:
comparein classTypeValidator
-
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- Parameters:
date1- normalized date representation of the first valuedate2- normalized date representation of the second valuestrict-- Returns:
- 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.- Parameters:
date1- date/time objectdate2- 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
-
getTime
protected void getTime(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data) throws java.lang.RuntimeExceptionParses time hh:mm:ss.sss and time zone if any- Parameters:
start-end-data-- Throws:
java.lang.RuntimeException
-
getDate
protected int getDate(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date) throws java.lang.RuntimeExceptionParses date CCYY-MM-DD- Parameters:
buffer-start- start positionend- end positiondate-- Throws:
java.lang.RuntimeException
-
getYearMonth
protected int getYearMonth(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date) throws java.lang.RuntimeExceptionParses date CCYY-MM- Parameters:
buffer-start- start positionend- end positiondate-- Throws:
java.lang.RuntimeException
-
parseTimeZone
protected void parseTimeZone(java.lang.String buffer, int start, int end, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date) throws java.lang.RuntimeExceptionShared code from Date and YearMonth datatypes. Finds if time zone sign is present- Parameters:
end-date-- Throws:
java.lang.RuntimeException
-
getTimeZone
protected void getTimeZone(java.lang.String buffer, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data, int sign, int end) throws java.lang.RuntimeExceptionParses time zone: 'Z' or {+,-} followed by hh:mm- Parameters:
data-sign-- Throws:
java.lang.RuntimeException
-
indexOf
protected int indexOf(java.lang.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
-
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]- Parameters:
data-
-
findUTCSign
protected int findUTCSign(java.lang.String buffer, int start, int end)Return index of UTC char: 'Z', '+', '-'- Parameters:
start-end-- Returns:
- index of the UTC character that was found
-
isNextCharUTCSign
protected final boolean isNextCharUTCSign(java.lang.String buffer, int start, int end)Returnstrueif the character at start is 'Z', '+' or '-'.
-
parseInt
protected int parseInt(java.lang.String buffer, int start, int end) throws java.lang.NumberFormatExceptionGiven start and end position, parses string value- Parameters:
buffer- string to parsestart- start positionend- end position- Returns:
- return integer representation of characters
- Throws:
java.lang.NumberFormatException
-
parseIntYear
protected int parseIntYear(java.lang.String buffer, int end)
-
normalize
protected void normalize(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
If timezone present - normalize dateTime [E Adding durations to dateTimes]- Parameters:
date- CCYY-MM-DDThh:mm:ss+03
-
saveUnnormalized
protected void saveUnnormalized(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
- Parameters:
date-
-
resetDateObj
protected void resetDateObj(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
Resets object representation of date/time- Parameters:
data- date/time object
-
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)
-
fQuotient
protected int fQuotient(int a, int b)
-
modulo
protected int modulo(int temp, int low, int high)
-
fQuotient
protected int fQuotient(int temp, int low, int high)
-
dateToString
protected java.lang.String dateToString(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData date)
-
append
protected final void append(java.lang.StringBuffer message, int value, int nch)
-
append
protected final void append(java.lang.StringBuffer message, double value)
-
append2
protected final void append2(java.lang.StringBuffer message, double value)
-
parseSecond
protected double parseSecond(java.lang.String buffer, int start, int end) throws java.lang.NumberFormatException- Throws:
java.lang.NumberFormatException
-
getXMLGregorianCalendar
protected javax.xml.datatype.XMLGregorianCalendar getXMLGregorianCalendar(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
-
getDuration
protected javax.xml.datatype.Duration getDuration(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
-
getFractionalSecondsAsBigDecimal
protected final java.math.BigDecimal getFractionalSecondsAsBigDecimal(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData data)
-
-