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
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 Expression
Expression.PointerIterator, Expression.ValueIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intadd/subtract precedenceprotected static final intand precedenceprotected static final intcompare precedenceprotected static final intmultiply/divide/mod precedenceprotected static final intnegate precedenceprotected static final intor precedenceprotected static final intrelational expression precedenceprotected static final intunion precedenceFields inherited from class Expression
NOT_A_NUMBER, ONE, ZERO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompute(EvalContext context) Evaluates the expression.abstract ObjectcomputeValue(EvalContext context) Evaluates the expression.protected abstract intComputes the precedence of the operation.abstract StringReturns the XPath symbol for this operation, e.g.protected abstract booleanReturns true if the operation is not sensitive to the order of arguments, e.g.private Stringparenthesize(Expression expression, boolean left) Wrap an expression in parens if necessary.toString()Methods inherited from class Operation
computeContextDependent, getArgumentsMethods inherited from class Expression
isContextDependent, iterate, iteratePointers
-
Field Details
-
OR_PRECEDENCE
protected static final int OR_PRECEDENCEor precedence- See Also:
-
AND_PRECEDENCE
protected static final int AND_PRECEDENCEand precedence- See Also:
-
COMPARE_PRECEDENCE
protected static final int COMPARE_PRECEDENCEcompare precedence- See Also:
-
RELATIONAL_EXPR_PRECEDENCE
protected static final int RELATIONAL_EXPR_PRECEDENCErelational expression precedence- See Also:
-
ADD_PRECEDENCE
protected static final int ADD_PRECEDENCEadd/subtract precedence- See Also:
-
MULTIPLY_PRECEDENCE
protected static final int MULTIPLY_PRECEDENCEmultiply/divide/mod precedence- See Also:
-
NEGATE_PRECEDENCE
protected static final int NEGATE_PRECEDENCEnegate precedence- See Also:
-
UNION_PRECEDENCE
protected static final int UNION_PRECEDENCEunion precedence- See Also:
-
-
Constructor Details
-
CoreOperation
-
-
Method Details
-
compute
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
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
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
-
parenthesize
Wrap an expression in parens if necessary.- Parameters:
expression- other Expressionleft- whetherexpressionis left of this one.- Returns:
- String
-