public abstract class CalendarValue extends AtomicValue implements AtomicMatchKey
Modifier and Type | Field and Description |
---|---|
static int |
MISSING_TIMEZONE
The value MISSING_TIMEZONE is returned as the value of implicit-timezone() if the context has no
known value for the implicit timezone, which typically arises when early (compile-time) evaluation
is attempted.
|
static int |
NO_TIMEZONE
The value NO_TIMEZONE is used in a value that has no timezone, and it can be passed as an argument
to a comparison operation if a value with no timezone is to be matched.
|
NaN_MATCH_KEY, typeLabel
Constructor and Description |
---|
CalendarValue() |
Modifier and Type | Method and Description |
---|---|
abstract CalendarValue |
add(DurationValue duration)
Add a duration to this date/time value
|
CalendarValue |
adjustTimezone(DayTimeDurationValue tz)
Return a new date, time, or dateTime with the same normalized value, but
in a different timezone, specified as a dayTimeDuration
|
abstract CalendarValue |
adjustTimezone(int tz)
Return a new date, time, or dateTime with the same normalized value, but
in a different timezone
|
void |
appendTimezone(FastStringBuffer sb)
Add a string representation of the timezone, typically
formatted as "Z" or "+03:00" or "-10:00", to a supplied
string buffer
|
static void |
appendTimezone(int tz,
FastStringBuffer sb)
Format a timezone and append it to a buffer
|
AtomicMatchKey |
asMapKey()
Get a value whose equals() method follows the "same key" rules for comparing the keys of a map.
|
abstract int |
compareTo(CalendarValue other,
int implicitTimezone)
Compare this value to another value of the same type, using the supplied implicit timezone if required.
|
abstract GregorianCalendar |
getCalendar()
Get a Java Calendar object that represents this date/time value.
|
AtomicMatchKey |
getComparisonKey(XPathContext context)
Method retained only because it is used in a test case
|
int |
getTimezoneInMinutes()
Get the timezone value held in this object.
|
XMLGregorianCalendar |
getXMLGregorianCalendar()
Get an XMLGregorianCalendar object that represents this date/time value The object
will be newly created for the purpose
|
AtomicMatchKey |
getXPathComparable(boolean ordered,
StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
boolean |
hasTimezone()
Determine whether this value includes a timezone
|
int |
identityHashCode()
Get a hashCode that offers the guarantee that if A.isIdentical(B), then A.identityHashCode() == B.identityHashCode()
|
boolean |
isIdentical(AtomicValue v)
Determine whether two atomic values are identical, as determined by XML Schema rules.
|
static ConversionResult |
makeCalendarValue(CharSequence s,
ConversionRules rules)
Parse a string to create a CalendarValue whose actual type will depend on the format of the string
|
CalendarValue |
removeTimezone()
Return a date, time, or dateTime with the same localized value, but
without the timezone component
|
void |
setTimezoneInMinutes(int minutes)
Modify the timezone value held in this object.
|
DayTimeDurationValue |
subtract(CalendarValue other,
XPathContext context)
Determine the difference between two points in time, as a duration
|
abstract DateTimeValue |
toDateTime()
Convert the value to a DateTime, retaining all the components that are actually present, and
substituting conventional values for components that are missing
|
asAtomic, atomize, checkPermittedContents, copyAsSubType, effectiveBooleanValue, equals, getCanonicalLexicalRepresentation, getCardinality, getComponent, getItemType, getPrimitiveStringValue, getPrimitiveType, getSchemaComparable, getStringValue, getStringValueCS, getUType, head, isIdentical, isNaN, itemAt, iterate, iterator, process, setTypeLabel, toString
getLength, reduce, subsequence
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asAtomic
getLength
reduce, subsequence
public static final int NO_TIMEZONE
public static final int MISSING_TIMEZONE
public static ConversionResult makeCalendarValue(CharSequence s, ConversionRules rules)
s
- a string in the lexical space of one of the date/time types (date, time, dateTime,
gYearMonth, gYear, gMonth, gMonthDay, or gDayrules
- public final boolean hasTimezone()
public final void setTimezoneInMinutes(int minutes)
minutes
- The timezone offset from GMT in minutes, positive or negative; or the special
value NO_TIMEZONE indicating that the value is not in a timezone (this is the default if this
method is not called)public abstract DateTimeValue toDateTime()
public final int getTimezoneInMinutes()
public abstract GregorianCalendar getCalendar()
public XMLGregorianCalendar getXMLGregorianCalendar()
public abstract CalendarValue add(DurationValue duration) throws XPathException
duration
- the duration to be added (which might be negative)XPathException
public DayTimeDurationValue subtract(CalendarValue other, XPathContext context) throws XPathException
other
- the other point in timecontext
- the dynamic context, used to obtain timezone information. May be set to null
only if both values contain an explicit timezone, or if neither does so.XPathException
- for example if one value is a date and the other is a timepublic final CalendarValue removeTimezone()
public abstract CalendarValue adjustTimezone(int tz)
tz
- the new timezone offset from UTC, in minutespublic final CalendarValue adjustTimezone(DayTimeDurationValue tz) throws XPathException
tz
- the new timezone, in minutesXPathException
public AtomicMatchKey getXPathComparable(boolean ordered, StringCollator collator, int implicitTimezone) throws NoDynamicContextException
getXPathComparable
in class AtomicValue
ordered
- true if an ordered comparison is required. In this case the result is null if the
type is unordered; in other cases the returned value will be a Comparable.collator
- collation used for stringsimplicitTimezone
- the XPath dynamic evaluation context, used in cases where the comparison is contextNoDynamicContextException
- if the supplied implicit timezone is "NO_TIMEZONE" (meaning
unknown), and the implicit timezone is actually required because the value in question is a date/time
value with no timezone. This can cause a failure to evaluate expressions statically (because the implicit
timezone is not known statically), and it will then be caught, meaning that the expression has to be
evaluated dynamically.public AtomicMatchKey getComparisonKey(XPathContext context)
public AtomicMatchKey asMapKey()
asMapKey
in class AtomicValue
public abstract int compareTo(CalendarValue other, int implicitTimezone) throws NoDynamicContextException
other
- the other value to be comparedimplicitTimezone
- the implicit timezone as an offset in minutesNoDynamicContextException
- if the result depends on the implicit timezone and
the supplied timezone is MISSING_TIMEZONE
public boolean isIdentical(AtomicValue v)
AtomicValue
Note that even this check ignores the type annotation of the value. The integer 3 and the short 3 are considered identical, even though they are not fully interchangeable. "Identical" means the same point in the value space, regardless of type annotation.
NaN is identical to itself.
isIdentical
in class AtomicValue
v
- the other value to be compared with this onepublic int identityHashCode()
identityHashCode
in interface IdentityComparable
identityHashCode
in class AtomicValue
public final void appendTimezone(FastStringBuffer sb)
sb
- The StringBuffer that will be updated with the resulting string
representationpublic static void appendTimezone(int tz, FastStringBuffer sb)
tz
- the timezonesb
- the bufferCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.