org.exist.xpath
Class OpEquals

java.lang.Object
  extended byorg.exist.xpath.PathExpr
      extended byorg.exist.xpath.BinaryOp
          extended byorg.exist.xpath.OpEquals
All Implemented Interfaces:
Expression

public class OpEquals
extends BinaryOp

compare two operands by =, <, > etc..

Author:
Wolfgang Meier

Field Summary
protected  FunContains containsExpr
           
protected  int relation
           
protected  NodeSet temp
           
 
Fields inherited from class org.exist.xpath.PathExpr
docs, inPredicate, keepVirtual, pool, steps
 
Constructor Summary
OpEquals(BrokerPool pool, Expression left, Expression right, int relation)
          Constructor for the OpEquals object
OpEquals(BrokerPool pool, int relation)
          Constructor for the OpEquals object
 
Method Summary
protected  Value booleanCompare(Expression left, Expression right, DocumentSet docs, NodeSet context, NodeProxy node)
          Left argument is boolean: Convert right argument to a bool.
protected  boolean cmpBooleans(boolean left, boolean right)
          Description of the Method
protected  boolean cmpNumbers(double left, double right)
          Description of the Method
protected  boolean compareStrings(java.lang.String left, java.lang.String right)
          Description of the Method
 Value eval(DocumentSet docs, NodeSet context, NodeProxy node)
          Compare left and right statement.
protected  Value nodeSetCompare(Expression left, Expression right, DocumentSet docs, NodeSet context, NodeProxy node)
          Left argument is a node set.
protected  Value numberCompare(Expression left, Expression right, DocumentSet docs, NodeSet context, NodeProxy node)
          Left argument is a number: Convert right argument to a number for every node in context.
 java.lang.String pprint()
          Description of the Method
 DocumentSet preselect(DocumentSet in_docs)
          check relevant documents.
 int returnsType()
          Description of the Method
protected  Value stringCompare(Expression left, Expression right, DocumentSet docs, NodeSet context, NodeProxy node)
           
protected  void switchOperands()
           
 
Methods inherited from class org.exist.xpath.BinaryOp
getLeft, getRight
 
Methods inherited from class org.exist.xpath.PathExpr
add, add, addDocument, addPath, addPredicate, getDocumentSet, getExpression, getLength, preselect, setDocumentSet, setFirstExpression, setInPredicate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relation

protected int relation

temp

protected NodeSet temp

containsExpr

protected FunContains containsExpr
Constructor Detail

OpEquals

public OpEquals(BrokerPool pool,
                int relation)
Constructor for the OpEquals object

Parameters:
relation - Description of the Parameter

OpEquals

public OpEquals(BrokerPool pool,
                Expression left,
                Expression right,
                int relation)
Constructor for the OpEquals object

Parameters:
left - Description of the Parameter
right - Description of the Parameter
relation - Description of the Parameter
Method Detail

booleanCompare

protected Value booleanCompare(Expression left,
                               Expression right,
                               DocumentSet docs,
                               NodeSet context,
                               NodeProxy node)
Left argument is boolean: Convert right argument to a bool.

Parameters:
left - Description of the Parameter
right - Description of the Parameter
docs - Description of the Parameter
context - Description of the Parameter
node - Description of the Parameter
Returns:
Description of the Return Value

cmpBooleans

protected boolean cmpBooleans(boolean left,
                              boolean right)
Description of the Method

Parameters:
left - Description of the Parameter
right - Description of the Parameter
Returns:
Description of the Return Value

cmpNumbers

protected boolean cmpNumbers(double left,
                             double right)
Description of the Method

Parameters:
left - Description of the Parameter
right - Description of the Parameter
Returns:
Description of the Return Value

compareStrings

protected boolean compareStrings(java.lang.String left,
                                 java.lang.String right)
Description of the Method

Parameters:
left - Description of the Parameter
right - Description of the Parameter
Returns:
Description of the Return Value

eval

public Value eval(DocumentSet docs,
                  NodeSet context,
                  NodeProxy node)
Compare left and right statement. Comparison is done like described in the spec. If one argument returns a node set, we handle that first. Otherwise if one argument is a number, process that. Third follows string, boolean is last. If necessary move right to left and left to right.

Specified by:
eval in interface Expression
Specified by:
eval in class BinaryOp
Parameters:
docs - Description of the Parameter
context - Description of the Parameter
node - Description of the Parameter
Returns:
Description of the Return Value

nodeSetCompare

protected Value nodeSetCompare(Expression left,
                               Expression right,
                               DocumentSet docs,
                               NodeSet context,
                               NodeProxy node)
Left argument is a node set. If right arg is a string-literal, call broker.getNodesEqualTo - which is fast. If it is a number, convert it. If it is a boolean, get the part of context which matches the left expression, get the right value for every node of context and compare it with the left-part.

Parameters:
left - Description of the Parameter
right - Description of the Parameter
docs - Description of the Parameter
context - Description of the Parameter
node - Description of the Parameter
Returns:
Description of the Return Value

numberCompare

protected Value numberCompare(Expression left,
                              Expression right,
                              DocumentSet docs,
                              NodeSet context,
                              NodeProxy node)
Left argument is a number: Convert right argument to a number for every node in context.

Parameters:
left - Description of the Parameter
right - Description of the Parameter
docs - Description of the Parameter
context - Description of the Parameter
node - Description of the Parameter
Returns:
Description of the Return Value

pprint

public java.lang.String pprint()
Description of the Method

Specified by:
pprint in interface Expression
Specified by:
pprint in class BinaryOp
Returns:
Description of the Return Value

preselect

public DocumentSet preselect(DocumentSet in_docs)
check relevant documents. Does nothing here.

Specified by:
preselect in interface Expression
Specified by:
preselect in class BinaryOp
Parameters:
in_docs - Description of the Parameter
Returns:
Description of the Return Value

returnsType

public int returnsType()
Description of the Method

Specified by:
returnsType in interface Expression
Overrides:
returnsType in class BinaryOp
Returns:
Description of the Return Value

stringCompare

protected Value stringCompare(Expression left,
                              Expression right,
                              DocumentSet docs,
                              NodeSet context,
                              NodeProxy node)

switchOperands

protected void switchOperands()


Copyright (C) Wolfgang Meier. All rights reserved.