public abstract class AtomicValue extends java.lang.Object implements Item, AtomicSequence, ConversionResult, IdentityComparable
The AtomicValue class contains some methods that are suitable for applications to use, and many others that are designed for internal use by Saxon itself. These have not been fully classified. At present, therefore, none of the methods on this class should be considered to be part of the public Saxon API.
Modifier and Type | Field and Description |
---|---|
protected AtomicType |
typeLabel |
Constructor and Description |
---|
AtomicValue() |
Modifier and Type | Method and Description |
---|---|
AtomicValue |
asAtomic()
Calling this method on a ConversionResult returns the AtomicValue that results
from the conversion if the conversion was successful, and throws a ValidationException
explaining the conversion error otherwise.
|
AtomicMatchKey |
asMapKey()
Get a value whose equals() method follows the "same key" rules for comparing the keys of a map.
|
AtomicSequence |
atomize()
Atomize the item.
|
void |
checkPermittedContents(SchemaType parentType,
StaticContext env,
boolean whole)
Check statically that the results of the expression are capable of constructing the content
of a given schema type.
|
void |
checkValidInJavascript()
Check that the value can be handled in Saxon-JS
|
abstract AtomicValue |
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
|
boolean |
effectiveBooleanValue()
Get the effective boolean value of the value
|
boolean |
equals(java.lang.Object o)
The equals() methods on atomic values is defined to follow the semantics of eq when applied
to two atomic values.
|
UnicodeString |
getCanonicalLexicalRepresentation()
Get the canonical lexical representation as defined in XML Schema.
|
int |
getCardinality()
Determine the static cardinality
|
AtomicValue |
getComponent(AccessorFn.Component component)
Method to extract components of a value.
|
Genre |
getGenre()
Get the genre of this item
|
AtomicType |
getItemType()
Determine the data type of the value
|
int |
getLength()
Get the length of the sequence
|
abstract UnicodeString |
getPrimitiveStringValue()
Convert the value to a string, using the serialization rules for the primitive type.
|
abstract BuiltInAtomicType |
getPrimitiveType()
Determine the primitive type of the value.
|
UnicodeString |
getUnicodeStringValue()
Get the value of the item as a UnicodeString.
|
UType |
getUType()
Determine the UType of the value.
|
abstract XPathComparable |
getXPathComparable(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
abstract AtomicMatchKey |
getXPathMatchKey(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality comparison semantics for this value.
|
int |
hashCode()
Returns a hash code value for the object.
|
AtomicValue |
head()
To implement
Sequence , this method returns the item itself |
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.
|
boolean |
isIdentical(IdentityComparable other)
Determine whether two IdentityComparable objects are identical.
|
boolean |
isNaN()
Test whether the value is the special value NaN
|
boolean |
isUntypedAtomic()
Ask whether the value is of type xs:untypedAtomic
|
AtomicValue |
itemAt(int n)
Get the n'th item in the sequence (starting from 0).
|
SingleAtomicIterator |
iterate()
Get an iterator over all the items in the sequence
|
java.util.Iterator<AtomicValue> |
iterator()
Returns a Java iterator over the atomic sequence.
|
void |
setTypeLabel(AtomicType type)
Set the type label on this atomic value.
|
java.lang.String |
show()
Display the value for diagnostics.
|
java.lang.String |
toShortString()
Provide a short string showing the contents of the item, suitable
for use in error messages
|
java.lang.String |
toString()
Get string value.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getStringValue, isStreamed, reduce, subsequence
asIterable, concatenate, containsNode, materialize
makeRepeatable
protected AtomicType typeLabel
public AtomicSequence atomize() throws XPathException
atomize
in interface Item
XPathException
- if atomization is not allowed for this kind of itempublic final AtomicValue head()
Sequence
, this method returns the item itselfhead
in interface AtomicSequence
head
in interface GroundedValue
head
in interface Item
head
in interface Sequence
public int getLength()
getLength
in interface AtomicSequence
getLength
in interface GroundedValue
getLength
in interface Item
public void setTypeLabel(AtomicType type)
copyAsSubType(net.sf.saxon.type.AtomicType)
type
- the type label to be setpublic boolean isUntypedAtomic()
public abstract AtomicMatchKey getXPathMatchKey(StringCollator collator, int implicitTimezone) throws NoDynamicContextException
AtomicMatchKey
provided that its equality semantics are context-free.collator
- the collation to be used when comparing stringsimplicitTimezone
- the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezoneNoDynamicContextException
- 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 abstract XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone) throws NoDynamicContextException
collator
- the collation to be used when comparing stringsimplicitTimezone
- the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezoneNoDynamicContextException
- 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 asMapKey()
public boolean equals(java.lang.Object o)
The hashCode() method is consistent with equals().
equals
in class java.lang.Object
o
- the other valuepublic int hashCode()
hashCode
in class java.lang.Object
public boolean isIdentical(AtomicValue v)
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.
v
- the other value to be compared with this onepublic boolean isIdentical(IdentityComparable other)
isIdentical
in interface IdentityComparable
other
- the value to be comparedpublic int identityHashCode()
identityHashCode
in interface IdentityComparable
public UnicodeString getUnicodeStringValue()
getUnicodeStringValue
in interface AtomicSequence
getUnicodeStringValue
in interface GroundedValue
getUnicodeStringValue
in interface Item
public UnicodeString getCanonicalLexicalRepresentation()
getCanonicalLexicalRepresentation
in interface AtomicSequence
public final AtomicValue itemAt(int n)
itemAt
in interface AtomicSequence
itemAt
in interface GroundedValue
itemAt
in interface Item
n
- position of the required item, counting from zero.public final AtomicType getItemType()
public abstract BuiltInAtomicType getPrimitiveType()
public final UType getUType()
public final int getCardinality()
Cardinality
public abstract AtomicValue copyAsSubType(AtomicType typeLabel)
typeLabel
- the type label of the new copy. The caller is responsible for checking that
the value actually conforms to this type.public boolean isNaN()
public abstract UnicodeString getPrimitiveStringValue()
public boolean effectiveBooleanValue() throws XPathException
effectiveBooleanValue
in interface GroundedValue
XPathException
- if effective boolean value is not defined for this type (the default behaviour)public AtomicValue getComponent(AccessorFn.Component component) throws XPathException
component
- identifies the required component, as a constant defined in class
AccessorFn
XPathException
- if a dynamic error occursjava.lang.UnsupportedOperationException
- if applied to a value of a type that has no componentspublic void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
parentType
- The schema typeenv
- the static contextwhole
- true if this atomic value accounts for the entire content of the containing nodeXPathException
- if the expression doesn't match the required content typepublic void checkValidInJavascript() throws XPathException
XPathException
- if it can't be handled in Saxon-JSpublic AtomicValue asAtomic()
Use this method if you are calling a conversion method that returns a ConversionResult, and if you want to throw an exception if the conversion fails.
asAtomic
in interface ConversionResult
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toShortString()
Item
toShortString
in interface GroundedValue
toShortString
in interface Item
public java.lang.String show()
public SingleAtomicIterator iterate()
iterate
in interface AtomicSequence
iterate
in interface GroundedValue
iterate
in interface Item
iterate
in interface Sequence
public java.util.Iterator<AtomicValue> iterator()
iterator
in interface java.lang.Iterable<AtomicValue>
public final Genre getGenre()
getGenre
in interface Item
Genre.ATOMIC
;Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.