org.josql.expressions
Class SubQueryExpression

java.lang.Object
  extended by org.josql.expressions.Expression
      extended by org.josql.expressions.ValueExpression
          extended by org.josql.expressions.SubQueryExpression
All Implemented Interfaces:
BindVariableChangedListener, SaveValueChangedListener

public class SubQueryExpression
extends ValueExpression
implements BindVariableChangedListener, SaveValueChangedListener


Constructor Summary
SubQueryExpression(Query q)
           
 
Method Summary
 void bindVariableChanged(BindVariableChangedEvent ev)
           
 Object evaluate(Object o, Query q)
           
 String getAccessor()
           
 Class getExpectedReturnType(Query q)
          Return the class of the object that "should" be returned from a call to the: Expression.getValue(Object,Query) method.
 com.gentlyweb.utils.Getter getGetter()
           
 Query getQuery()
           
 boolean hasFixedResult(Query q)
          Return whether the expression will evaluate to a fixed/constant result.
 void init(Query q)
          Perform the necessary initialisation for this expression.
 boolean isTrue(Object o, Query q)
          This method allows ANY expression (including those that extend ValueExpression) to be used in the WHERE and HAVING clauses but ensuring that a boolean value is available for every expression.
 void saveValueChanged(SaveValueChangedEvent ev)
           
 void setAccessor(String acc)
           
 String toString()
          Return a string representation of the expression, making this abstract forces sub-classes to provide an implementation.
 
Methods inherited from class org.josql.expressions.ValueExpression
getValue
 
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

SubQueryExpression

public SubQueryExpression(Query q)
Method Detail

bindVariableChanged

public void bindVariableChanged(BindVariableChangedEvent ev)
Specified by:
bindVariableChanged in interface BindVariableChangedListener

saveValueChanged

public void saveValueChanged(SaveValueChangedEvent ev)
Specified by:
saveValueChanged in interface SaveValueChangedListener

getGetter

public com.gentlyweb.utils.Getter getGetter()

setAccessor

public void setAccessor(String acc)

getAccessor

public String getAccessor()

getQuery

public Query getQuery()

hasFixedResult

public boolean hasFixedResult(Query q)
Description copied from class: Expression
Return whether the expression will evaluate to a fixed/constant result. This allows certain optimisations to be performed when an expression is evaluated. A "fixed result" is basically one in which multiple calls to either the: Expression.isTrue(Object,Query) or Expression.getValue(Object,Query) methods will return the same object (or that o1.equals (o2) == true) regardless of the object passed to the method.

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

getExpectedReturnType

public Class getExpectedReturnType(Query q)
                            throws QueryParseException
Description copied from class: Expression
Return the class of the object that "should" be returned from a call to the: Expression.getValue(Object,Query) method. It may be that repeated executions of a query will return different classes from this method. In general sub-classes should take this variance into account.

Specified by:
getExpectedReturnType in class Expression
Parameters:
q - The Query object.
Returns:
The expected type that will be returned from the Expression.getValue(Object,Query) method.
Throws:
QueryParseException - If something goes wrong with determining the type.

init

public void init(Query q)
          throws QueryParseException
Description copied from class: Expression
Perform the necessary initialisation for this expression. The exact operations performed are defined by the sub-class.

Specified by:
init in class Expression
Parameters:
q - The Query object.
Throws:
QueryParseException - If something goes wrong with the initialisation.

isTrue

public boolean isTrue(Object o,
                      Query q)
               throws QueryExecutionException
Description copied from class: Expression
This method allows ANY expression (including those that extend ValueExpression) to be used in the WHERE and HAVING clauses but ensuring that a boolean value is available for every expression.

Specified by:
isTrue in class Expression
Parameters:
o - The current object to evaluate the expression on.
q - The Query object.
Returns:
true if the expression evaluates to true (well duh...).
Throws:
QueryExecutionException - If there is a problem with the execution of the expression.

evaluate

public Object evaluate(Object o,
                       Query q)
                throws QueryExecutionException
Specified by:
evaluate in class ValueExpression
Throws:
QueryExecutionException

toString

public String toString()
Description copied from class: Expression
Return a string representation of the expression, making this abstract forces sub-classes to provide an implementation.

Specified by:
toString in class Expression
Returns:
A string representation of the expression.


  Copyright © 2008 Gary Bentley. All Rights Reserved.