org.josql.expressions
Class BinaryExpression

java.lang.Object
  extended by org.josql.expressions.Expression
      extended by org.josql.expressions.BinaryExpression
Direct Known Subclasses:
AndOrExpression, BetweenExpression, EqualsExpression, GTLTExpression, InExpression, IsNullExpression, LikeExpression

public abstract class BinaryExpression
extends Expression

Super-class of Expressions that return a binary result.

A binary expression must always have a LHS. The RHS is optional.


Field Summary
protected  Expression left
           
protected  Expression right
           
 
Constructor Summary
BinaryExpression()
           
 
Method Summary
 Class getExpectedReturnType(Query q)
          Return the expected return type from this expression.
 Expression getLeft()
          Get the LHS.
 Expression getRight()
          Get the RHS.
 Object getValue(Object o, Query q)
          Get the value of this expression.
 boolean hasFixedResult(Query q)
          Return whether this expression, and more specifically the left and right parts of the expression return a fixed result.
 void init(Query q)
          Init the expression.
 void setLeft(Expression exp)
           
 void setRight(Expression exp)
           
 
Methods inherited from class org.josql.expressions.Expression
isBracketed, isTrue, setBracketed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

left

protected Expression left

right

protected Expression right
Constructor Detail

BinaryExpression

public BinaryExpression()
Method Detail

hasFixedResult

public boolean hasFixedResult(Query q)
Return whether this expression, and more specifically the left and right parts of the expression return a fixed result. Sub-classes may override this method for more tailored results, especially if the binary expression does not demand a RHS.

Specified by:
hasFixedResult in class Expression
Parameters:
q - The Query object.
Returns:
true if the expression has a fixed result.

getExpectedReturnType

public Class getExpectedReturnType(Query q)
Return the expected return type from this expression.

Specified by:
getExpectedReturnType in class Expression
Parameters:
q - The Query object.
Returns:
The class of the return type, this method ALWAYS returns Boolean.class.

init

public void init(Query q)
          throws QueryParseException
Init the expression. Sub-classes will often override this method. This method just calls: Expression.init(Query) on the LHS and RHS (if present) of the expression.

Specified by:
init in class Expression
Parameters:
q - The Query object.
Throws:
QueryParseException - If the LHS and/or RHS cannot be inited.

getValue

public Object getValue(Object o,
                       Query q)
                throws QueryExecutionException
Get the value of this expression. This will always return an instance of: java.lang.Boolean created as the result of a call to: Expression.getValue(Object,Query).

Specified by:
getValue in class Expression
Parameters:
o - The object to evaluate the expression on.
q - The Query object.
Returns:
An instance of Boolean.
Throws:
QueryExecutionException - If the expression cannot be evaluated.

getRight

public Expression getRight()
Get the RHS.

Returns:
The RHS of the expression.

getLeft

public Expression getLeft()
Get the LHS.

Returns:
The LHS of the expression.

setLeft

public void setLeft(Expression exp)

setRight

public void setRight(Expression exp)


  Copyright © 2008 Gary Bentley. All Rights Reserved.