net.sf.saxon.value
public abstract class Value extends Object implements Serializable, SequenceIterable, ValueRepresentation
Field Summary | |
---|---|
static int | INDETERMINATE_ORDERING
Constant returned by compareTo() method to indicate an indeterminate ordering between two values |
Method Summary | |
---|---|
static Item | asItem(ValueRepresentation value)
Static method to make an Item from a Value |
Item | asItem()
Return the value in the form of an Item |
static SequenceIterator | asIterator(ValueRepresentation val)
Static method to get an Iterator over any ValueRepresentation (which may be either a Value
or a NodeInfo or a FunctionItem |
static Value | asValue(ValueRepresentation val)
Static method to make a Value from a given Item (which may be either an AtomicValue
or a NodeInfo or a FunctionItem |
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. |
static Object | convertToJava(Item item)
Convert an XPath value to a Java object.
|
boolean | effectiveBooleanValue()
Get the effective boolean value of the expression. |
boolean | equals(Object obj)
Compare two (sequence) values for equality. |
static Value | fromItem(Item item)
Static method to get a Value from an Item |
CharSequence | getCanonicalLexicalRepresentation()
Get the canonical lexical representation as defined in XML Schema. |
int | getCardinality()
Determine the cardinality |
ItemType | getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible |
static SequenceIterator | getIterator(ValueRepresentation val)
Get a SequenceIterator over a ValueRepresentation |
int | getLength()
Get the length of the sequence |
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. |
boolean | isIdentical(Value v)
Determine whether two values are identical, as determined by XML Schema rules. |
Item | itemAt(int n)
Get the n'th item in the sequence (starting from 0). |
abstract SequenceIterator | iterate()
Iterate over the items contained in this value. |
SequenceIterator | iterate(XPathContext context)
Return an iterator over the results of evaluating an expression |
void | process(XPathContext context)
Process the value as an instruction, without returning any tail calls |
Value | reduce()
Reduce a value to its simplest form. |
static double | stringToNumber(CharSequence s)
Static method to convert strings to doubles. |
Parameters: value the value to be converted
Returns: null if the value is an empty sequence; or the only item in the value if it is a singleton sequence
Throws: XPathException if the Value contains multiple items
Returns: the value in the form of an Item
Parameters: val The supplied value, or null, indicating the empty sequence.
Returns: The supplied value, if it is a value, or a SingletonNode that wraps the item, if it is a node. If the supplied value was null, return an EmptySequence
Parameters: val The supplied value, or null, indicating the empty sequence.
Returns: The supplied value, if it is a value, or a SingletonNode that wraps the item, if it is a node. If the supplied value was null, return an EmptySequence
Parameters: parentType The schema type env the static context whole true if this value accounts for the entire content of the containing node
Throws: XPathException if the expression doesn't match the required content type
Parameters: item the item to be converted
Returns: the value after conversion
Returns: the effective boolean value
Throws: XPathException if any dynamic error occurs evaluating the expression
Consider creating an XPathComparable from each value, and comparing those; or creating a SchemaComparable to achieve equality comparison as defined in XML Schema.
Throws: UnsupportedOperationException (always)
Parameters: item the supplied item
Returns: the item expressed as a Value
Returns: the canonical lexical representation if defined in XML Schema; otherwise, the result of casting to string according to the XPath 2.0 rules
Returns: the cardinality
Parameters: th The TypeHierarchy. Can be null if the target is an AtomicValue.
Returns: for the default implementation: AnyItemType (not known)
Parameters: val the value to iterate over
Returns: the iterator
Returns: the number of items in the sequence
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 INDETERMINATE_ORDERING when there is no defined order relationship between two given values.
Returns: a Comparable that follows XML Schema comparison rules
Throws: XPathException The method can fail if evaluation of the value has been deferred, and if a failure occurs during the deferred evaluation. No failure is possible in the case of an AtomicValue.
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.
Although the schema rules cover nodes only, this method also handles values that include nodes, using node identity in this case.
The empty sequence is considered identical to the empty sequence.
NaN is identical to itself.
Parameters: v the other value to be compared with this one
Returns: true if the two values are identical, false otherwise.
Parameters: n position of the required item, counting from zero.
Returns: the n'th item in the sequence, where the first item in the sequence is numbered zero. If n is negative or >= the length of the sequence, returns null.
Returns: an iterator over the sequence of items
Throws: XPathException if a dynamic error occurs. This is possible only in the case of values that are materialized lazily, that is, where the iterate() method leads to computation of an expression that delivers the values.
Parameters: context the dynamic evaluation context (not used in this implementation)
Returns: an iterator over the items delivered by the expression
Parameters: context The dynamic context, giving access to the current node, the current variables, etc.
Returns: the value in simplified form
Parameters: s the String to be converted
Returns: a double representing the value of the String
Throws: NumberFormatException if the value cannot be converted