java.lang.Object
org.josql.expressions.Expression
org.josql.expressions.BinaryExpression
org.josql.expressions.AndOrExpression
- public class AndOrExpression
- extends BinaryExpression
Represents either an AND expression or a OR expression.
Lazy evaluation is employed here such if the expression is: LHS OR RHS
and LHS = true then the RHS is NOT evaluated, if the expression is: LHS AND RHS
and LHS = false then the RHS is NOT evaluated (see isTrue(Object,Query) 55 ). This is important to note if you expect
side-effects to occur in the RHS (bad practice anyway so don't do it!).
Last Modified By: $Author: barrygently $
Last Modified On: $Date: 2004/12/20 16:22:43 $
Current Revision: $Revision: 1.2 $
|
Field Summary |
private boolean |
and
|
| Fields inherited from class org.josql.expressions.Expression |
|
and
private boolean and
AndOrExpression
public AndOrExpression()
isAnd
public boolean isAnd()
setAnd
public void setAnd(boolean v)
isTrue
public boolean isTrue(java.lang.Object o,
org.josql.Query q)
throws org.josql.QueryExecutionException
- Evaulates the expression and returns true if the expression evaulates to
true.
| Type |
LHS |
RHS |
Result |
Notes |
| AND |
true |
true |
true |
Both LHS and RHS are evaulated. |
| AND |
true |
false |
false |
Both LHS and RHS are evaulated. |
| AND |
false |
unknown or false |
false |
Only the LHS is evaulated. |
| OR |
true |
unknown |
true |
Only the LHS is evaulated. |
| OR |
false |
true |
true |
Both the LHS and RHS are evaulated. |
| OR |
false |
false |
false |
Both the LHS and RHS are evaulated. |
In general what this means is that you should "left-weight" your expressions so that
the expression that returns true most often (or more likely to return
true) should be on the LHS.
- Specified by:
isTrue in class Expression
toString
public java.lang.String toString()
- Return a string version of this expression.
Note: any formatting of the statement (such as line breaks) will be removed.
- Specified by:
toString in class Expression