org.datanucleus.query.compiler
Class QueryCompilation

java.lang.Object
  extended by org.datanucleus.query.compiler.QueryCompilation

public class QueryCompilation
extends java.lang.Object

Representation of the components of a compiled java "string-based" query. Assumes that the query has the form

 SELECT {result} FROM {from} WHERE {filter} GROUP BY {grouping} HAVING {having} ORDER BY {order}
 


Field Summary
protected  java.lang.String candidateAlias
          Alias for the (primary) candidate.
protected  java.lang.Class candidateClass
          Primary candidate class.
protected  Expression exprFilter
          Compiled filter expression
protected  Expression[] exprFrom
          Compled from expression.
protected  Expression[] exprGrouping
          Compiled grouping expression.
protected  Expression exprHaving
          Compiled having expression.
protected  Expression[] exprOrdering
          Compiled ordering expression.
protected  Expression[] exprResult
          Compiled result expression.
protected static Localiser LOCALISER
          Localiser for messages.
protected  java.util.Map subqueryCompilations
          Compilations of any subqueries, keyed by the subquery variable name.
protected  SymbolTable symtbl
          Compiled Symbol Table.
 
Constructor Summary
QueryCompilation(java.lang.Class candidateCls, java.lang.String candidateAlias, SymbolTable symtbl, Expression[] results, Expression[] froms, Expression filter, Expression[] groupings, Expression having, Expression[] orderings)
           
 
Method Summary
 void addSubqueryCompilation(java.lang.String alias, QueryCompilation compilation)
          Method to add the compilation for a subquery of this query.
 void bindParameterValuesToNames(java.util.Map parameters)
          Convenience method to bind the parameter values (at execution) to the compiled query.
 java.lang.String getCandidateAlias()
          Accessor for the candidate alias.
 java.lang.Class getCandidateClass()
          Accessor for the candidate class.
 QueryCompilation getCompilationForSubquery(java.lang.String alias)
          Accessor for the compilation for a subquery with the specified alias.
 Expression getExprFilter()
          Accessor for the filter expression.
 Expression[] getExprFrom()
          Accessor for any from expression(s).
 Expression[] getExprGrouping()
          Accessor for any grouping expression(s).
 Expression getExprHaving()
          Accessor for any having expression.
 Expression[] getExprOrdering()
          Accessor for any ordering expression(s).
 Expression[] getExprResult()
          Accessor for any result expression(s).
 SymbolTable getSymbolTable()
          Accessor for the symbol table for the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localiser for messages.


candidateClass

protected java.lang.Class candidateClass
Primary candidate class.


candidateAlias

protected java.lang.String candidateAlias
Alias for the (primary) candidate. Defaults to "this".


symtbl

protected SymbolTable symtbl
Compiled Symbol Table.


exprResult

protected Expression[] exprResult
Compiled result expression.


exprFrom

protected Expression[] exprFrom
Compled from expression.


exprFilter

protected Expression exprFilter
Compiled filter expression


exprGrouping

protected Expression[] exprGrouping
Compiled grouping expression.


exprHaving

protected Expression exprHaving
Compiled having expression.


exprOrdering

protected Expression[] exprOrdering
Compiled ordering expression.


subqueryCompilations

protected java.util.Map subqueryCompilations
Compilations of any subqueries, keyed by the subquery variable name.

Constructor Detail

QueryCompilation

public QueryCompilation(java.lang.Class candidateCls,
                        java.lang.String candidateAlias,
                        SymbolTable symtbl,
                        Expression[] results,
                        Expression[] froms,
                        Expression filter,
                        Expression[] groupings,
                        Expression having,
                        Expression[] orderings)
Method Detail

addSubqueryCompilation

public void addSubqueryCompilation(java.lang.String alias,
                                   QueryCompilation compilation)
Method to add the compilation for a subquery of this query.

Parameters:
alias - Alias for the subquery (variable name)
compilation - The compilation

getCompilationForSubquery

public QueryCompilation getCompilationForSubquery(java.lang.String alias)
Accessor for the compilation for a subquery with the specified alias.

Parameters:
alias - Alias of subquery
Returns:
The compilation

getCandidateClass

public java.lang.Class getCandidateClass()
Accessor for the candidate class.

Returns:
Candidate class

getCandidateAlias

public java.lang.String getCandidateAlias()
Accessor for the candidate alias.

Returns:
Candidate alias

getSymbolTable

public SymbolTable getSymbolTable()
Accessor for the symbol table for the query.

Returns:
Symbol table, for parameter, variable lookup.

getExprResult

public Expression[] getExprResult()
Accessor for any result expression(s).

Returns:
The results

getExprFrom

public Expression[] getExprFrom()
Accessor for any from expression(s).

Returns:
The from clauses

getExprFilter

public Expression getExprFilter()
Accessor for the filter expression.

Returns:
The filter

getExprGrouping

public Expression[] getExprGrouping()
Accessor for any grouping expression(s).

Returns:
The grouping

getExprHaving

public Expression getExprHaving()
Accessor for any having expression.

Returns:
The having clause

getExprOrdering

public Expression[] getExprOrdering()
Accessor for any ordering expression(s).

Returns:
The ordering

bindParameterValuesToNames

public void bindParameterValuesToNames(java.util.Map parameters)
Convenience method to bind the parameter values (at execution) to the compiled query. This updates the symbols in the SymbolTable to the specified values.

Parameters:
parameters - Map of parameter values keyed by parameter name


Copyright © 2009. All Rights Reserved.