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

java.lang.Object
  extended byorg.apache.commons.jxpath.ri.compiler.Expression
      extended byorg.apache.commons.jxpath.ri.compiler.Operation
          extended byorg.apache.commons.jxpath.ri.compiler.CoreOperation
Direct Known Subclasses:
CoreOperationAdd, CoreOperationAnd, CoreOperationCompare, CoreOperationDivide, CoreOperationGreaterThan, CoreOperationGreaterThanOrEqual, CoreOperationLessThan, CoreOperationLessThanOrEqual, CoreOperationMod, CoreOperationMultiply, CoreOperationNegate, CoreOperationOr, CoreOperationSubtract, CoreOperationUnion

public abstract class CoreOperation
extends Operation

The common subclass for tree elements representing core operations like "+", "- ", "*" etc.

Version:
$Revision: 1.14 $ $Date: 2004/02/29 14:17:39 $
Author:
Dmitri Plotnikov

Nested Class Summary
 
Nested classes inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator
 
Field Summary
 
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Operation
args
 
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE, ZERO
 
Constructor Summary
CoreOperation(Expression[] args)
           
 
Method Summary
 java.lang.Object compute(EvalContext context)
           
abstract  java.lang.Object computeValue(EvalContext context)
          Evaluates the expression.
protected abstract  int getPrecedence()
          Computes the precedence of the operation.
abstract  java.lang.String getSymbol()
          Returns the XPath symbol for this operation, e.g.
protected abstract  boolean isSymmetric()
          Returns true if the operation is not sensitive to the order of arguments, e.g.
private  java.lang.String parenthesize(Expression expression, boolean left)
           
 java.lang.String toString()
           
 
Methods inherited from class org.apache.commons.jxpath.ri.compiler.Operation
computeContextDependent, getArguments
 
Methods inherited from class org.apache.commons.jxpath.ri.compiler.Expression
isContextDependent, iterate, iteratePointers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CoreOperation

public CoreOperation(Expression[] args)
Method Detail

compute

public java.lang.Object compute(EvalContext context)
Specified by:
compute in class Expression

computeValue

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

Specified by:
computeValue in class Expression

getSymbol

public abstract java.lang.String getSymbol()
Returns the XPath symbol for this operation, e.g. "+", "div", etc.


isSymmetric

protected abstract boolean isSymmetric()
Returns true if the operation is not sensitive to the order of arguments, e.g. "=", "and" etc, and false if it is, e.g. "<=", "div".


getPrecedence

protected abstract int getPrecedence()
Computes the precedence of the operation.


toString

public java.lang.String toString()

parenthesize

private java.lang.String parenthesize(Expression expression,
                                      boolean left)