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

java.lang.Object
  |
  +--org.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.3 $ $Date: 2002/05/08 00:39:59 $
Author:
Dmitri Plotnikov

Nested Class Summary
static class Expression.PointerIterator
           
static class Expression.ValueIterator
           
 
Field Summary
protected static java.lang.Double NaN
           
protected static java.lang.Double ONE
           
static int OP_AND
           
static int OP_CONSTANT
           
static int OP_CORE_FUNCTION
           
static int OP_DIV
           
static int OP_EQ
           
static int OP_EXPRESSION_PATH
           
static int OP_FUNCTION
           
static int OP_GT
           
static int OP_GTE
           
static int OP_KEY_LOOKUP
           
static int OP_LOCATION_PATH
           
static int OP_LT
           
static int OP_LTE
           
static int OP_MINUS
           
static int OP_MOD
           
static int OP_MULT
           
static int OP_NE
           
static int OP_OR
           
static int OP_STEP
           
static int OP_SUM
           
static int OP_UNARY_MINUS
           
static int OP_UNION
           
static int OP_VAR
           
protected static java.lang.Double ZERO
           
 
Constructor Summary
protected Expression(int typeCode)
           
 
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.
protected  Expression[] getArguments()
           
 int getExpressionTypeCode()
           
 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)
           
protected  java.lang.String opCodeToString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OP_SUM

public static final int OP_SUM
See Also:
Constant Field Values

OP_MINUS

public static final int OP_MINUS
See Also:
Constant Field Values

OP_MULT

public static final int OP_MULT
See Also:
Constant Field Values

OP_DIV

public static final int OP_DIV
See Also:
Constant Field Values

OP_CONSTANT

public static final int OP_CONSTANT
See Also:
Constant Field Values

OP_STEP

public static final int OP_STEP
See Also:
Constant Field Values

OP_AND

public static final int OP_AND
See Also:
Constant Field Values

OP_OR

public static final int OP_OR
See Also:
Constant Field Values

OP_UNARY_MINUS

public static final int OP_UNARY_MINUS
See Also:
Constant Field Values

OP_MOD

public static final int OP_MOD
See Also:
Constant Field Values

OP_LT

public static final int OP_LT
See Also:
Constant Field Values

OP_GT

public static final int OP_GT
See Also:
Constant Field Values

OP_LTE

public static final int OP_LTE
See Also:
Constant Field Values

OP_GTE

public static final int OP_GTE
See Also:
Constant Field Values

OP_EQ

public static final int OP_EQ
See Also:
Constant Field Values

OP_NE

public static final int OP_NE
See Also:
Constant Field Values

OP_VAR

public static final int OP_VAR
See Also:
Constant Field Values

OP_FUNCTION

public static final int OP_FUNCTION
See Also:
Constant Field Values

OP_UNION

public static final int OP_UNION
See Also:
Constant Field Values

OP_LOCATION_PATH

public static final int OP_LOCATION_PATH
See Also:
Constant Field Values

OP_EXPRESSION_PATH

public static final int OP_EXPRESSION_PATH
See Also:
Constant Field Values

OP_CORE_FUNCTION

public static final int OP_CORE_FUNCTION
See Also:
Constant Field Values

OP_KEY_LOOKUP

public static final int OP_KEY_LOOKUP
See Also:
Constant Field Values

ZERO

protected static java.lang.Double ZERO

ONE

protected static java.lang.Double ONE

NaN

protected static java.lang.Double NaN
Constructor Detail

Expression

protected Expression(int typeCode)
Method Detail

getExpressionTypeCode

public int getExpressionTypeCode()

getArguments

protected Expression[] getArguments()

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()


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

opCodeToString

protected java.lang.String opCodeToString()

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)


Copyright (c) 2001 - Apache Software Foundation