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 int
ADD_PRECEDENCE
add/subtract precedenceprotected static int
AND_PRECEDENCE
and precedenceprotected static int
COMPARE_PRECEDENCE
compare precedenceprotected static int
MULTIPLY_PRECEDENCE
multiply/divide/mod precedenceprotected static int
NEGATE_PRECEDENCE
negate precedenceprotected static int
OR_PRECEDENCE
or precedenceprotected static int
RELATIONAL_EXPR_PRECEDENCE
relational expression precedenceprotected static int
UNION_PRECEDENCE
union 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.Object
compute(EvalContext context)
Evaluates the expression.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)
Wrap an expression in parens if necessary.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
-
-
-
-
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: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
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 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:
toString
in classjava.lang.Object
-
parenthesize
private java.lang.String parenthesize(Expression expression, boolean left)
Wrap an expression in parens if necessary.- Parameters:
expression
- other Expressionleft
- whetherexpression
is left of this one.- Returns:
- String
-
-