Package net.sf.saxon.value
Class GYearValue
java.lang.Object
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.CalendarValue
net.sf.saxon.value.GDateValue
net.sf.saxon.value.GYearValue
- All Implemented Interfaces:
Iterable<AtomicValue>,AtomicMatchKey,AtomicSequence,GroundedValue,IdentityComparable,Item,Sequence,ConversionResult
Implementation of the xs:gYear data type
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.saxon.value.GDateValue
GDateValue.GDateComparable, GDateValue.MutableGDateValue -
Field Summary
Fields inherited from class net.sf.saxon.value.GDateValue
day, daysPerMonth, DEFAULT_DAY, DEFAULT_MONTH, DEFAULT_YEAR, month, monthData, yearFields inherited from class net.sf.saxon.value.CalendarValue
MISSING_TIMEZONE, NO_TIMEZONE, SIXTY, tzMinutesFields inherited from class net.sf.saxon.value.AtomicValue
metadata -
Constructor Summary
ConstructorsConstructorDescriptionGYearValue(int year, int tzMinutes) Constructs an instance of GMonthValue without any validation of the input values.GYearValue(int year, int tzMinutes, AtomicMetadata type) Constructs an instance of GMonthValue without any validation of the input values; with a supplied type annotation -
Method Summary
Modifier and TypeMethodDescriptionadd(DurationValue duration) Add a duration to this date/time valueadjustTimezone(int tz) Return a new date, time, or dateTime with the same normalized value, but in a different timezoneprotected EnumSet<AccessorFn.Component> Convert the value to a string, using the serialization rules for the primitive type.Determine the primitive type of the value.getXPathComparable(StringCollator collator, int implicitTimezone, int specVersion) Get an object value that implements the XPath equality and ordering comparison semantics for this value.static ConversionResultmakeGYearValue(int year, int timezoneInMinutes) Creates an instance of GYearValue.static ConversionResultmakeGYearValue(UnicodeString value, ConversionRules rules) Parse a GYear value from its lexical representationwithMetadata(AtomicMetadata metadata) Make a copy of this date, time, or dateTime valueMethods inherited from class net.sf.saxon.value.GDateValue
checkValidInJavascript, compareTo, equals, getCalendar, getComponent, getDay, getMonth, getSchemaComparable, getYear, hashCode, isLeapYear, isValidDate, isValidTimezone, toDateTimeMethods inherited from class net.sf.saxon.value.CalendarValue
adjustTimezone, appendString, appendTimezone, appendTimezone, appendTwoDigits, asMapKey, getTimezoneInMinutes, getXMLGregorianCalendar, getXPathMatchKey, hasTimezone, identityHashCode, isIdentical, makeCalendarValue, removeTimezone, subtractMethods inherited from class net.sf.saxon.value.AtomicValue
asAtomic, atomize, checkPermittedContents, effectiveBooleanValue, getCanonicalLexicalRepresentation, getCardinality, getGenre, getItemType, getLabel, getLength, getUnicodeStringValue, getUType, head, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, show, toShortString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.sf.saxon.expr.sort.AtomicMatchKey
asAtomic, longHashCodeMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materializeMethods inherited from interface net.sf.saxon.om.Item
getStringValue, isStreamed, reduce, subsequenceMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
GYearValue
public GYearValue(int year, int tzMinutes) Constructs an instance of GMonthValue without any validation of the input values.- Parameters:
year- - the yeartzMinutes- - number of minutes to adjust by for the timezone
-
GYearValue
Constructs an instance of GMonthValue without any validation of the input values; with a supplied type annotation- Parameters:
year- - the yeartzMinutes- - number of minutes to adjust by for the timezonetype- - the type annotation
-
-
Method Details
-
makeGYearValue
Parse a GYear value from its lexical representation- Parameters:
value- the lexical representation of the xs:gYear value- Returns:
- either a
GYearValue, or aValidationFailure
-
makeGYearValue
Creates an instance of GYearValue. Includes validation checks. If a validation error is detected, an instance of ValidationFailure will be returned instead.- Parameters:
year- - number of a year in the Gregorian calendartimezoneInMinutes- - number of minutes to adjust by for the timezone- Returns:
- an instance of GYearValue or ValidationFailure
-
withMetadata
Make a copy of this date, time, or dateTime value- Specified by:
withMetadatain classAtomicValue- Parameters:
metadata- the type label of the new copy. The caller is responsible for checking that the value actually conforms to this type.- Returns:
- the copied value
-
getXPathComparable
public XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone, int specVersion) throws NoDynamicContextException Description copied from class:AtomicValueGet an object value that implements the XPath equality and ordering comparison semantics for this value. A collation is supplied for comparing strings, and an implicit timezone for comparing date/time values that have no saved timezone. An atomic value may return itself as the result, provided that its ordering rules are independent of the collation and timezone, and provided that it implements the XPathComparable interface: which means that its compareTo, equals, and hashCode methods must be compatible with the rules for XPath value comparisons.- Overrides:
getXPathComparablein classGDateValue- Parameters:
collator- the collation to be used when comparing stringsimplicitTimezone- the implicit timezone in the dynamic context, used when comparing dates/times with and without timezonespecVersion- the version of the XPath specification (31 for 3.1, 40 for 4.0)- Returns:
- an Object that implements the XPath value comparison semantics with respect to this atomic value. For an atomic type that is not ordered (according to XPath rules), return null.
- Throws:
NoDynamicContextException- 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.
-
getDefinedComponents
- Overrides:
getDefinedComponentsin classGDateValue
-
getPrimitiveType
Determine the primitive type of the value. This delivers the same answer as getItemType().getPrimitiveItemType(). The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration, and xs:untypedAtomic. For external objects, the result is AnyAtomicType.- Specified by:
getPrimitiveTypein classAtomicValue- Returns:
- the primitive type
-
getPrimitiveStringValue
Description copied from class:AtomicValueConvert the value to a string, using the serialization rules for the primitive type. This is the result of conversion to a string except that postprocessing defined by the saxon:preprocess facet is not (yet) applied.- Specified by:
getPrimitiveStringValuein classAtomicValue- Returns:
- the value converted to a string according to the rules for the primitive type
-
add
Add a duration to this date/time value- Specified by:
addin classCalendarValue- Parameters:
duration- the duration to be added (which might be negative)- Returns:
- a new date/time value representing the result of adding the duration. The original object is not modified.
- Throws:
XPathException- if an error is detected
-
adjustTimezone
Return a new date, time, or dateTime with the same normalized value, but in a different timezone- Specified by:
adjustTimezonein classCalendarValue- Parameters:
tz- the new timezone, in minutes- Returns:
- the date/time in the new timezone
-