public abstract class AtomicValue extends AbstractItem implements AtomicSequence, ConversionResult, IdentityComparable
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.
|
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(Object o)
The equals() methods on atomic values is defined to follow the semantics of eq when applied
to two atomic values.
|
CharSequence |
getCanonicalLexicalRepresentation()
Get the canonical lexical representation as defined in XML Schema.
|
int |
getCardinality()
Determine the static cardinality
|
AtomicValue |
getComponent(int component)
Method to extract components of a value.
|
AtomicType |
getItemType()
Determine the data type of the value
|
protected abstract 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 Comparable |
getSchemaComparable()
Get a Comparable value that implements the XML Schema ordering comparison semantics for this value.
|
String |
getStringValue()
Convert the value to a string, using the serialization rules.
|
CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
abstract Object |
getXPathComparable(boolean ordered,
StringCollator collator,
XPathContext context)
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 |
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 values 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).
|
SequenceIterator<AtomicValue> |
iterate()
To implement
Sequence , this method returns a singleton iterator
that delivers this item in the form of a 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.
|
String |
toString()
Get string value.
|
getLength, reduce, subsequence
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getLength
reduce, subsequence
protected AtomicType typeLabel
public final AtomicValue head()
Sequence
, this method returns the item itselfhead
in interface AtomicSequence
head
in interface Sequence
head
in class AbstractItem
public final SequenceIterator<AtomicValue> iterate()
Sequence
, this method returns a singleton iterator
that delivers this item in the form of a sequenceiterate
in interface AtomicSequence
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 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 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(Object o)
The hashCode() method is consistent with equals().
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
- public final CharSequence getStringValueCS()
getStringValueCS
in interface AtomicSequence
getStringValueCS
in interface GroundedValue
getStringValueCS
in interface Item
Item.getStringValue()
public 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 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 String getStringValue()
getStringValue
in interface AtomicSequence
getStringValue
in interface GroundedValue
getStringValue
in interface Item
Item.getStringValueCS()
protected abstract 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(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 occursUnsupportedOperationException
- 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 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
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.