|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.value.Value<AtomicValue> net.sf.saxon.value.AtomicValue
public abstract class AtomicValue
The AtomicValue class corresponds to the concept of an atomic value in the XPath 2.0 data model. Atomic values belong to one of the 19 primitive types defined in XML Schema; or they are of type xs:untypedAtomic; or they are "external objects", representing a Saxon extension to the XPath 2.0 type system.
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.
Field Summary | |
---|---|
protected AtomicType |
typeLabel
|
Fields inherited from class net.sf.saxon.value.Value |
---|
INDETERMINATE_ORDERING |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
Constructor Summary | |
---|---|
AtomicValue()
|
Method Summary | |
---|---|
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. |
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 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. |
SequenceIterator<AtomicValue> |
getTypedValue()
Get the typed value of this item |
AtomicType |
getTypeLabel()
Determine the data type of the value. |
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. |
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 |
String |
toString()
Get string value. |
Methods inherited from class net.sf.saxon.value.Value |
---|
asItem, asItem, asIterator, asValue, convertToJava, fromItem, getCanonicalLexicalRepresentation, getIterator, getSequenceLength, hashCode, reduce |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected AtomicType typeLabel
Constructor Detail |
---|
public AtomicValue()
Method Detail |
---|
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 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 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
sensitive
NoDynamicContextException
- 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().
equals
in class Value<AtomicValue>
o
- the other value
public 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 one
public final 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 String getStringValue()
getStringValue
in interface Item<AtomicValue>
getStringValue
in interface ValueRepresentation<AtomicValue>
getStringValue
in class Value<AtomicValue>
Item.getStringValueCS()
protected abstract 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 occurs
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 node
XPathException
- 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 sequence
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |