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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.josql.expressions.Expression
      extended byorg.josql.expressions.BinaryExpression
          extended byorg.josql.expressions.LikeExpression

public class LikeExpression
extends BinaryExpression

Represents a LHS [ NOT ] [ $ ] LIKE RHS expression. It should be noted that unlike "normal" SQL the "." character is not supported since in practice it tends to be redundant.

It is possible to use: $ in front of the "LIKE" to indicate that a case insensitive comparison should be performed, for example:

   SELECT *
   FROM   java.lang.String
   WHERE  toString $LIKE '%value'
 

Also, the LHS or RHS can be built up using the "+" operator to concatenate a string, thus:

   SELECT *
   FROM   java.lang.String
   WHREE  toString $LIKE '%' + :myValue
 

In this way (using the named bind variable) you don't have to provide the wildcard.

It is also possible to specify your own "wildcard" character in the Query object using: Query.setWildcardCharacter(char)>Query.setWildcardCharacter(char) 55 .

Note: the implementation is a modified version of that provided by: Kevin Stannard (http://www.jzoo.com/java/wildcardfilter/).

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


Field Summary
private  boolean ignoreCase
           
private  boolean not
           
private  java.util.List pattern
           
 
Fields inherited from class org.josql.expressions.BinaryExpression
left, right
 
Fields inherited from class org.josql.expressions.Expression
 
Constructor Summary
LikeExpression()
           
 
Method Summary
 void init(org.josql.Query q)
          Init the expression, we over-ride here so that if the RHS is fixed we can init the pattern that will be used to match the expression.
 boolean isIgnoreCase()
           
 boolean isNot()
           
 boolean isTrue(java.lang.Object o, org.josql.Query q)
          Returns whether the LHS is "LIKE" the RHS.
 void setIgnoreCase(boolean v)
           
 void setNot(boolean v)
           
 java.lang.String toString()
          Returns a string version of the 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

not

private boolean not

ignoreCase

private boolean ignoreCase

pattern

private java.util.List pattern
Constructor Detail

LikeExpression

public LikeExpression()
Method Detail

isIgnoreCase

public boolean isIgnoreCase()

init

public void init(org.josql.Query q)
          throws org.josql.QueryParseException
Init the expression, we over-ride here so that if the RHS is fixed we can init the pattern that will be used to match the expression.

Overrides:
init in class BinaryExpression

setIgnoreCase

public void setIgnoreCase(boolean v)

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
Returns whether the LHS is "LIKE" the RHS. A special case here is that if the LHS and RHS are both null then true is returned. Also, if either the LHS or RHS is not null and one is null then false is returned.

Specified by:
isTrue in class Expression

toString

public java.lang.String toString()
Returns a string version of the expression. Returns in the form:
   Expression 55  [ NOT ] [ $ ]LIKE Expression 55 
 

Specified by:
toString in class Expression