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

java.lang.Object
  extended by org.apache.commons.jxpath.ri.compiler.Expression
      extended by org.apache.commons.jxpath.ri.compiler.Operation
          extended by org.apache.commons.jxpath.ri.compiler.CoreOperation
Direct Known Subclasses:
CoreOperationAdd, CoreOperationAnd, CoreOperationCompare, CoreOperationDivide, CoreOperationMod, CoreOperationMultiply, CoreOperationNegate, CoreOperationOr, CoreOperationRelationalExpression, CoreOperationSubtract, CoreOperationUnion

public abstract class CoreOperation
extends Operation

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

Version:
$Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
Author:
Dmitri Plotnikov

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator
 
Field Summary
protected static int ADD_PRECEDENCE
          add/subtract precedence
protected static int AND_PRECEDENCE
          and precedence
protected static int COMPARE_PRECEDENCE
          compare precedence
protected static int MULTIPLY_PRECEDENCE
          multiply/divide/mod precedence
protected static int NEGATE_PRECEDENCE
          negate precedence
protected static int OR_PRECEDENCE
          or precedence
protected static int RELATIONAL_EXPR_PRECEDENCE
          relational expression precedence
protected static int UNION_PRECEDENCE
          union precedence
 
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)
          Create a new CoreOperation.
 
Method Summary
 Object compute(EvalContext context)
          Evaluates the expression.
abstract  Object computeValue(EvalContext context)
          Evaluates the expression.
protected abstract  int getPrecedence()
          Computes the precedence of the operation.
abstract  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.
 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
 

Field Detail

OR_PRECEDENCE

protected static final int OR_PRECEDENCE
or precedence

See Also:
Constant Field Values

AND_PRECEDENCE

protected static final int AND_PRECEDENCE
and precedence

See Also:
Constant Field Values

COMPARE_PRECEDENCE

protected static final int COMPARE_PRECEDENCE
compare precedence

See Also:
Constant Field Values

RELATIONAL_EXPR_PRECEDENCE

protected static final int RELATIONAL_EXPR_PRECEDENCE
relational expression precedence

See Also:
Constant Field Values

ADD_PRECEDENCE

protected static final int ADD_PRECEDENCE
add/subtract precedence

See Also:
Constant Field Values

MULTIPLY_PRECEDENCE

protected static final int MULTIPLY_PRECEDENCE
multiply/divide/mod precedence

See Also:
Constant Field Values

NEGATE_PRECEDENCE

protected static final int NEGATE_PRECEDENCE
negate precedence

See Also:
Constant Field Values

UNION_PRECEDENCE

protected static final int UNION_PRECEDENCE
union precedence

See Also:
Constant Field Values
Constructor Detail

CoreOperation

public CoreOperation(Expression[] args)
Create a new CoreOperation.

Parameters:
args - Expression[]
Method Detail

compute

public Object compute(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:
compute in class Expression
Parameters:
context - evaluation context
Returns:
Object

computeValue

public abstract 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
Parameters:
context - evaluation context
Returns:
Object

getSymbol

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

Returns:
String symbol

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

Returns:
boolean

getPrecedence

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

Returns:
int precedence

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2008 The Apache Software Foundation. All Rights Reserved.