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) $
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
add/subtract precedenceprotected static final int
and precedenceprotected static final int
compare precedenceprotected static final int
multiply/divide/mod precedenceprotected static final int
negate precedenceprotected static final int
or precedenceprotected static final int
relational expression precedenceprotected static final int
union precedenceFields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE, ZERO
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompute
(EvalContext context) Evaluates the expression.abstract Object
computeValue
(EvalContext context) Evaluates the expression.protected abstract int
Computes the precedence of the operation.abstract String
Returns the XPath symbol for this operation, e.g.protected abstract boolean
Returns true if the operation is not sensitive to the order of arguments, e.g.private String
parenthesize
(Expression expression, boolean left) Wrap an expression in parens if necessary.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
-
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
Create a new CoreOperation.- Parameters:
args
- Expression[]
-
-
Method Details
-
compute
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 classExpression
- Parameters:
context
- evaluation context- Returns:
- Object
-
computeValue
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 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
- whetherexpression
is left of this one.- Returns:
- String
-