Class CoreOperation
- java.lang.Object
-
- org.apache.commons.jxpath.ri.compiler.Expression
-
- org.apache.commons.jxpath.ri.compiler.Operation
-
- 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) $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected static intADD_PRECEDENCEadd/subtract precedenceprotected static intAND_PRECEDENCEand precedenceprotected static intCOMPARE_PRECEDENCEcompare precedenceprotected static intMULTIPLY_PRECEDENCEmultiply/divide/mod precedenceprotected static intNEGATE_PRECEDENCEnegate precedenceprotected static intOR_PRECEDENCEor precedenceprotected static intRELATIONAL_EXPR_PRECEDENCErelational expression precedenceprotected static intUNION_PRECEDENCEunion precedence-
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE, ZERO
-
-
Constructor Summary
Constructors Constructor Description CoreOperation(Expression[] args)Create a new CoreOperation.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Objectcompute(EvalContext context)Evaluates the expression.abstract java.lang.ObjectcomputeValue(EvalContext context)Evaluates the expression.protected abstract intgetPrecedence()Computes the precedence of the operation.abstract java.lang.StringgetSymbol()Returns the XPath symbol for this operation, e.g.protected abstract booleanisSymmetric()Returns true if the operation is not sensitive to the order of arguments, e.g.private java.lang.Stringparenthesize(Expression expression, boolean left)Wrap an expression in parens if necessary.java.lang.StringtoString()-
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
-
-
-
-
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 java.lang.Object compute(EvalContext context)
Description copied from class:ExpressionEvaluates the expression. If the result is a node set, returns the first element of the node set.- Specified by:
computein classExpression- Parameters:
context- evaluation context- Returns:
- Object
-
computeValue
public abstract java.lang.Object computeValue(EvalContext context)
Description copied from class:ExpressionEvaluates the expression. If the result is a node set, returns the first element of the node set.- Specified by:
computeValuein classExpression- Parameters:
context- evaluation context- Returns:
- Object
-
getSymbol
public abstract java.lang.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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
parenthesize
private java.lang.String parenthesize(Expression expression, boolean left)
Wrap an expression in parens if necessary.- Parameters:
expression- other Expressionleft- whetherexpressionis left of this one.- Returns:
- String
-
-