Package com.icl.saxon.expr
Class NodeSetValue
java.lang.Object
com.icl.saxon.expr.Expression
com.icl.saxon.expr.Value
com.icl.saxon.expr.NodeSetValue
- Direct Known Subclasses:
EmptyNodeSet
,NodeSetExtent
,NodeSetIntent
,SingletonNodeSet
A node-set value. We use this both for node-sets and node-lists. The node set will only
be sorted into document order when requested (using sort() or evaluate()). This is an abstract
class with a number of concrete implementations including NodeSetExtent (for extensional node-sets)
and NodeSetIntent (for intensional node-sets).
-
Field Summary
Fields inherited from class com.icl.saxon.expr.Expression
staticContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
Evaluate as a boolean.double
asNumber()
Evaluate as a number.abstract String
asString()
Convert to string valueboolean
Test how a nodeset compares to another Value under a relational comparisonint
conversionPreference
(Class required) Get conversion preference for this value to a Java class.convertToJava
(Class target) Convert to Java object (for passing to external functions)void
display
(int level) Diagnostic print of expression structureabstract NodeEnumeration
Return an enumeration of this nodeset value.Return an enumeration of this nodeset value.boolean
Test whether a nodeset "equals" another ValueEvaluate the Node Set.evaluateAsNodeSet
(Context context) Evaluate an expression as a NodeSet.abstract int
getCount()
Count the nodes in the node-set.int
Determine the data type of the expressionabstract NodeInfo
getFirst()
Get the first node in the nodeset (in document order)abstract boolean
isSorted()
Test whether the value is known to be sortedboolean
Test whether a nodeset "not-equals" another Valueabstract void
setSorted
(boolean isSorted) Set a flag to indicate whether the nodes are sorted.abstract NodeSetValue
sort()
Sort the nodes into document order.Methods inherited from class com.icl.saxon.expr.Value
getDependencies, inverse, numericCompare, reduce, simplify, stringToNumber
Methods inherited from class com.icl.saxon.expr.Expression
containsReferences, evaluateAsBoolean, evaluateAsNumber, evaluateAsString, getStaticContext, indent, isContextDocumentNodeSet, make, outputStringValue, setStaticContext, usesCurrent
-
Constructor Details
-
NodeSetValue
public NodeSetValue()
-
-
Method Details
-
getDataType
public int getDataType()Determine the data type of the expression- Specified by:
getDataType
in classExpression
- Returns:
- Value.NODESET
-
evaluate
Evaluate the Node Set. This guarantees to return the result in sorted order.- Overrides:
evaluate
in classValue
- Parameters:
context
- The context for evaluation (not used)- Returns:
- the value, unchanged
- Throws:
XPathException
-
evaluateAsNodeSet
Evaluate an expression as a NodeSet.- Overrides:
evaluateAsNodeSet
in classExpression
- Parameters:
context
- The context in which the expression is to be evaluated- Returns:
- the value of the expression, evaluated in the current context
- Throws:
XPathException
- when the expression does not return a nodeset.
-
enumerate
Return an enumeration of this nodeset value. Unless sort() has been called the nodes can be in any order.- Throws:
XPathException
-
enumerate
Return an enumeration of this nodeset value. This is to satisfy the interface for Expression.- Overrides:
enumerate
in classExpression
- Parameters:
c
- The context in which the expression is to be evaluatedsorted
- Indicates that the result must be in document ordercontext
- The context is ignored.- Throws:
XPathException
- when the expression does not return a nodeset.
-
setSorted
public abstract void setSorted(boolean isSorted) Set a flag to indicate whether the nodes are sorted. Used when the creator of the node-set knows that they are already in document order.- Parameters:
isSorted
- true if the caller wishes to assert that the nodes are in document order and do not need to be further sorted
-
isSorted
Test whether the value is known to be sorted- Returns:
- true if the value is known to be sorted in document order, false if it is not known whether it is sorted.
- Throws:
XPathException
-
asString
Convert to string value- Specified by:
asString
in classValue
- Returns:
- the value of the first node in the node-set if there is one, otherwise an empty string
- Throws:
XPathException
-
asNumber
Evaluate as a number.- Specified by:
asNumber
in classValue
- Returns:
- the number obtained by evaluating as a String and converting the string to a number
- Throws:
XPathException
-
asBoolean
Evaluate as a boolean.- Specified by:
asBoolean
in classValue
- Returns:
- true if the node set is not empty
- Throws:
XPathException
-
getCount
Count the nodes in the node-set. Note this will sort the node set if necessary, to make sure there are no duplicates.- Throws:
XPathException
-
sort
Sort the nodes into document order. This does nothing if the nodes are already known to be sorted; to force a sort, call setSorted(false)- Parameters:
controller
- The controller used to sort nodes into document order- Returns:
- the same NodeSetValue, after sorting. (The reason for returning this is that it makes life easier for the XSL compiler).
- Throws:
XPathException
-
getFirst
Get the first node in the nodeset (in document order)- Returns:
- the first node
- Throws:
XPathException
-
equals
Test whether a nodeset "equals" another Value- Overrides:
equals
in classValue
- Returns:
- a boolean giving the value of the expression, evaluated in the current context
- Throws:
XPathException
-
notEquals
Test whether a nodeset "not-equals" another Value- Overrides:
notEquals
in classValue
- Returns:
- a boolean giving the value of the expression, evaluated in the current context
- Throws:
XPathException
-
compare
Test how a nodeset compares to another Value under a relational comparison- Overrides:
compare
in classValue
- Parameters:
operator
- The comparison operator, one of Tokenizer.LE, Tokenizer.LT, Tokenizer.GE, Tokenizer.GT,- Throws:
XPathException
-
display
public void display(int level) Diagnostic print of expression structure- Specified by:
display
in classExpression
-
conversionPreference
Get conversion preference for this value to a Java class. A low result indicates higher preference.- Specified by:
conversionPreference
in classValue
-
convertToJava
Convert to Java object (for passing to external functions)- Specified by:
convertToJava
in classValue
- Parameters:
target
- The class required by the external function- Returns:
- an object of the target class
- Throws:
XPathException
-