Package 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 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Expression.PointerIterator`
  Pointer iterator
  `static class`
  `Expression.ValueIterator`
  Value Iterator

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final Double`
  `NOT_A_NUMBER`
  NaN
  `protected static final Double`
  `ONE`
  One
  `protected static final Double`
  `ZERO`
  Zero

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Expression()`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract Object`
  `compute(EvalContext context)`
  Evaluates the expression.
  `abstract boolean`
  `computeContextDependent()`
  Implemented by subclasses and result is cached by isContextDependent()
  `abstract 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.
  `Iterator`
  `iterate(EvalContext context)`
  Iterate over the values from the specified context.
  `Iterator`
  `iteratePointers(EvalContext context)`
  Iterate over the pointers from the specified context.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ZERO

    protected static final Double ZERO
    Zero

  - ### ONE

    protected static final Double ONE
    One

  - ### NOT_A_NUMBER

    protected static final Double NOT_A_NUMBER
    NaN

- ## Constructor Details

  - ### Expression

    public Expression()
    Constructs a new instance.

- ## Method Details

  - ### compute

    public abstract Object compute(EvalContext context)
    Evaluates the expression. If the result is a node set, returns the first element of the node set.
    Parameters:
      `context` - evaluation context
    Returns:
      Object

  - ### computeContextDependent

    public abstract boolean computeContextDependent()
    Implemented by subclasses and result is cached by isContextDependent()
    Returns:
      calculated context-dependentness as boolean

  - ### computeValue

    public abstract Object computeValue(EvalContext context)
    Evaluates the expression. If the result is a node set, returns the first element of the node set.
    Parameters:
      `context` - evaluation context
    Returns:
      Object

  - ### isContextDependent

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

  - ### iterate

    public Iterator iterate(EvalContext context)
    Iterate over the values from the specified context.
    Parameters:
      `context` - evaluation context
    Returns:
      value Iterator

  - ### iteratePointers

    public Iterator iteratePointers(EvalContext context)
    Iterate over the pointers from the specified context.
    Parameters:
      `context` - evaluation context
    Returns:
      pointer Iterator