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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.josql.expressions.Expression
      extended byorg.josql.expressions.BinaryExpression
          extended byorg.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.BinaryExpression
left, right
 
Fields inherited from class org.josql.expressions.Expression
 
Constructor Summary
AndOrExpression()
           
 
Method Summary
 boolean isAnd()
           
 boolean isTrue(java.lang.Object o, org.josql.Query q)
          Evaulates the expression and returns true if the expression evaulates to true.
 void setAnd(boolean v)
           
 java.lang.String toString()
          Return a string version of this expression.
 
Methods inherited from class org.josql.expressions.BinaryExpression
getExpectedReturnType, getLeft, getRight, getValue, hasFixedResult, init, 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

and

private boolean and
Constructor Detail

AndOrExpression

public AndOrExpression()
Method Detail

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