com.icl.saxon.expr

Class SingletonExpression

Known Direct Subclasses:
ContextNodeExpression, ParentNodeExpression, RootExpression

public abstract class SingletonExpression
extends NodeSetExpression

A node set expression that will always return zero or one nodes

Field Summary

Fields inherited from class com.icl.saxon.expr.Expression

staticContext

Method Summary

NodeEnumeration
enumerate(Context context, boolean sort)
Evaluate the expression in a given context to return a Node enumeration
boolean
evaluateAsBoolean(Context context)
Evaluate as a boolean.
NodeSetValue
evaluateAsNodeSet(Context context)
Evaluate an expression as a NodeSet.
String
evaluateAsString(Context context)
Evaluate as a string.
NodeInfo
getNode(Context context)
Get the single node to which this expression refers
boolean
isContextDocumentNodeSet()
Determine, in the case of an expression whose data type is Value.NODESET, whether all the nodes in the node-set are guaranteed to come from the same document as the context node.
NodeInfo
selectFirst(Context context)
Return the first node selected by this Expression when evaluated in the current context

Methods inherited from class com.icl.saxon.expr.NodeSetExpression

enumerate, evaluate, evaluateAsBoolean, evaluateAsNodeSet, evaluateAsString, getDataType, outputStringValue, selectFirst

Methods inherited from class com.icl.saxon.expr.Expression

containsReferences, display, enumerate, evaluate, evaluateAsBoolean, evaluateAsNodeSet, evaluateAsNumber, evaluateAsString, getDataType, getDependencies, getStaticContext, indent, isContextDocumentNodeSet, make, outputStringValue, reduce, setStaticContext, simplify, usesCurrent

Method Details

enumerate

public NodeEnumeration enumerate(Context context,
                                 boolean sort)
            throws XPathException
Evaluate the expression in a given context to return a Node enumeration
Overrides:
enumerate in interface NodeSetExpression

Parameters:
context - the evaluation context
sort - Indicates result must be in document order


evaluateAsBoolean

public boolean evaluateAsBoolean(Context context)
            throws XPathException
Evaluate as a boolean. Returns true if there are any nodes selected by the NodeSetExpression
Overrides:
evaluateAsBoolean in interface NodeSetExpression

Parameters:
context - The context in which the expression is to be evaluated

Returns:
true if there are any nodes selected by the NodeSetExpression


evaluateAsNodeSet

public NodeSetValue evaluateAsNodeSet(Context context)
            throws XPathException
Evaluate an expression as a NodeSet.
Overrides:
evaluateAsNodeSet in interface NodeSetExpression

Parameters:
context - The context in which the expression is to be evaluated

Returns:
the value of the expression, evaluated in the current context


evaluateAsString

public String evaluateAsString(Context context)
            throws XPathException
Evaluate as a string. Returns the string value of the node if it exists
Overrides:
evaluateAsString in interface NodeSetExpression

Parameters:
context - The context in which the expression is to be evaluated

Returns:
true if there are any nodes selected by the NodeSetExpression


getNode

public NodeInfo getNode(Context context)
            throws XPathException
Get the single node to which this expression refers


isContextDocumentNodeSet

public boolean isContextDocumentNodeSet()
Determine, in the case of an expression whose data type is Value.NODESET, whether all the nodes in the node-set are guaranteed to come from the same document as the context node. Used for optimization.
Overrides:
isContextDocumentNodeSet in interface Expression


selectFirst

public NodeInfo selectFirst(Context context)
            throws XPathException
Return the first node selected by this Expression when evaluated in the current context
Overrides:
selectFirst in interface NodeSetExpression

Parameters:
context - The context for the evaluation

Returns:
the NodeInfo of the first node in document order, or null if the node-set is empty.