org.josql.expressions
Class InExpression

java.lang.Object
  extended by org.josql.expressions.Expression
      extended by org.josql.expressions.BinaryExpression
          extended by org.josql.expressions.InExpression

public class InExpression
extends BinaryExpression

This class represents in [ NOT ] IN [ LIKE ] [ ALL ] expression. If any of the values listed are Maps or Collections then they are iterated over to see if a match is found. For Maps only the key values are checked. If you pass a list then it is iterated over using a for construct rather than an Iterator since it's much faster.

Note: due to the way that the expression is designed it is POSSIBLE to have a binary expression in the in list, however at this time that is not supported since it can lead to an ambiguous result, for example: true IN (true, false) has no sensible meaning.


Field Summary
 
Fields inherited from class org.josql.expressions.BinaryExpression
left, right
 
Constructor Summary
InExpression()
           
 
Method Summary
 void addItem(Expression e)
           
 List getItems()
           
 void init(Query q)
          Initialise the IN expression.
 boolean isAll()
           
 boolean isDoLike()
           
 boolean isIgnoreCase()
           
 boolean isNot()
           
 boolean isTrue(Object o, Query q)
          Return whether this expression evaulates to true.
 void setAll(boolean v)
           
 void setDoLike(boolean d)
           
 void setIgnoreCase(boolean v)
           
 void setItems(List items)
           
 void setNot(boolean v)
           
 String toString()
          Return a string representation of this expression.
 
Methods inherited from class org.josql.expressions.BinaryExpression
getExpectedReturnType, getLeft, getRight, getValue, hasFixedResult, setLeft, setRight
 
Methods inherited from class org.josql.expressions.Expression
isBracketed, setBracketed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InExpression

public InExpression()
Method Detail

init

public void init(Query q)
          throws QueryParseException
Initialise the IN expression. Init the LHS and then all of the values in the brackets.

Overrides:
init in class BinaryExpression
Parameters:
q - The Query object.
Throws:
QueryParseException - If something goes wrong with the init.

setIgnoreCase

public void setIgnoreCase(boolean v)

isIgnoreCase

public boolean isIgnoreCase()

isAll

public boolean isAll()

setAll

public void setAll(boolean v)

isDoLike

public boolean isDoLike()

setDoLike

public void setDoLike(boolean d)

setItems

public void setItems(List items)

getItems

public List getItems()

addItem

public void addItem(Expression e)

isNot

public boolean isNot()

setNot

public void setNot(boolean v)

isTrue

public boolean isTrue(Object o,
                      Query q)
               throws QueryExecutionException
Return whether this expression evaulates to true. If any of the values on RHS are Maps (keys only) or Collections then they are iterated over and checked against the LHS.

Specified by:
isTrue in class Expression
Parameters:
o - The current object to perform the expression on.
q - The Query object.
Returns:
true if the LHS is "equal" (as determined by: Utilities.isEquals(Object,Object)) to any of the values in the brackets. If this is a NOT expression then the result is negated.
Throws:
QueryExecutionException - If the expression cannot be evaluated.

toString

public String toString()
Return a string representation of this expression. In the form: Expression [ NOT ] [$]IN [ LIKE ] [ ALL ] ( Expression [ , Expression* ] )

Specified by:
toString in class Expression
Returns:
A string representation of this expression.


  Copyright © 2008 Gary Bentley. All Rights Reserved.