|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.value.Value 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 |
---|
Fields inherited from class net.sf.saxon.value.Value |
---|
EMPTY_CLASS_ARRAY, INDETERMINATE_ORDERING |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
---|
EMPTY_VALUE_ARRAY |
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. |
ConversionResult |
convert(AtomicType targetType,
boolean validate,
XPathContext context)
Convert the value to a given type. |
AtomicValue |
convert(AtomicType schemaType,
XPathContext context)
Convert the value to a given 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 |
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. |
abstract String |
getStringValue()
Convert the value to a string, using the serialization rules. |
CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence. |
SequenceIterator |
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 |
isNaN()
Test whether the value is the double/float value NaN |
Item |
itemAt(int n)
Get the n'th item in the sequence (starting from 0). |
SequenceIterator |
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 |
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, convertJavaObjectToXPath, convertToJava, convertToJava, fromItem, getCanonicalLexicalRepresentation, getIterator, iterate, makeQNameValue, reduce, stringToNumber |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
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
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
o
- the other value
public CharSequence getStringValueCS()
getStringValueCS
in interface Item
getStringValueCS
in interface ValueRepresentation
getStringValueCS
in class Value
Item.getStringValue()
public void process(XPathContext context) throws XPathException
process
in class Value
context
- The dynamic context, giving access to the current node,
the current variables, etc.
XPathException
public final Item itemAt(int n)
itemAt
in interface GroundedValue
itemAt
in class Value
n
- position of the required item, counting from zero.
public ItemType getItemType(TypeHierarchy th)
getItemType
in class Value
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
Cardinality
public final AtomicValue convert(AtomicType schemaType, XPathContext context) throws XPathException
schemaType
- the required atomic typecontext
- the XPath dynamic context
XPathException
- if conversion is not allowed for this
required type, or if the particular value cannot be convertedpublic final ConversionResult convert(AtomicType targetType, boolean validate, XPathContext context)
targetType
- the type to which the value is to be convertedvalidate
- true if validation is required, false if the caller already knows that the
value is validcontext
- provides access to conversion context
ValidationFailure
if conversion failed. The
caller must check for this condition. Validation may fail even if validation was not requested.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 class Value
public final SequenceIterator iterate()
iterate
in class Value
public abstract String getStringValue()
getStringValue
in interface Item
getStringValue
in interface ValueRepresentation
getStringValue
in class Value
Item.getStringValueCS()
public final SequenceIterator getTypedValue()
getTypedValue
in interface Item
public boolean effectiveBooleanValue() throws XPathException
effectiveBooleanValue
in class Value
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
public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
checkPermittedContents
in class Value
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 subsequence(int start, int length)
subsequence
in interface GroundedValue
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 Value
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |