org.apache.commons.jxpath.ri.compiler
Class CoreOperationCompare

java.lang.Object
  extended by org.apache.commons.jxpath.ri.compiler.Expression
      extended by org.apache.commons.jxpath.ri.compiler.Operation
          extended by org.apache.commons.jxpath.ri.compiler.CoreOperation
              extended by org.apache.commons.jxpath.ri.compiler.CoreOperationCompare
Direct Known Subclasses:
CoreOperationEqual, CoreOperationNotEqual

public abstract class CoreOperationCompare
extends CoreOperation

Common superclass for the implementations of Expression for the operations "=" and "!=".

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 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_PRECEDENCE
 
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Operation
args
 
Fields inherited from class org.apache.commons.jxpath.ri.compiler.Expression
NOT_A_NUMBER, ONE, ZERO
 
Constructor Summary
  CoreOperationCompare(Expression arg1, Expression arg2)
          Create a new CoreOperationCompare.
protected CoreOperationCompare(Expression arg1, Expression arg2, boolean invert)
          Create a new CoreOperationCompare.
 
Method Summary
 java.lang.Object computeValue(EvalContext context)
          Evaluates the expression.
protected  boolean contains(java.util.Iterator it, java.lang.Object value)
          Learn whether it contains value.
protected  boolean equal(EvalContext context, Expression left, Expression right)
          Compares two values.
protected  boolean equal(java.lang.Object l, java.lang.Object r)
          Learn whether l equals r in XPath terms.
protected  boolean findMatch(java.util.Iterator lit, java.util.Iterator rit)
          Learn whether lit intersects rit.
protected  int getPrecedence()
          Computes the precedence of the operation.
protected  boolean isSymmetric()
          Returns true if the operation is not sensitive to the order of arguments, e.g.
 
Methods inherited from class org.apache.commons.jxpath.ri.compiler.CoreOperation
compute, getSymbol, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CoreOperationCompare

public CoreOperationCompare(Expression arg1,
                            Expression arg2)
Create a new CoreOperationCompare.

Parameters:
arg1 - left operand
arg2 - right operand

CoreOperationCompare

protected CoreOperationCompare(Expression arg1,
                               Expression arg2,
                               boolean invert)
Create a new CoreOperationCompare.

Parameters:
arg1 - left operand
arg2 - right operand
invert - whether to invert (not) the comparison
Method Detail

computeValue

public 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 class CoreOperation
Parameters:
context - evaluation context
Returns:
Object

getPrecedence

protected int getPrecedence()
Description copied from class: CoreOperation
Computes the precedence of the operation.

Specified by:
getPrecedence in class CoreOperation
Returns:
int precedence

isSymmetric

protected boolean isSymmetric()
Description copied from class: CoreOperation
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".

Specified by:
isSymmetric in class CoreOperation
Returns:
boolean

equal

protected boolean equal(EvalContext context,
                        Expression left,
                        Expression right)
Compares two values.

Parameters:
context - evaluation context
left - operand
right - operand
Returns:
whether left = right in XPath terms

contains

protected boolean contains(java.util.Iterator it,
                           java.lang.Object value)
Learn whether it contains value.

Parameters:
it - Iterator to check
value - for which to look
Returns:
whether value was found

findMatch

protected boolean findMatch(java.util.Iterator lit,
                            java.util.Iterator rit)
Learn whether lit intersects rit.

Parameters:
lit - left Iterator
rit - right Iterator
Returns:
boolean

equal

protected boolean equal(java.lang.Object l,
                        java.lang.Object r)
Learn whether l equals r in XPath terms.

Parameters:
l - left operand
r - right operand
Returns:
whether l = r


Copyright © 2001-2011 Apache Software Foundation. All Rights Reserved.