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:boolean
atomic valueXdmAtomicValue
(byte value) Create anxs:byte
atomic valueXdmAtomicValue
(double value) Create anxs:double
atomic valueXdmAtomicValue
(float value) Create anxs:float
atomic valueXdmAtomicValue
(int value) Create anxs:int
atomic valueXdmAtomicValue
(long value) Create anxs:long
atomic valueXdmAtomicValue
(short value) Create anxs:short
atomic valueXdmAtomicValue
(String value) Create anxs:string
atomic 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:decimal
atomic valueXdmAtomicValue
(URI value) Create anxs:anyURI
atomic valueXdmAtomicValue
(Instant value) Create anxs:dateTime
atomic value from aInstant
.XdmAtomicValue
(LocalDate value) Create anxs:date
atomic value from aLocalDate
.XdmAtomicValue
(LocalDateTime value) Create anxs:dateTime
atomic value from aLocalDateTime
.XdmAtomicValue
(OffsetDateTime value) Create anxs:dateTime
atomic value from aOffsetDateTime
.XdmAtomicValue
(ZonedDateTime value) Create anxs:dateTime
atomic value from aZonedDateTime
.XdmAtomicValue
(QName value) Create anxs:QName
atomic valueXdmAtomicValue
(AtomicValue value) Create an XdmAtomicValue that wraps a suppliedAtomicValue
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compare values for equality.boolean
Get the value converted to a boolean using the XPath casting rulesGet the value converted to a decimal using the XPath casting rulesdouble
Get 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 ofInstant
For 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
.long
Get 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 ofOffsetDateTime
Get 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 ofZonedDateTime
int
hashCode()
Get a hashcode that reflects the rules for equality matchingstatic XdmAtomicValue
makeAtomicValue
(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, wrapItem
Methods inherited from class net.sf.saxon.s9api.XdmValue
append, documentOrder, isEmpty, itemAt, iterator, makeSequence, makeValue, matches, select, subsequence, where, wrap, wrap
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:boolean
atomic value- Parameters:
value
- the boolean value, true or false
-
XdmAtomicValue
public XdmAtomicValue(long value) Create anxs:long
atomic value- Parameters:
value
- thexs:integer
value, as a long
-
XdmAtomicValue
public XdmAtomicValue(int value) Create anxs:int
atomic value- Parameters:
value
- thexs:integer
value, as a long
-
XdmAtomicValue
public XdmAtomicValue(short value) Create anxs:short
atomic value- Parameters:
value
- thexs:integer
value, as a short
-
XdmAtomicValue
public XdmAtomicValue(byte value) Create anxs:byte
atomic value- Parameters:
value
- thexs:integer
value, as a byte
-
XdmAtomicValue
Create anxs:decimal
atomic value- Parameters:
value
- thexs:decimal
value, as a BigDecimal
-
XdmAtomicValue
public XdmAtomicValue(double value) Create anxs:double
atomic value- Parameters:
value
- thexs:double
value, as a double
-
XdmAtomicValue
public XdmAtomicValue(float value) Create anxs:float
atomic value- Parameters:
value
- thexs:float
value, as a float
-
XdmAtomicValue
Create anxs:string
atomic value- Parameters:
value
- thexs:string
value, as a string
-
XdmAtomicValue
Create anxs:anyURI
atomic value- Parameters:
value
- thexs:anyURI
value, as a URI
-
XdmAtomicValue
Create anxs:QName
atomic value- Parameters:
value
- thexs:QName
value, as a QName
-
XdmAtomicValue
Create anxs:dateTime
atomic value from aInstant
. The resulting value will always have a timezone component.- Parameters:
value
- thexs:dateTime
value in the form of aInstant
- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateTime
atomic 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:dateTime
value in the form of aZonedDateTime
- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateTime
atomic value from aOffsetDateTime
. The resulting value will always have a timezone component. The timezone offset (e.g. -05:00) is retained.- Parameters:
value
- thexs:dateTime
value in the form of aOffsetDateTime
- Since:
- 10.0
-
XdmAtomicValue
Create anxs:dateTime
atomic value from aLocalDateTime
. The resulting value will have no timezone component.- Parameters:
value
- thexs:dateTime
value in the form of aLocalDateTime
- Since:
- 10.0
-
XdmAtomicValue
Create anxs:date
atomic value from aLocalDate
. The resulting value will have no timezone component.- Parameters:
value
- thexs:dateTime
value 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 inlexicalForm
is 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 ofAtomicValue
orQName
, 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:
getUnderlyingValue
in 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
-