Class CoreOperationRelationalExpression
java.lang.Object
org.apache.commons.jxpath.ri.compiler.Expression
org.apache.commons.jxpath.ri.compiler.Operation
org.apache.commons.jxpath.ri.compiler.CoreOperation
org.apache.commons.jxpath.ri.compiler.CoreOperationRelationalExpression
- Direct Known Subclasses:
CoreOperationGreaterThan,CoreOperationGreaterThanOrEqual,CoreOperationLessThan,CoreOperationLessThanOrEqual
Base implementation of Expression for the operations ">", ">=", "<", "<=".
- Since:
- JXPath 1.3
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.jxpath.ri.compiler.Expression
Expression.PointerIterator, Expression.ValueIterator -
Field Summary
Fields inherited from class org.apache.commons.jxpath.ri.compiler.CoreOperation
ADD_PRECEDENCE, AND_PRECEDENCE, COMPARE_PRECEDENCE, MULTIPLY_PRECEDENCE, NEGATE_PRECEDENCE, OR_PRECEDENCE, RELATIONAL_EXPR_PRECEDENCE, UNION_PRECEDENCEFields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE, ZERO -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new CoreOperationRelationalExpression. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanCompare left to right.final ObjectcomputeValue(EvalContext context) Evaluates the expression.private booleancontainsMatch(Object value, Iterator it) Tests whether any element returned from an Iterator matches a given value.private booleancontainsMatch(Iterator it, Object value) Tests whether any element returned from an Iterator matches a given value.protected abstract booleanevaluateCompare(int compare) Template method for subclasses to evaluate the result of a comparison.private booleanTests whether there is an intersection between two Iterators.protected final intComputes the precedence of the operation.protected final booleanReturns true if the operation is not sensitive to the order of arguments, e.g.private ObjectReduce an operand for comparison.Methods inherited from class org.apache.commons.jxpath.ri.compiler.CoreOperation
compute, getSymbol, toStringMethods inherited from class org.apache.commons.jxpath.ri.compiler.Operation
computeContextDependent, getArgumentsMethods inherited from class org.apache.commons.jxpath.ri.compiler.Expression
isContextDependent, iterate, iteratePointers
-
Constructor Details
-
CoreOperationRelationalExpression
Constructs a new CoreOperationRelationalExpression.- Parameters:
args- arguments
-
-
Method Details
-
compute
Compare left to right.- Parameters:
left- left operandright- right operand- Returns:
- operation success/failure
-
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 classCoreOperation- Parameters:
context- evaluation context- Returns:
- Object
-
containsMatch
Tests whether any element returned from an Iterator matches a given value.- Parameters:
it- Iteratorvalue- to look for- Returns:
- whether a match was found
-
containsMatch
Tests whether any element returned from an Iterator matches a given value.- Parameters:
value- to look forit- Iterator- Returns:
- whether a match was found
-
evaluateCompare
protected abstract boolean evaluateCompare(int compare) Template method for subclasses to evaluate the result of a comparison.- Parameters:
compare- result of comparison to evaluate- Returns:
- ultimate operation success/failure
-
findMatch
Tests whether there is an intersection between two Iterators.- Parameters:
lit- left Iteratorrit- right Iterator- Returns:
- whether a match was found
-
getPrecedence
protected final int getPrecedence()Description copied from class:CoreOperationComputes the precedence of the operation.- Specified by:
getPrecedencein classCoreOperation- Returns:
- int precedence
-
isSymmetric
protected final boolean isSymmetric()Description copied from class:CoreOperationReturns true if the operation is not sensitive to the order of arguments, e.g. "=", "and" etc, and false if it is, e.g. "<=", "div".- Specified by:
isSymmetricin classCoreOperation- Returns:
- boolean
-
reduce
Reduce an operand for comparison.- Parameters:
o- Object to reduce- Returns:
- reduced operand
-