| |
|
| java.lang.Object org.josql.expressions.Expression org.josql.expressions.BinaryExpression org.josql.expressions.AndOrExpression
AndOrExpression | public class AndOrExpression extends BinaryExpression (Code) | | 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
AndOrExpression.isTrue(Object,Query) ). This is important to note if you expect
side-effects to occur in the RHS (bad practice anyway so don't do it!).
|
Method Summary | |
public boolean | isAnd() | public boolean | isTrue(Object o, Query q) 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.
Parameters: o - The current object to perform the expression on. | public void | setAnd(boolean v) | public String | toString() Return a string version of this expression.
Note: any formatting of the statement (such as line breaks) will be removed.
A string version of the expression. |
isAnd | public boolean isAnd()(Code) | | |
isTrue | public boolean isTrue(Object o, Query q) throws QueryExecutionException(Code) | | 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.
Parameters: o - The current object to perform the expression on. Parameters: q - The query object. true if the expression evaulates to true , false otherwise. throws: QueryExecutionException - If the expression cannot be evaulated. |
setAnd | public void setAnd(boolean v)(Code) | | |
toString | public String toString()(Code) | | Return a string version of this expression.
Note: any formatting of the statement (such as line breaks) will be removed.
A string version of the expression. |
|
|
|