Class 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: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
    Author:
    Dmitri Plotnikov
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.Double NOT_A_NUMBER
      NaN
      protected static java.lang.Double ONE
      one
      protected static java.lang.Double ZERO
      zero
    • Constructor Summary

      Constructors 
      Constructor Description
      Expression()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract java.lang.Object compute​(EvalContext context)
      Evaluates the expression.
      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)
      Iterate over the values from the specified context.
      java.util.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 Detail

      • ZERO

        protected static final java.lang.Double ZERO
        zero
      • ONE

        protected static final java.lang.Double ONE
        one
      • NOT_A_NUMBER

        protected static final java.lang.Double NOT_A_NUMBER
        NaN
    • 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.
        Returns:
        boolean
      • computeContextDependent

        public abstract boolean computeContextDependent()
        Implemented by subclasses and result is cached by isContextDependent()
        Returns:
        calculated context-dependentness as boolean
      • 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.
        Parameters:
        context - evaluation context
        Returns:
        Object
      • compute

        public abstract java.lang.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
      • iterate

        public java.util.Iterator iterate​(EvalContext context)
        Iterate over the values from the specified context.
        Parameters:
        context - evaluation context
        Returns:
        value Iterator
      • iteratePointers

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