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 following forms

 SELECT {result} FROM {from} WHERE {filter} GROUP BY {grouping} HAVING {having} ORDER BY {order}
 UPDATE {from} SET {update} WHERE {filter}
 DELETE FROM {from} WHERE {filter}
 


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
          Compiled 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  Expression[] exprUpdate
          Compiled update expression.
protected static Localiser LOCALISER
          Localiser for messages.
protected  java.lang.String queryLanguage
          Query language that this is a compilation for.
protected  boolean resultDistinct
          Whether the result is distinct.
protected  boolean returnsSingleRow
          Whether the query will return a single row.
protected  java.util.Map<java.lang.String,QueryCompilation> 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, Expression[] updates)
           
 
Method Summary
 void addSubqueryCompilation(java.lang.String alias, QueryCompilation compilation)
          Method to add the compilation for a subquery of this query.
 java.lang.String debugString(java.lang.String indent)
           
 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).
 Expression[] getExprUpdate()
          Accessor for any update expression(s).
 ParameterExpression getParameterExpressionForPosition(int pos)
           
 java.lang.String getQueryLanguage()
           
 boolean getResultDistinct()
           
 java.lang.Class[] getResultTypes()
          Accessor for the types of the result row components.
 java.lang.String[] getSubqueryAliases()
          Accessor for the aliases for any subqueries in this compilation.
 SymbolTable getSymbolTable()
          Accessor for the symbol table for the query.
 boolean returnsSingleRow()
          Accessor for whether this query will return a single row.
 void setExprFilter(Expression filter)
           
 void setExprHaving(Expression having)
           
 void setQueryLanguage(java.lang.String lang)
           
 void setResultDistinct()
           
 void setReturnsSingleRow()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localiser for messages.


queryLanguage

protected java.lang.String queryLanguage
Query language that this is a compilation for.


candidateClass

protected java.lang.Class candidateClass
Primary candidate class.


candidateAlias

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


returnsSingleRow

protected boolean returnsSingleRow
Whether the query will return a single row.


symtbl

protected SymbolTable symtbl
Compiled Symbol Table.


resultDistinct

protected boolean resultDistinct
Whether the result is distinct.


exprResult

protected Expression[] exprResult
Compiled result expression.


exprFrom

protected Expression[] exprFrom
Compiled from expression.


exprUpdate

protected Expression[] exprUpdate
Compiled update 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<java.lang.String,QueryCompilation> 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,
                        Expression[] updates)
Method Detail

setQueryLanguage

public void setQueryLanguage(java.lang.String lang)

getQueryLanguage

public java.lang.String getQueryLanguage()

setResultDistinct

public void setResultDistinct()

getResultDistinct

public boolean getResultDistinct()

setReturnsSingleRow

public void setReturnsSingleRow()

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

getSubqueryAliases

public java.lang.String[] getSubqueryAliases()
Accessor for the aliases for any subqueries in this compilation.

Returns:
The subquery aliases (if any)

returnsSingleRow

public boolean returnsSingleRow()
Accessor for whether this query will return a single row. This is true if all result selects are aggregates, or the user has set "unique" on the query.

Returns:
Whether this query will return a single row

getResultTypes

public java.lang.Class[] getResultTypes()
Accessor for the types of the result row components. If no result is defined then will be an array of size 1 with element type "candidate".

Returns:
The result type(s)

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

getExprUpdate

public Expression[] getExprUpdate()
Accessor for any update expression(s).

Returns:
The updates

getExprFilter

public Expression getExprFilter()
Accessor for the filter expression.

Returns:
The filter

setExprFilter

public void setExprFilter(Expression 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

setExprHaving

public void setExprHaving(Expression having)

getExprOrdering

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

Returns:
The ordering

getParameterExpressionForPosition

public ParameterExpression getParameterExpressionForPosition(int pos)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

debugString

public java.lang.String debugString(java.lang.String indent)


Copyright © 2011. All Rights Reserved.