net.sf.saxon.expr
Class LazyExpression
- EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator
public class LazyExpression
A LazyExpression is an expression that forces lazy evaluation: it must not be evaluated eagerly,
because a failure must not be reported unless the value is actually referenced. This is used
for an expression that has been moved out of a loop. If the loop iterates zero times, the expression
will not be evaluated, and in particular, it will not cause a dynamic error.
Note that the LazyExpression class does not itself implement any kind of delayed evaluation:
calling its evaluateItem() and iterate() methods produces an immediate result. Instead, the existence
of a LazyExpression on the expression tree acts as a signal to other classes that evaluation should
be delayed, typically by holding the result of the iterate() method in a Closure object.
computeCardinality, computeSpecialProperties, displayExpressionName, displayOperator, equals, explain, getBaseExpression, getItemType, hashCode, iterateSubExpressions, optimize, promote, replaceSubExpression, simplify, toString, typeCheck |
addToPathMap, adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, explain, findParentOf, getCardinality, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getItemType, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterate, iterateEvents, iterateSubExpressions, markTailFunctionCalls, optimize, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, toString, typeCheck, typeError |
LazyExpression
public LazyExpression(Expression operand)
Create a LazyExpression
operand - the expression to be evaluated lazily
copy
public Expression copy()
Copy an expression. This makes a deep copy.
- copy in interface Expression
- the copy of the original expression
evaluateItem
public Item evaluateItem(XPathContext context)
throws XPathException Evaluate an expression as a single item. This always returns either a single Item or
null (denoting the empty sequence). No conversion is done. This method should not be
used unless the static type of the expression is a subtype of "item" or "item?": that is,
it should not be called if the expression may return a sequence. There is no guarantee that
this condition will be detected.
- evaluateItem in interface EvaluableItem
- evaluateItem in interface Expression
context - The context in which the expression is to be evaluated
- the node or atomic value that results from evaluating the
expression; or null to indicate that the result is an empty
sequence
XPathException - if any dynamic error occurs evaluating the
expression
iterate
public SequenceIterator iterate(XPathContext context)
throws XPathException Return an Iterator to iterate over the values of a sequence. The value of every
expression can be regarded as a sequence, so this method is supported for all
expressions. This default implementation handles iteration for expressions that
return singleton values: for non-singleton expressions, the subclass must
provide its own implementation.
- iterate in interface SequenceIterable
- iterate in interface Expression
context - supplies the context for evaluation
- a SequenceIterator that can be used to iterate over the result
of the expression
XPathException - if any dynamic error occurs evaluating the
expression
makeLazyExpression
public static Expression makeLazyExpression(Expression operand)
Create a LazyExpression (factory method)
operand - the expression to be evaluated lazily
process
public void process(XPathContext context)
throws XPathException Process the instruction, without returning any tail calls
- process in interface Expression
context - The dynamic context, giving access to the current node,
the current variables, etc.