|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.josql.expressions.Expression org.josql.expressions.BinaryExpression org.josql.expressions.LikeExpression
public class LikeExpression
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)
.
Note: the implementation is a modified version of that provided by: Kevin Stannard (http://www.jzoo.com/java/wildcardfilter/).
Field Summary |
---|
Fields inherited from class org.josql.expressions.BinaryExpression |
---|
left, right |
Constructor Summary | |
---|---|
LikeExpression()
|
Method Summary | |
---|---|
void |
init(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(Object o,
Query q)
Returns whether the LHS is "LIKE" the RHS. |
void |
setIgnoreCase(boolean v)
|
void |
setNot(boolean v)
|
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 |
Constructor Detail |
---|
public LikeExpression()
Method Detail |
---|
public boolean isIgnoreCase()
public void init(Query q) throws QueryParseException
init
in class BinaryExpression
q
- The Query object.
QueryParseException
- If the LHS and/or RHS cannot be inited.public void setIgnoreCase(boolean v)
public boolean isNot()
public void setNot(boolean v)
public boolean isTrue(Object o, Query q) throws QueryExecutionException
null
then true
is returned. Also, if either the LHS or RHS is not null and one is null then false
is returned.
isTrue
in class Expression
o
- The object to evaluate the expression on.q
- The Query object.
true
if the LHS is "LIKE" the RHS, false
if not. And using
"NOT" will invert the result.
QueryExecutionException
- If the expression cannot be evaluated.public String toString()
Expression
[ NOT ] [ $ ]LIKEExpression
toString
in class Expression
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |