Package net.sf.saxon.s9api
Class XdmAtomicValue
java.lang.Object
net.sf.saxon.s9api.XdmValue
net.sf.saxon.s9api.XdmItem
net.sf.saxon.s9api.XdmAtomicValue
The class XdmAtomicValue represents an item in an XPath sequence that is an atomic value.
The value may belong to any of the 19 primitive types defined in XML Schema, or to a type
derived from these primitive types, or the XPath type xs:untypedAtomic. The type may
be either a built-in type or a user-defined type.
An XdmAtomicValue is immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionXdmAtomicValue(boolean value) Create anxs:booleanatomic valueXdmAtomicValue(byte value) Create anxs:byteatomic valueXdmAtomicValue(double value) Create anxs:doubleatomic valueXdmAtomicValue(float value) Create anxs:floatatomic valueXdmAtomicValue(int value) Create anxs:intatomic valueXdmAtomicValue(long value) Create anxs:longatomic valueXdmAtomicValue(short value) Create anxs:shortatomic valueXdmAtomicValue(String value) Create anxs:stringatomic valueXdmAtomicValue(String lexicalForm, ItemType type) Construct an atomic value given its lexical representation and the name of the required built-in atomic type.XdmAtomicValue(BigDecimal value) Create anxs:decimalatomic valueXdmAtomicValue(URI value) Create anxs:anyURIatomic valueXdmAtomicValue(Instant value) Create anxs:dateTimeatomic value from aInstant.XdmAtomicValue(LocalDate value) Create anxs:dateatomic value from aLocalDate.XdmAtomicValue(LocalDateTime value) Create anxs:dateTimeatomic value from aLocalDateTime.XdmAtomicValue(OffsetDateTime value) Create anxs:dateTimeatomic value from aOffsetDateTime.XdmAtomicValue(ZonedDateTime value) Create anxs:dateTimeatomic value from aZonedDateTime.XdmAtomicValue(QName value) Create anxs:QNameatomic valueXdmAtomicValue(AtomicValue value) Create an XdmAtomicValue that wraps a suppliedAtomicValue. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompare values for equality.booleanGet the value converted to a boolean using the XPath casting rulesGet the value converted to a decimal using the XPath casting rulesdoubleGet the value converted to a double using the XPath casting rules.For an XdmAtomicValue representing an xs:dateTime value including timezone, get the value as an instance ofInstantFor an XdmAtomicValue representing an xs:date value, get the value as an instance ofLocalDate.For an XdmAtomicValue representing an xs:dateTime value, get the value as an instance ofLocalDateTime.longGet the value converted to an integer using the XPath casting rulesFor an XdmAtomicValue representing an xs:dateTime value including timezone, get the value as an instance ofOffsetDateTimeGet the primitive type of this atomic value, as a QName.For an XdmAtomicValue representing an xs:QName or xs:NOTATION value, get the value as an instance of QNameGet the type of this atomic value, as a QName.Get the underlying implementation object representing the value.getValue()Get the value as a Java object of the nearest equivalent type.For an XdmAtomicValue representing an xs:dateTime value including timezone, get the value as an instance ofZonedDateTimeinthashCode()Get a hashcode that reflects the rules for equality matchingstatic XdmAtomicValuemakeAtomicValue(Object value) Attempt conversion from an arbitrary Java objecttoString()Get the result of converting the atomic value to a string.Methods inherited from class net.sf.saxon.s9api.XdmItem
asMap, getStringValue, getUnicodeStringValue, isAtomicValue, isNode, matches, size, stream, wrapItem, wrapItem, wrapItemMethods inherited from class net.sf.saxon.s9api.XdmValue
append, documentOrder, isEmpty, isEmptySequence, itemAt, iterator, makeSequence, makeValue, matches, select, subsequence, where, wrap, wrapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
XdmAtomicValue
Create an XdmAtomicValue that wraps a suppliedAtomicValue. This method is primarily for internal use, though it is also available to applications that manipulate data using lower-level Saxon interfaces.- Parameters:
value- the value to be wrapped.
-
XdmAtomicValue
public XdmAtomicValue(boolean value) Create anxs:booleanatomic value- Parameters:
value- the boolean value, true or false
-
XdmAtomicValue
public XdmAtomicValue(long value) Create anxs:longatomic value- Parameters:
value- thexs:integervalue, as a long
-
XdmAtomicValue
public XdmAtomicValue(int value) Create anxs:intatomic value- Parameters:
value- thexs:integervalue, as a long
-
XdmAtomicValue
public XdmAtomicValue(short value) Create anxs:shortatomic value- Parameters:
value- thexs:integervalue, as a short
-
XdmAtomicValue
public XdmAtomicValue(byte value) Create anxs:byteatomic value- Parameters:
value- thexs:integervalue, as a byte
-
XdmAtomicValue
Create anxs:decimalatomic value- Parameters:
value- thexs:decimalvalue, as a BigDecimal
-
XdmAtomicValue
public XdmAtomicValue(double value) Create anxs:doubleatomic value- Parameters:
value- thexs:doublevalue, as a double
-
XdmAtomicValue
public XdmAtomicValue(float value) Create anxs:floatatomic value- Parameters:
value- thexs:floatvalue, as a float
-
XdmAtomicValue
Create anxs:stringatomic value- Parameters:
value- thexs:stringvalue, as a string
-
XdmAtomicValue
Create anxs:anyURIatomic value- Parameters:
value- thexs:anyURIvalue, as a URI
-
XdmAtomicValue
Create anxs:QNameatomic value- Parameters:
value- thexs:QNamevalue, as a QName
-
XdmAtomicValue
Create anxs:dateTimeatomic value from aInstant. The resulting value will always have a timezone component.- Parameters:
value- thexs:dateTimevalue in the form of aInstant- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateTimeatomic value from aZonedDateTime. The resulting value will always have a timezone component. Note that the timezone offset (e.g. -05:00) is retained, but the civil time zone identity (e.g. America/New_York) is lost.- Parameters:
value- thexs:dateTimevalue in the form of aZonedDateTime- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateTimeatomic value from aOffsetDateTime. The resulting value will always have a timezone component. The timezone offset (e.g. -05:00) is retained.- Parameters:
value- thexs:dateTimevalue in the form of aOffsetDateTime- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateTimeatomic value from aLocalDateTime. The resulting value will have no timezone component.- Parameters:
value- thexs:dateTimevalue in the form of aLocalDateTime- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateatomic value from aLocalDate. The resulting value will have no timezone component.- Parameters:
value- thexs:dateTimevalue in the form of aLocalDate- Since:
- 10.0
-
XdmAtomicValue
Construct an atomic value given its lexical representation and the name of the required built-in atomic type.This method cannot be used to construct values that are namespace-sensitive (QNames and Notations)
- Parameters:
lexicalForm- the value in the lexical space of the target data type. More strictly, the input value before the actions of the whitespace facet for the target data type are applied.type- the required atomic type. This must either be one of the built-in atomic types defined in XML Schema, or a user-defined type whose definition appears in a schema that is known to the Processor. It must not be an abstract type.- Throws:
SaxonApiException- if the type is unknown, or is not atomic, or is namespace-sensitive; or if the value supplied inlexicalFormis not in the lexical space of the specified atomic type.
-
-
Method Details
-
makeAtomicValue
Attempt conversion from an arbitrary Java object- Parameters:
value- the value to convert from. This must either be an instance ofAtomicValueorQName, or one of the basic Java types Boolean, Integer, Long, Short, Character, Byte, String, Double, Float, BigDecimal, BigInteger, URI, ZonedDateTime, LocalDateTime, or LocalDate- Returns:
- the result of the conversion if successful
- Throws:
IllegalArgumentException- if conversion from this kind of Object is not supported- Since:
- 10.0 (extended in 10.0 to handle additional data types ZonedDateTime, LocalDateTime, LocalDate)
-
getUnderlyingValue
Get the underlying implementation object representing the value. This method allows access to lower-level Saxon functionality, including classes and methods that offer no guarantee of stability across releases.- Overrides:
getUnderlyingValuein classXdmItem- Returns:
- the underlying implementation object representing the value
- Since:
- 9.8 (previously inherited from XdmValue which returns a Sequence)
-
toString
Get the result of converting the atomic value to a string. This has the same effect as the XPath string() function. -
getPrimitiveTypeName
Get the primitive type of this atomic value, as a QName. The primitive types for this purpose 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 xs:anyAtomicType.- Returns:
- a QName naming the primitive type of this atomic value. This will always be an atomic type.
-
getTypeName
Get the type of this atomic value, as a QName.- Returns:
- a QName naming the type of this atomic value. This will always be an atomic type.
-
getValue
Get the value as a Java object of the nearest equivalent type.The result type is as follows:
XPath types and corresponding Java classes XPath type Java class xs:string String xs:integer java.math.BigInteger xs:decimal java.math.BigDecimal xs:double Double xs:float Float xs:boolean Boolean xs:QName QName xs:anyURI String xs:dateTime ZonedDateTime or LocalDateTime (depending whether a timezone is present) xs:date LocalDate (dropping any timezone) xs:untypedAtomic String Other types currently String, but this may change in the future - Returns:
- the value, converted to a Java object of a suitable type
- Since:
- 10.0 (added additional return types for xs:dateTime and xs:date)
-
getBooleanValue
Get the value converted to a boolean using the XPath casting rules- Returns:
- the result of converting to a boolean (Note: this is not the same as the effective boolean value).
- Throws:
SaxonApiException- if the value cannot be cast to a boolean
-
getLongValue
Get the value converted to an integer using the XPath casting rules- Returns:
- the result of converting to an integer
- Throws:
SaxonApiException- if the value cannot be cast to an integer
-
getDoubleValue
Get the value converted to a double using the XPath casting rules.If the value is a string, the XSD 1.1 rules are used, which means that the string "+INF" is recognised.
- Returns:
- the result of converting to a double
- Throws:
SaxonApiException- if the value cannot be cast to a double
-
getDecimalValue
Get the value converted to a decimal using the XPath casting rules- Returns:
- the result of converting to a decimal
- Throws:
SaxonApiException- if the value cannot be cast to a double
-
getQNameValue
For an XdmAtomicValue representing an xs:QName or xs:NOTATION value, get the value as an instance of QName- Returns:
- the corresponding QName if the value is an xs:QName or xs:NOTATION, or null otherwise
-
getInstant
For an XdmAtomicValue representing an xs:dateTime value including timezone, get the value as an instance ofInstant- Returns:
- the corresponding Instant if the value is an xs:dateTime including a timezone; otherwise null
- Since:
- 10.0
-
getZonedDateTime
For an XdmAtomicValue representing an xs:dateTime value including timezone, get the value as an instance ofZonedDateTime- Returns:
- the corresponding ZonedDateTime if the value is an xs:dateTime including a timezone; otherwise null
- Since:
- 10.0
-
getOffsetDateTime
For an XdmAtomicValue representing an xs:dateTime value including timezone, get the value as an instance ofOffsetDateTime- Returns:
- the corresponding OffsetDateTime if the value is an xs:dateTime including a timezone; otherwise null
- Since:
- 10.0
-
getLocalDateTime
For an XdmAtomicValue representing an xs:dateTime value, get the value as an instance ofLocalDateTime. Any timezone information in the value is discarded- Returns:
- the corresponding LocalDateTime if the value is an xs:dateTime; otherwise null
- Since:
- 10.0
-
getLocalDate
For an XdmAtomicValue representing an xs:date value, get the value as an instance ofLocalDate. Any timezone information in the value is discarded- Returns:
- the corresponding LocalDate if the value is an xs:date; otherwise null
- Since:
- 10.0
-
equals
Compare values for equality. Two atomic values are considered equal if they are equal according to the rules of the op:is-same-key() operation, used when comparing keys in maps -
hashCode
public int hashCode()Get a hashcode that reflects the rules for equality matching
-