public abstract class AtomicValue extends AbstractItem implements AtomicSequence, ConversionResult, IdentityComparable
Modifier and Type | Field and Description |
---|---|
static AtomicMatchKey |
NaN_MATCH_KEY
A match key for use in situations where NaN = NaN
|
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
|
abstract 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.
|
java.lang.CharSequence |
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.
|
AtomicType |
getItemType()
Determine the data type of the value
|
protected abstract java.lang.CharSequence |
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.
|
abstract java.lang.Comparable |
getSchemaComparable()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value.
|
java.lang.String |
getStringValue()
Convert the value to a string, using the serialization rules.
|
java.lang.CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
UType |
getUType()
Determine the UType of the value.
|
abstract AtomicMatchKey |
getXPathComparable(boolean ordered,
StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
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
|
AtomicValue |
itemAt(int n)
Get the n'th item in the sequence (starting from 0).
|
AtomicIterator |
iterate()
To implement
Sequence , this method returns a singleton iterator
that delivers this item in the form of a sequence |
java.util.Iterator<AtomicValue> |
iterator()
Returns a Java iterator over the atomic sequence.
|
void |
process(XPathContext context)
Process the instruction, without returning any tail calls
|
void |
setTypeLabel(AtomicType type)
Set the type label on this atomic value.
|
java.lang.String |
toString()
Get string value.
|
getLength, isStreamed, reduce, subsequence
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getLength
reduce, subsequence
protected AtomicType typeLabel
public static final AtomicMatchKey NaN_MATCH_KEY
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
head
in class AbstractItem
public final AtomicIterator iterate()
Sequence
, this method returns a singleton iterator
that delivers this item in the form of a sequenceiterate
in interface AtomicSequence
iterate
in interface GroundedValue
iterate
in interface Sequence
iterate
in class AbstractItem
public void setTypeLabel(AtomicType type)
copyAsSubType(net.sf.saxon.type.AtomicType)
type
- the type label to be setpublic abstract java.lang.Comparable getSchemaComparable()
In the case of data types that are partially ordered, the returned Comparable extends the standard
semantics of the compareTo() method by returning the value SequenceTool.INDETERMINATE_ORDERING
when there
is no defined order relationship between two given values. This value is also returned when two values
of different types are compared.
getSchemaComparable
in interface AtomicSequence
public abstract AtomicMatchKey getXPathComparable(boolean ordered, StringCollator collator, int implicitTimezone) throws NoDynamicContextException
ordered
- true if an ordered comparison is required. In this case the result is null if the
type is unordered; in other cases the returned value will be a Comparable.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 abstract boolean equals(java.lang.Object o)
The hashCode() method is consistent with equals().
equals
in class java.lang.Object
o
- the other valuepublic 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 final java.lang.CharSequence getStringValueCS()
getStringValueCS
in interface AtomicSequence
getStringValueCS
in interface GroundedValue
getStringValueCS
in interface Item
Item.getStringValue()
public java.lang.CharSequence getCanonicalLexicalRepresentation()
getCanonicalLexicalRepresentation
in interface AtomicSequence
public void process(XPathContext context) throws XPathException
context
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if the current receiver fails for any reason, for example
with a serialization error due to invalid characters in the contentpublic final AtomicValue itemAt(int n)
itemAt
in interface AtomicSequence
itemAt
in interface GroundedValue
itemAt
in class AbstractItem
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 final java.lang.String getStringValue()
getStringValue
in interface AtomicSequence
getStringValue
in interface GroundedValue
getStringValue
in interface Item
Item.getStringValueCS()
protected abstract java.lang.CharSequence 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.util.Iterator<AtomicValue> iterator()
iterator
in interface java.lang.Iterable<AtomicValue>
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.