Top Description Inners Fields Constructors Methods
org.apache.xerces.impl.dv.xs

public abstract Class AbstractDateTimeDV

extends TypeValidator
Class Inheritance
Known Direct Subclasses
org.apache.xerces.impl.dv.xs.DateTimeDV, org.apache.xerces.impl.dv.xs.DayDV, org.apache.xerces.impl.dv.xs.DurationDV, org.apache.xerces.impl.dv.xs.MonthDayDV, org.apache.xerces.impl.dv.xs.MonthDV, org.apache.xerces.impl.dv.xs.TimeDV, org.apache.xerces.impl.dv.xs.YearDV, org.apache.xerces.impl.dv.xs.YearMonthDV
Imports
java.math.BigDecimal, javax.xml.datatype.DatatypeFactory, .Duration, .XMLGregorianCalendar, org.apache.xerces.impl.Constants, org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl, org.apache.xerces.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.
Version
$Id: AbstractDateTimeDV.java 965250 2010-07-18 16:04:58Z mrglavas $

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 org.apache.xerces.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 org.apache.xerces.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 org.apache.xerces.impl.dv.xs.TypeValidator.compare.

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 org.apache.xerces.impl.dv.xs.TypeValidator.getAllowedFacets.

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 org.apache.xerces.impl.dv.xs.TypeValidator.isIdentical.

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]

org.apache.xerces.impl.dv.xs back to summary

pack-priv final Class AbstractDateTimeDV.DateTimeData

extends Object
implements XSDateTime
Class Inheritance
All Implemented Interfaces
org.apache.xerces.xs.datatypes.XSDateTime

Represents date time data

Field Summary

Modifier and TypeField and Description
private 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
the reference object with which to compare.
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 boolean
public boolean
public XSDateTime
public synchronized String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
finalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

canonicalback to summary
private 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.

Returns:Object

a clone of this instance.

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.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getDaysback to summary
public int getDays()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getDays.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getDays.

days - cannot be negative;

getDurationback to summary
public Duration getDuration()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getDuration.

Returns:Duration

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getDuration.

a Duration (if applicable otherwise null)

getHoursback to summary
public int getHours()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getHours.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getHours.

hours - cannot be negative;

getLexicalValueback to summary
public String getLexicalValue()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getLexicalValue.

Returns:String

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getLexicalValue.

the original lexical value

getMinutesback to summary
public int getMinutes()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getMinutes.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getMinutes.

minutes - cannot be negative;

getMonthsback to summary
public int getMonths()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getMonths.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getMonths.

months - can be negative only for duration types; For duration types, it returns years*12 + months

getSecondsback to summary
public double getSeconds()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getSeconds.

Returns:double

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getSeconds.

seconds - can be negative only for durations; For duration types, it returns days*24*3600 + hours*3600 + minutes*60 + seconds

getTimeZoneHoursback to summary
public int getTimeZoneHours()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getTimeZoneHours.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getTimeZoneHours.

timezone hours (for GMT-xx:xx this will be negative),

getTimeZoneMinutesback to summary
public int getTimeZoneMinutes()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getTimeZoneMinutes.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getTimeZoneMinutes.

timezone minutes (for GMT-xx:xx this will be negative),

getXMLGregorianCalendarback to summary
public XMLGregorianCalendar getXMLGregorianCalendar()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getXMLGregorianCalendar.

Returns:XMLGregorianCalendar

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getXMLGregorianCalendar.

an un-normalized XMLGregorianCalendar (if applicable otherwise null)

getYearsback to summary
public int getYears()

Implements org.apache.xerces.xs.datatypes.XSDateTime.getYears.

Returns:int

Doc from org.apache.xerces.xs.datatypes.XSDateTime.getYears.

years - can be negative for date-time related types;

hasTimeZoneback to summary
public boolean hasTimeZone()

Implements org.apache.xerces.xs.datatypes.XSDateTime.hasTimeZone.

Returns:boolean

Doc from org.apache.xerces.xs.datatypes.XSDateTime.hasTimeZone.

boolean (true when timezone is specified in the original lexical value)

isNormalizedback to summary
public boolean isNormalized()

Implements org.apache.xerces.xs.datatypes.XSDateTime.isNormalized.

Returns:boolean

Doc from org.apache.xerces.xs.datatypes.XSDateTime.isNormalized.

whether a date-time related object is normalized or not (value is not useful for types where timezone is not specified)

normalizeback to summary
public XSDateTime normalize()

Implements org.apache.xerces.xs.datatypes.XSDateTime.normalize.

Returns:XSDateTime

Doc from org.apache.xerces.xs.datatypes.XSDateTime.normalize.

a new date-time related object with normalized values (has no effect on objects already normalized)

toStringback to summary
public synchronized String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.