org.apache.commons.jxpath.ri.compiler
Class Expression

java.lang.Object
  extended byorg.apache.commons.jxpath.ri.compiler.Expression
Direct Known Subclasses:
Constant, Operation, Path, VariableReference

public abstract class Expression
extends java.lang.Object

Common superclass for several types of nodes in the parse tree. Provides APIs for optimization of evaluation of expressions. Specifically, an expression only needs to executed once during the evaluation of an xpath if that expression is context-independent. Expression.isContextDependent() provides that hint.

Version:
$Revision: 1.10 $ $Date: 2004/02/29 14:17:38 $
Author:
Dmitri Plotnikov

Nested Class Summary
static class Expression.PointerIterator
           
static class Expression.ValueIterator
           
 
Field Summary
private  boolean contextDependencyKnown
           
private  boolean contextDependent
           
protected static java.lang.Double NOT_A_NUMBER
           
protected static java.lang.Double ONE
           
protected static java.lang.Double ZERO
           
 
Constructor Summary
Expression()
           
 
Method Summary
abstract  java.lang.Object compute(EvalContext context)
           
abstract  boolean computeContextDependent()
          Implemented by subclasses and result is cached by isContextDependent()
abstract  java.lang.Object computeValue(EvalContext context)
          Evaluates the expression.
 boolean isContextDependent()
          Returns true if this expression should be re-evaluated each time the current position in the context changes.
 java.util.Iterator iterate(EvalContext context)
           
 java.util.Iterator iteratePointers(EvalContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

protected static final java.lang.Double ZERO

ONE

protected static final java.lang.Double ONE

NOT_A_NUMBER

protected static final java.lang.Double NOT_A_NUMBER

contextDependencyKnown

private boolean contextDependencyKnown

contextDependent

private boolean contextDependent
Constructor Detail

Expression

public Expression()
Method Detail

isContextDependent

public boolean isContextDependent()
Returns true if this expression should be re-evaluated each time the current position in the context changes.


computeContextDependent

public abstract boolean computeContextDependent()
Implemented by subclasses and result is cached by isContextDependent()


computeValue

public abstract java.lang.Object computeValue(EvalContext context)
Evaluates the expression. If the result is a node set, returns the first element of the node set.


compute

public abstract java.lang.Object compute(EvalContext context)

iterate

public java.util.Iterator iterate(EvalContext context)

iteratePointers

public java.util.Iterator iteratePointers(EvalContext context)