public abstract class AtomicValue extends Value<AtomicValue> implements Item<AtomicValue>, GroundedValue<AtomicValue>, ConversionResult
Modifier and Type | Field and Description |
---|---|
protected AtomicType |
typeLabel |
INDETERMINATE_ORDERING
EMPTY_VALUE_ARRAY
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.
|
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.
|
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.
|
int |
getCardinality()
Determine the static cardinality
|
AtomicValue |
getComponent(int component)
Method to extract components of a value.
|
ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible
|
int |
getLength()
Get the length of the sequence
|
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.
|
SequenceIterator<AtomicValue> |
getTypedValue()
Get the typed value of this item
|
AtomicType |
getTypeLabel()
Determine the data type of the value.
|
abstract java.lang.Object |
getXPathComparable(boolean ordered,
StringCollator collator,
XPathContext context)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
boolean |
isIdentical(Value v)
Determine whether two atomic values are identical, as determined by XML Schema rules.
|
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).
|
SequenceIterator<AtomicValue> |
iterate()
Iterate over the (single) item in the 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.
|
GroundedValue<AtomicValue> |
subsequence(int start,
int length)
Get a subsequence of the value
|
java.lang.String |
toString()
Get string value.
|
asItem, asItem, asIterator, asValue, convertToJava, fromItem, getCanonicalLexicalRepresentation, getIterator, getSequenceLength, hashCode, reduce
protected AtomicType typeLabel
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 Value.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 class Value<AtomicValue>
public abstract java.lang.Object getXPathComparable(boolean ordered, StringCollator collator, XPathContext context) 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 stringscontext
- the XPath dynamic evaluation context, used in cases where the comparison is context
sensitiveNoDynamicContextException
- if the comparison depends on dynamic context information that
is not available, for example implicit timezonepublic abstract boolean equals(java.lang.Object o)
The hashCode() method is consistent with equals().
equals
in class Value<AtomicValue>
o
- the other valuepublic boolean isIdentical(Value 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.
isIdentical
in class Value<AtomicValue>
v
- the other value to be compared with this onepublic final java.lang.CharSequence getStringValueCS()
getStringValueCS
in interface Item<AtomicValue>
getStringValueCS
in interface ValueRepresentation<AtomicValue>
getStringValueCS
in class Value<AtomicValue>
Item.getStringValue()
public void process(XPathContext context) throws XPathException
process
in class Value<AtomicValue>
context
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if an error occurs (for example if the value is
a closure that needs to be evaluated)public final AtomicValue itemAt(int n)
itemAt
in interface GroundedValue<AtomicValue>
itemAt
in class Value<AtomicValue>
n
- position of the required item, counting from zero.public ItemType getItemType(TypeHierarchy th)
getItemType
in class Value<AtomicValue>
th
- The TypeHierarchy. Can be null if the target is an AtomicValue,
except in the case where it is an external ObjectValue.public AtomicType getTypeLabel()
getItemType(net.sf.saxon.type.TypeHierarchy)
, except in the case of external objects
(instances of ObjectValue
, where the method may deliver a less specific type.public abstract BuiltInAtomicType getPrimitiveType()
public final int getCardinality()
getCardinality
in class Value<AtomicValue>
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 int getLength()
getLength
in interface GroundedValue<AtomicValue>
getLength
in class Value<AtomicValue>
public final SequenceIterator<AtomicValue> iterate()
iterate
in class Value<AtomicValue>
public final java.lang.String getStringValue()
getStringValue
in interface Item<AtomicValue>
getStringValue
in interface ValueRepresentation<AtomicValue>
getStringValue
in class Value<AtomicValue>
Item.getStringValueCS()
protected abstract java.lang.CharSequence getPrimitiveStringValue()
public final SequenceIterator<AtomicValue> getTypedValue()
getTypedValue
in interface Item<AtomicValue>
public boolean effectiveBooleanValue() throws XPathException
effectiveBooleanValue
in class Value<AtomicValue>
XPathException
- if any dynamic error occurs evaluating the
expressionpublic AtomicValue getComponent(int component) throws XPathException
component
- identifies the required component, as a constant defined in class
Component
, for example Component.HOURS
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
checkPermittedContents
in class Value<AtomicValue>
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 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 GroundedValue<AtomicValue> subsequence(int start, int length)
subsequence
in interface GroundedValue<AtomicValue>
start
- the index of the first item to be included in the result, counting from zero.
A negative value is taken as zero. If the value is beyond the end of the sequence, an empty
sequence is returnedlength
- the number of items to be included in the result. Specify Integer.MAX_VALUE to
get the subsequence up to the end of the base sequence. If the value is negative, an empty sequence
is returned. If the value goes off the end of the sequence, the result returns items up to the end
of the sequencepublic java.lang.String toString()
toString
in class java.lang.Object