public class XdmAtomicValue extends XdmItem
An XdmAtomicValue
is immutable.
Constructor and Description |
---|
XdmAtomicValue(AtomicValue value)
Create an XdmAtomicValue that wraps a supplied
AtomicValue . |
XdmAtomicValue(java.math.BigDecimal value)
Create an xs:decimal atomic value
|
XdmAtomicValue(boolean value)
Create an xs:boolean atomic value
|
XdmAtomicValue(byte value)
Create an xs:short atomic value
|
XdmAtomicValue(double value)
Create an xs:double atomic value
|
XdmAtomicValue(float value)
Create an xs:float atomic value
|
XdmAtomicValue(java.time.Instant value)
Create an xs:dateTime atomic value from a
Instant . |
XdmAtomicValue(int value)
Create an xs:int atomic value
|
XdmAtomicValue(java.time.LocalDate value)
Create an xs:date atomic value from a
LocalDate . |
XdmAtomicValue(java.time.LocalDateTime value)
Create an xs:dateTime atomic value from a
LocalDateTime . |
XdmAtomicValue(long value)
Create an xs:long atomic value
|
XdmAtomicValue(java.time.OffsetDateTime value)
Create an xs:dateTime atomic value from a
OffsetDateTime . |
XdmAtomicValue(QName value)
Create an xs:QName atomic value
|
XdmAtomicValue(short value)
Create an xs:short atomic value
|
XdmAtomicValue(java.lang.String value)
Create an xs:string atomic value
|
XdmAtomicValue(java.lang.String lexicalForm,
ItemType type)
Construct an atomic value given its lexical representation and the name of the required
built-in atomic type.
|
XdmAtomicValue(java.net.URI value)
Create an xs:anyURI atomic value
|
XdmAtomicValue(java.time.ZonedDateTime value)
Create an xs:dateTime atomic value from a
ZonedDateTime . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other)
Compare values for equality.
|
boolean |
getBooleanValue()
Get the value converted to a boolean using the XPath casting rules
|
java.math.BigDecimal |
getDecimalValue()
Get the value converted to a decimal using the XPath casting rules
|
double |
getDoubleValue()
Get the value converted to a double using the XPath casting rules.
|
java.time.Instant |
getInstant()
For an XdmAtomicValue representing an xs:dateTime value including timezone,
get the value as an instance of
Instant |
java.time.LocalDate |
getLocalDate()
For an XdmAtomicValue representing an xs:date value,
get the value as an instance of
LocalDate . |
java.time.LocalDateTime |
getLocalDateTime()
For an XdmAtomicValue representing an xs:dateTime value,
get the value as an instance of
LocalDateTime . |
long |
getLongValue()
Get the value converted to an integer using the XPath casting rules
|
java.time.OffsetDateTime |
getOffsetDateTime()
For an XdmAtomicValue representing an xs:dateTime value including timezone,
get the value as an instance of
OffsetDateTime |
QName |
getPrimitiveTypeName()
Get the primitive type of this atomic value, as a QName.
|
QName |
getQNameValue()
For an XdmAtomicValue representing an xs:QName or xs:NOTATION value,
get the value as an instance of QName
|
QName |
getTypeName()
Get the type of this atomic value, as a QName.
|
AtomicValue |
getUnderlyingValue()
Get the underlying implementation object representing the value.
|
java.lang.Object |
getValue()
Get the value as a Java object of the nearest equivalent type.
|
java.time.ZonedDateTime |
getZonedDateTime()
For an XdmAtomicValue representing an xs:dateTime value including timezone,
get the value as an instance of
ZonedDateTime |
int |
hashCode()
Get a hashcode that reflects the rules for equality matching
|
static XdmAtomicValue |
makeAtomicValue(java.lang.Object value)
Attempt conversion from an arbitrary Java object
|
java.lang.String |
toString()
Get the result of converting the atomic value to a string.
|
asMap, getStringValue, getUnicodeStringValue, isAtomicValue, isNode, matches, size, stream, wrapItem, wrapItem, wrapItem
append, documentOrder, isEmpty, itemAt, iterator, makeSequence, makeValue, select, subsequence, wrap, wrap
public XdmAtomicValue(AtomicValue value)
AtomicValue
. This
method is primarily for internal use, though it is also available to applications
that manipulate data using lower-level Saxon interfaces.value
- the value to be wrapped.public XdmAtomicValue(boolean value)
value
- the boolean value, true or falsepublic XdmAtomicValue(long value)
value
- the xs:integer value, as a longpublic XdmAtomicValue(int value)
value
- the xs:integer value, as a longpublic XdmAtomicValue(short value)
value
- the xs:integer value, as a longpublic XdmAtomicValue(byte value)
value
- the xs:integer value, as a longpublic XdmAtomicValue(java.math.BigDecimal value)
value
- the xs:decimal value, as a BigDecimalpublic XdmAtomicValue(double value)
value
- the xs:double value, as a doublepublic XdmAtomicValue(float value)
value
- the xs:float value, as a floatpublic XdmAtomicValue(java.lang.String value)
value
- the xs:string value, as a stringpublic XdmAtomicValue(java.net.URI value)
value
- the xs:anyURI value, as a URIpublic XdmAtomicValue(QName value)
value
- the xs:QName value, as a QNamepublic XdmAtomicValue(java.time.Instant value)
Instant
. The resulting value
will always have a timezone component.value
- the xs:dateTime value in the form of a Instant
public XdmAtomicValue(java.time.ZonedDateTime value)
ZonedDateTime
. 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.value
- the xs:dateTime value in the form of a ZonedDateTime
public XdmAtomicValue(java.time.OffsetDateTime value)
OffsetDateTime
. The resulting value
will always have a timezone component. The timezone offset (e.g. -05:00) is retained.value
- the xs:dateTime value in the form of a OffsetDateTime
public XdmAtomicValue(java.time.LocalDateTime value)
LocalDateTime
. The resulting value
will have no timezone component.value
- the xs:dateTime value in the form of a LocalDateTime
public XdmAtomicValue(java.time.LocalDate value)
LocalDate
. The resulting value
will have no timezone component.value
- the xs:dateTime value in the form of a LocalDate
public XdmAtomicValue(java.lang.String lexicalForm, ItemType type) throws SaxonApiException
This method cannot be used to construct values that are namespace-sensitive (QNames and Notations)
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.SaxonApiException
- if the type is unknown, or is not atomic, or is namespace-sensitive;
or if the value supplied in lexicalForm is not in the lexical space of the specified atomic
type.public static XdmAtomicValue makeAtomicValue(java.lang.Object value)
value
- the value to convert from. This must either be an instance of AtomicValue
or QName
,
or one of the basic Java types Boolean, Integer, Long, Short, Character, Byte,
String, Double, Float, BigDecimal, BigInteger, URI, ZonedDateTime,
LocalDateTime, or LocalDatejava.lang.IllegalArgumentException
- if conversion from this kind of Object is not supportedpublic AtomicValue getUnderlyingValue()
getUnderlyingValue
in class XdmItem
public java.lang.String toString()
public QName getPrimitiveTypeName()
public QName getTypeName()
public java.lang.Object getValue()
The result type is as follows:
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 |
public boolean getBooleanValue() throws SaxonApiException
SaxonApiException
- if the value cannot be cast to a booleanpublic long getLongValue() throws SaxonApiException
SaxonApiException
- if the value cannot be cast to an integerpublic double getDoubleValue() throws SaxonApiException
If the value is a string, the XSD 1.1 rules are used, which means that the string "+INF" is recognised.
SaxonApiException
- if the value cannot be cast to a doublepublic java.math.BigDecimal getDecimalValue() throws SaxonApiException
SaxonApiException
- if the value cannot be cast to a doublepublic QName getQNameValue()
public java.time.Instant getInstant()
Instant
public java.time.ZonedDateTime getZonedDateTime()
ZonedDateTime
public java.time.OffsetDateTime getOffsetDateTime()
OffsetDateTime
public java.time.LocalDateTime getLocalDateTime()
LocalDateTime
. Any timezone
information in the value is discardedpublic java.time.LocalDate getLocalDate()
LocalDate
. Any timezone
information in the value is discardedpublic boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the value to be comparedpublic int hashCode()
hashCode
in class java.lang.Object
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.