APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.impl.dv.xs

public abstract Class AbstractDateTimeDV

extends TypeValidator
Class Inheritance
Known Direct Subclasses
com.sun.org.apache.xerces.internal.impl.dv.xs.DateTimeDV, com.sun.org.apache.xerces.internal.impl.dv.xs.DayDV, com.sun.org.apache.xerces.internal.impl.dv.xs.DurationDV, com.sun.org.apache.xerces.internal.impl.dv.xs.MonthDayDV, com.sun.org.apache.xerces.internal.impl.dv.xs.MonthDV, com.sun.org.apache.xerces.internal.impl.dv.xs.TimeDV, com.sun.org.apache.xerces.internal.impl.dv.xs.YearDV, com.sun.org.apache.xerces.internal.impl.dv.xs.YearMonthDV
Imports
java.math.BigDecimal, javax.xml.datatype.DatatypeFactory, .Duration, .XMLGregorianCalendar, com.sun.org.apache.xerces.internal.impl.Constants, com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl, com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime

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

Authors
Elena Litani, Len Berman, Gopal Sharma, SUN Microsystems Inc.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
AbstractDateTimeDV.DateTimeData

Represents date time data

Field Summary

Modifier and TypeField and Description
protected static final DatatypeFactory
protected static final int
private static final boolean
protected static final int
protected static final int
Inherited from com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator:
EQUALGREATER_THANINDETERMINATELESS_THAN

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final void
append(StringBuffer message, int value, int nch)

protected final void
append(StringBuffer message, double value)

protected final void
append2(StringBuffer message, double value)

private void
append3(StringBuffer message, double value)

private void
public int
protected short

Returns:

less, greater, less_equal, greater_equal, equal
compareDates
(AbstractDateTimeDV.DateTimeData
normalized date representation of the first value
date1
,
AbstractDateTimeDV.DateTimeData
normalized date representation of the second value
date2
,
boolean strict)

Compare algorithm described in dateDime (3.2.7).

protected short

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
compareOrder
(AbstractDateTimeDV.DateTimeData
date/time object
date1
,
AbstractDateTimeDV.DateTimeData
date/time object
date2
)

Given normalized values, determines order-relation between give date/time objects.

protected String
protected int

Returns:

index of the UTC character that was found
findUTCSign
(String buffer, int start, int end)

Return index of UTC char: 'Z', '+', '-'

protected int
fQuotient(int a, int b)

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

public short
protected int
getDate(String buffer, int
start position
start
,
int
end position
end
,
AbstractDateTimeDV.DateTimeData date)

Parses date CCYY-MM-DD

protected Duration
protected final BigDecimal
protected void
getTime(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData data)

Parses time hh:mm:ss.sss and time zone if any

protected void
getTimeZone(String buffer, AbstractDateTimeDV.DateTimeData data, int sign, int end)

Parses time zone: 'Z' or {+,-} followed by hh:mm

protected XMLGregorianCalendar
protected int
getYearMonth(String buffer, int
start position
start
,
int
end position
end
,
AbstractDateTimeDV.DateTimeData date)

Parses date CCYY-MM

protected int

Returns:

index of ch within StringBuffer
indexOf
(String buffer, int start, int end, char
character to look for in StringBuffer
ch
)

Computes index of given char within StringBuffer

public boolean
private boolean
isLeapYear(int year)

protected final boolean
isNextCharUTCSign(String buffer, int start, int end)

Returns true if the character at start is 'Z', '+' or '-'.

protected int

Returns:

integer containg the number of days in a given month
maxDayInMonthFor
(int year, int month)

Given {year,month} computes maximum number of days for given month

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

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

protected void
normalize(AbstractDateTimeDV.DateTimeData
CCYY-MM-DDThh:mm:ss+03
date
)

If timezone present - normalize dateTime [E Adding durations to dateTimes]

protected int

Returns:

return integer representation of characters
parseInt
(String
string to parse
buffer
,
int
start position
start
,
int
end position
end
)

Given start and end position, parses string value

protected int
parseIntYear(String buffer, int end)

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

protected void
parseTimeZone(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date)

Shared code from Date and YearMonth datatypes.

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

Resets object representation of date/time

protected void
protected void
validateDateTime(AbstractDateTimeDV.DateTimeData data)

Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601 Conventions]

Inherited from com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator:
checkExtraRulesgetActualValuegetDataLengthgetDigitgetFractionDigitsgetTotalDigitsisDigit

Field Detail

datatypeFactoryback to summary
protected static final DatatypeFactory datatypeFactory
DAYback to summary
protected static final int DAY
DEBUGback to summary
private static final boolean DEBUG
MONTHback to summary
protected static final int MONTH
YEARback to summary
protected static final int YEAR

Constructor Detail

AbstractDateTimeDVback to summary
public AbstractDateTimeDV()

Method Detail

appendback to summary
protected final void append(StringBuffer message, int value, int nch)
appendback to summary
protected final void append(StringBuffer message, double value)
append2back to summary
protected final void append2(StringBuffer message, double value)
append3back to summary
private void append3(StringBuffer message, double value)
cloneDateback to summary
private void cloneDate(AbstractDateTimeDV.DateTimeData finalValue, AbstractDateTimeDV.DateTimeData tempDate)
compareback to summary
public int compare(Object value1, Object value2)

Overrides com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator.compare.

Annotations
@Override
compareDatesback to summary
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:AbstractDateTimeDV.DateTimeData

normalized date representation of the first value

date2:AbstractDateTimeDV.DateTimeData

normalized date representation of the second value

Returns:short

less, greater, less_equal, greater_equal, equal

compareOrderback to summary
protected short compareOrder(AbstractDateTimeDV.DateTimeData date1, AbstractDateTimeDV.DateTimeData date2)

Given normalized values, determines order-relation between give date/time objects.

Parameters
date1:AbstractDateTimeDV.DateTimeData

date/time object

date2:AbstractDateTimeDV.DateTimeData

date/time object

Returns:short

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

dateToStringback to summary
protected String dateToString(AbstractDateTimeDV.DateTimeData date)
findUTCSignback to summary
protected int findUTCSign(String buffer, int start, int end)

Return index of UTC char: 'Z', '+', '-'

Returns:int

index of the UTC character that was found

fQuotientback to summary
protected int fQuotient(int a, int b)
fQuotientback to summary
protected int fQuotient(int temp, int low, int high)
getAllowedFacetsback to summary
public short getAllowedFacets()

Implements abstract com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator.getAllowedFacets.

Annotations
@Override
getDateback to summary
protected int getDate(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date) throws RuntimeException

Parses date CCYY-MM-DD

Parameters
start:int

start position

end:int

end position

getDurationback to summary
protected Duration getDuration(AbstractDateTimeDV.DateTimeData data)
getFractionalSecondsAsBigDecimalback to summary
protected final BigDecimal getFractionalSecondsAsBigDecimal(AbstractDateTimeDV.DateTimeData data)
getTimeback to summary
protected void getTime(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData data) throws RuntimeException

Parses time hh:mm:ss.sss and time zone if any

getTimeZoneback to summary
protected void getTimeZone(String buffer, AbstractDateTimeDV.DateTimeData data, int sign, int end) throws RuntimeException

Parses time zone: 'Z' or {+,-} followed by hh:mm

getXMLGregorianCalendarback to summary
protected XMLGregorianCalendar getXMLGregorianCalendar(AbstractDateTimeDV.DateTimeData data)
getYearMonthback to summary
protected int getYearMonth(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date) throws RuntimeException

Parses date CCYY-MM

Parameters
start:int

start position

end:int

end position

indexOfback to summary
protected int indexOf(String buffer, int start, int end, char ch)

Computes index of given char within StringBuffer

Parameters
ch:char

character to look for in StringBuffer

Returns:int

index of ch within StringBuffer

isIdenticalback to summary
public boolean isIdentical(Object value1, Object value2)

Overrides com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator.isIdentical.

Annotations
@Override
isLeapYearback to summary
private boolean isLeapYear(int year)
isNextCharUTCSignback to summary
protected final boolean isNextCharUTCSign(String buffer, int start, int end)

Returns true if the character at start is 'Z', '+' or '-'.

maxDayInMonthForback to summary
protected int maxDayInMonthFor(int year, int month)

Given {year,month} computes maximum number of days for given month

Returns:int

integer containg the number of days in a given month

modback to summary
protected int mod(int a, int b, int quotient)
moduloback to summary
protected int modulo(int temp, int low, int high)
normalizeback to summary
protected void normalize(AbstractDateTimeDV.DateTimeData date)

If timezone present - normalize dateTime [E Adding durations to dateTimes]

Parameters
date:AbstractDateTimeDV.DateTimeData

CCYY-MM-DDThh:mm:ss+03

parseIntback to summary
protected int parseInt(String buffer, int start, int end) throws NumberFormatException

Given start and end position, parses string value

Parameters
buffer:String

string to parse

start:int

start position

end:int

end position

Returns:int

return integer representation of characters

parseIntYearback to summary
protected int parseIntYear(String buffer, int end)
parseSecondback to summary
protected double parseSecond(String buffer, int start, int end) throws NumberFormatException
parseTimeZoneback to summary
protected void parseTimeZone(String buffer, int start, int end, AbstractDateTimeDV.DateTimeData date) throws RuntimeException

Shared code from Date and YearMonth datatypes. Finds if time zone sign is present

resetDateObjback to summary
protected void resetDateObj(AbstractDateTimeDV.DateTimeData data)

Resets object representation of date/time

Parameters
data:AbstractDateTimeDV.DateTimeData

date/time object

saveUnnormalizedback to summary
protected void saveUnnormalized(AbstractDateTimeDV.DateTimeData date)
validateDateTimeback to summary
protected void validateDateTime(AbstractDateTimeDV.DateTimeData data)

Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601 Conventions]

com.sun.org.apache.xerces.internal.impl.dv.xs back to summary

pack-priv final Class AbstractDateTimeDV.DateTimeData

extends Object
implements XSDateTime
Class Inheritance
  • java.lang.Object
  • com.sun.org.apache.xerces.internal.impl.dv.xs.AbstractDateTimeDV.DateTimeData
All Implemented Interfaces
com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime

Represents date time data

Field Summary

Modifier and TypeField and Description
private volatile String
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv boolean
private String
pack-priv int
pack-priv double
pack-priv int
pack-priv int
pack-priv final AbstractDateTimeDV
pack-priv int
pack-priv int
pack-priv int
pack-priv int
pack-priv double
pack-priv int
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
public
DateTimeData(String originalValue, AbstractDateTimeDV type)

public
DateTimeData(int year, int month, int day, int hour, int minute, double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type)

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
public Duration
public int
public String
public int
public int
public double
public int
public int
public XMLGregorianCalendar
public int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public boolean
public XSDateTime
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

canonicalback to summary
private volatile String canonical
dayback to summary
pack-priv int day
hourback to summary
pack-priv int hour
minuteback to summary
pack-priv int minute
monthback to summary
pack-priv int month
normalizedback to summary
pack-priv boolean normalized
originalValueback to summary
private String originalValue
positionback to summary
pack-priv int position
secondback to summary
pack-priv double second
timezoneHrback to summary
pack-priv int timezoneHr
timezoneMinback to summary
pack-priv int timezoneMin
typeback to summary
pack-priv final AbstractDateTimeDV type
unNormDayback to summary
pack-priv int unNormDay
unNormHourback to summary
pack-priv int unNormHour
unNormMinuteback to summary
pack-priv int unNormMinute
unNormMonthback to summary
pack-priv int unNormMonth
unNormSecondback to summary
pack-priv double unNormSecond
unNormYearback to summary
pack-priv int unNormYear
utcback to summary
pack-priv int utc
yearback to summary
pack-priv int year

Constructor Detail

DateTimeDataback to summary
public DateTimeData(String originalValue, AbstractDateTimeDV type)
DateTimeDataback to summary
public DateTimeData(int year, int month, int day, int hour, int minute, double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type)

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getDaysback to summary
public int getDays()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getDays.

Annotations
@Override
getDurationback to summary
public Duration getDuration()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getDuration.

Annotations
@Override
getHoursback to summary
public int getHours()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getHours.

Annotations
@Override
getLexicalValueback to summary
public String getLexicalValue()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getLexicalValue.

Annotations
@Override
getMinutesback to summary
public int getMinutes()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getMinutes.

Annotations
@Override
getMonthsback to summary
public int getMonths()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getMonths.

Annotations
@Override
getSecondsback to summary
public double getSeconds()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getSeconds.

Annotations
@Override
getTimeZoneHoursback to summary
public int getTimeZoneHours()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getTimeZoneHours.

Annotations
@Override
getTimeZoneMinutesback to summary
public int getTimeZoneMinutes()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getTimeZoneMinutes.

Annotations
@Override
getXMLGregorianCalendarback to summary
public XMLGregorianCalendar getXMLGregorianCalendar()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getXMLGregorianCalendar.

Annotations
@Override
getYearsback to summary
public int getYears()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.getYears.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
hasTimeZoneback to summary
public boolean hasTimeZone()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.hasTimeZone.

Annotations
@Override
isNormalizedback to summary
public boolean isNormalized()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.isNormalized.

Annotations
@Override
normalizeback to summary
public XSDateTime normalize()

Implements com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime.normalize.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override