org.datanucleus.query.compiler
Class JavaQueryCompiler

java.lang.Object
  extended by org.datanucleus.query.compiler.JavaQueryCompiler
All Implemented Interfaces:
SymbolResolver
Direct Known Subclasses:
JDOQLCompiler, JPQLCompiler, SQLCompiler

public abstract class JavaQueryCompiler
extends java.lang.Object
implements SymbolResolver

Typical implementation of a compiler for a java-based query language. The constructor takes in the components of the query, and the method compile() compiles it returning the compiled query, for use elsewhere.

Each "Expression" is effectively a tree of Expressions. You can navigate through each expression based on their type. For example, a DyadicExpression has a "left" and "right" and an operator between them. The left could also be a DyadicExpression, so you would navigate to its left/right components etc etc.


Field Summary
protected  java.lang.String candidateAlias
          Alias for the primary candidate.
protected  java.lang.Class candidateClass
          Primary candidate class (if defined).
protected  java.util.Collection candidates
           
protected  ClassLoaderResolver clr
           
protected  java.lang.String filter
           
protected  java.lang.String from
           
protected  java.lang.String grouping
           
protected  java.lang.String having
           
protected  Imports imports
           
protected  MetaDataManager metaDataManager
           
protected  java.lang.String ordering
           
protected  java.lang.String parameters
           
protected  Parser parser
          Parser specific to the type of query being compiled.
protected  java.lang.String result
           
protected  SymbolTable symtbl
          Compiled Symbol Table.
protected  java.lang.String variables
           
 
Constructor Summary
JavaQueryCompiler(MetaDataManager metaDataManager, ClassLoaderResolver clr, java.lang.String from, java.lang.Class candidateClass, java.util.Collection candidates, java.lang.String filter, Imports imports, java.lang.String ordering, java.lang.String result, java.lang.String grouping, java.lang.String having, java.lang.String params, java.lang.String variables)
           
 
Method Summary
abstract  QueryCompilation compile(java.util.Map parameters)
          Method to compile the query.
 void compileCandidatesParametersVariables(java.util.Map parameters)
          Compile the candidates, variables and parameters.
 Expression compileFilter()
          Compile the filter and return the compiled expression.
protected  Expression[] compileFrom()
          Method to compile the "from" clause (if present for the query language).
 Expression[] compileGrouping()
           
 Expression compileHaving()
           
 Expression[] compileOrdering()
           
 Expression[] compileResult()
           
 java.lang.Class getType(java.util.List tuples)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metaDataManager

protected final MetaDataManager metaDataManager

clr

protected final ClassLoaderResolver clr

candidateClass

protected java.lang.Class candidateClass
Primary candidate class (if defined).


candidateAlias

protected java.lang.String candidateAlias
Alias for the primary candidate. Default to "this" (JDOQL) but can be set.


from

protected java.lang.String from

candidates

protected java.util.Collection candidates

filter

protected java.lang.String filter

ordering

protected java.lang.String ordering

parameters

protected java.lang.String parameters

variables

protected java.lang.String variables

grouping

protected java.lang.String grouping

having

protected java.lang.String having

result

protected java.lang.String result

imports

protected Imports imports

symtbl

protected SymbolTable symtbl
Compiled Symbol Table.


parser

protected Parser parser
Parser specific to the type of query being compiled.

Constructor Detail

JavaQueryCompiler

public JavaQueryCompiler(MetaDataManager metaDataManager,
                         ClassLoaderResolver clr,
                         java.lang.String from,
                         java.lang.Class candidateClass,
                         java.util.Collection candidates,
                         java.lang.String filter,
                         Imports imports,
                         java.lang.String ordering,
                         java.lang.String result,
                         java.lang.String grouping,
                         java.lang.String having,
                         java.lang.String params,
                         java.lang.String variables)
Method Detail

compile

public abstract QueryCompilation compile(java.util.Map parameters)
Method to compile the query.

Parameters:
parameters - The parameter values keyed by name.
Returns:
The query compilation

compileCandidatesParametersVariables

public void compileCandidatesParametersVariables(java.util.Map parameters)
Compile the candidates, variables and parameters.

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

compileFrom

protected Expression[] compileFrom()
Method to compile the "from" clause (if present for the query language).


compileFilter

public Expression compileFilter()
Compile the filter and return the compiled expression.

Returns:
The compiled expression

compileResult

public Expression[] compileResult()

compileGrouping

public Expression[] compileGrouping()

compileHaving

public Expression compileHaving()

compileOrdering

public Expression[] compileOrdering()

getType

public java.lang.Class getType(java.util.List tuples)
Specified by:
getType in interface SymbolResolver


Copyright © 2009. All Rights Reserved.