net.sf.saxon.expr
Class LazyExpression

java.lang.Object
  extended bynet.sf.saxon.expr.ComputedExpression
      extended bynet.sf.saxon.expr.UnaryExpression
          extended bynet.sf.saxon.expr.LazyExpression
All Implemented Interfaces:
Container, Expression, InstructionInfoProvider, java.io.Serializable, javax.xml.transform.SourceLocator

public class LazyExpression
extends UnaryExpression

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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.UnaryExpression
operand
 
Fields inherited from class net.sf.saxon.expr.ComputedExpression
locationId, staticProperties
 
Fields inherited from interface net.sf.saxon.expr.Expression
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD
 
Method Summary
protected  java.lang.String displayOperator(NamePool pool)
          Give a string representation of the operator for use in diagnostics
 Item evaluateItem(XPathContext context)
          Evaluate an expression as a single item.
 SequenceIterator iterate(XPathContext context)
          Return an Iterator to iterate over the values of a sequence.
static Expression makeLazyExpression(Expression operand)
           
 void process(XPathContext context)
          Process the instruction, without returning any tail calls
 
Methods inherited from class net.sf.saxon.expr.UnaryExpression
computeCardinality, computeSpecialProperties, display, equals, getBaseExpression, getItemType, hashCode, iterateSubExpressions, optimize, promote, simplify, typeCheck
 
Methods inherited from class net.sf.saxon.expr.ComputedExpression
adoptChildExpression, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, dynamicError, effectiveBooleanValue, evaluateAsString, getCardinality, getColumnNumber, getConstructType, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getLineNumber, getLocationId, getLocationProvider, getParentExpression, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasBadParentPointer, markTailFunctionCalls, resetStaticProperties, setLocationId, setParentExpression, suppressValidation, typeError, typeError
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makeLazyExpression

public static Expression makeLazyExpression(Expression operand)

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.

Specified by:
evaluateItem in interface Expression
Overrides:
evaluateItem in class ComputedExpression
Parameters:
context - The context in which the expression is to be evaluated
Returns:
the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
Throws:
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.

Specified by:
iterate in interface Expression
Overrides:
iterate in class ComputedExpression
Parameters:
context - supplies the context for evaluation
Returns:
a SequenceIterator that can be used to iterate over the result of the expression
Throws:
XPathException - if any dynamic error occurs evaluating the expression

process

public void process(XPathContext context)
             throws XPathException
Process the instruction, without returning any tail calls

Specified by:
process in interface Expression
Overrides:
process in class ComputedExpression
Parameters:
context - The dynamic context, giving access to the current node, the current variables, etc.
Throws:
XPathException

displayOperator

protected java.lang.String displayOperator(NamePool pool)
Description copied from class: UnaryExpression
Give a string representation of the operator for use in diagnostics

Specified by:
displayOperator in class UnaryExpression
Returns:
the operator, as a string