Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.josql.expressions
Class InExpression  view InExpression download InExpression.java

java.lang.Object
  extended byorg.josql.expressions.Expression
      extended byorg.josql.expressions.BinaryExpression
          extended byorg.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.

Last Modified By: $Author: barrygently $
Last Modified On: $Date: 2005/04/28 05:48:59 $
Current Revision: $Revision: 1.3 $


Field Summary
private  boolean all
           
private  boolean doLike
           
private  boolean ignoreCase
           
private  java.util.List items
           
private  java.util.Map lPats
           
private  boolean not
           
 
Fields inherited from class org.josql.expressions.BinaryExpression
left, right
 
Fields inherited from class org.josql.expressions.Expression
 
Constructor Summary
InExpression()
           
 
Method Summary
 void addItem(Expression e)
           
private  boolean compareCollection(java.lang.Object o, java.util.Collection c, java.lang.String v, java.lang.String wc)
           
private  boolean compareItem(java.lang.Object o, java.lang.Object n, java.lang.String v, java.lang.String wc)
           
private  boolean compareList(java.lang.Object o, java.util.List l, java.lang.String v, java.lang.String wc)
           
private  boolean compareMap(java.lang.Object o, java.util.Map m, java.lang.String v, java.lang.String wc)
           
 java.util.List getItems()
           
 void init(org.josql.Query q)
          Initialise the IN expression.
 boolean isAll()
           
 boolean isDoLike()
           
 boolean isIgnoreCase()
           
 boolean isNot()
           
 boolean isTrue(java.lang.Object o, org.josql.Query q)
          Return whether this expression evaulates to true.
 void setAll(boolean v)
           
 void setDoLike(boolean d)
           
 void setIgnoreCase(boolean v)
           
 void setItems(java.util.List items)
           
 void setNot(boolean v)
           
 java.lang.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
 

Field Detail

items

private java.util.List items

not

private boolean not

doLike

private boolean doLike

all

private boolean all

lPats

private java.util.Map lPats

ignoreCase

private boolean ignoreCase
Constructor Detail

InExpression

public InExpression()
Method Detail

init

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

Overrides:
init in class BinaryExpression

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(java.util.List items)

getItems

public java.util.List getItems()

addItem

public void addItem(Expression e)

isNot

public boolean isNot()

setNot

public void setNot(boolean v)

isTrue

public boolean isTrue(java.lang.Object o,
                      org.josql.Query q)
               throws org.josql.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

compareCollection

private boolean compareCollection(java.lang.Object o,
                                  java.util.Collection c,
                                  java.lang.String v,
                                  java.lang.String wc)

compareList

private boolean compareList(java.lang.Object o,
                            java.util.List l,
                            java.lang.String v,
                            java.lang.String wc)

compareItem

private boolean compareItem(java.lang.Object o,
                            java.lang.Object n,
                            java.lang.String v,
                            java.lang.String wc)

compareMap

private boolean compareMap(java.lang.Object o,
                           java.util.Map m,
                           java.lang.String v,
                           java.lang.String wc)

toString

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

Specified by:
toString in class Expression