org.datanucleus.store.query
Class QueryCompiler

java.lang.Object
  extended by org.datanucleus.store.query.QueryCompiler

public class QueryCompiler
extends java.lang.Object

Base definition of a query compiler for a query language. Should be extended to compile details of individual query languages. This was designed for the old-style compilation process, and is being phased out. New implementations of querying in DataNucleus should make use of compilers under "org.datanucleus.query.compiler".


Field Summary
protected  java.lang.String candidateAlias
          Alias for the candidate class.
protected  java.lang.Class candidateClass
          Candidate class for the query.
static int COMPILE_EXECUTION
           
static int COMPILE_EXPLICIT_PARAMETERS
           
static int COMPILE_EXPLICIT_VARIABLES
           
static int COMPILE_SYNTAX
           
protected  boolean executionCompile
          Flag for whether the current compile is for execution (using param values).
protected  Imports imports
          Imports to use for the resolution of classes.
protected  java.lang.String language
          Language of this query (e.g JDOQL, JPQL).
protected static Localiser LOCALISER
          Localiser for messages.
protected  java.util.List parameterNames
          The parameter names.
protected  java.util.Map parameters
          Map of parameter values, keyed by their name.
protected  java.util.Map parameterTypesByName
          Look-up for the parameter types, keyed by the name.
protected  Query query
          The query being compiled.
protected  java.util.List variableNames
          List of variable names.
protected  java.util.Map variableTypesByName
          Look-up for the variables types, keyed by the name.
 
Constructor Summary
QueryCompiler(Query query, Imports imports, java.util.Map parameters)
          Constructor for a compiler of java queries.
 
Method Summary
 void close()
          Method to close the Compiler.
 java.lang.Object compile(int type)
          Method to compile the query.
protected  void compileExplicitParameters()
          Method to compile all parameters declared for this query.
protected  void compileExplicitVariables()
          Method to compile all variables declared for this query.
 java.lang.String getCandidateAlias()
          Accessor for the candidate alias.
 java.lang.Class getCandidateClass()
          Accessor for the candidate class.
 java.lang.String[] getParameterNames()
          Accessor for the (explicit) parameter names.
 java.util.Map getParameterTypesByName()
          Accessor for the parameter types keyed by the parameter name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPILE_EXPLICIT_PARAMETERS

public static final int COMPILE_EXPLICIT_PARAMETERS
See Also:
Constant Field Values

COMPILE_EXPLICIT_VARIABLES

public static final int COMPILE_EXPLICIT_VARIABLES
See Also:
Constant Field Values

COMPILE_SYNTAX

public static final int COMPILE_SYNTAX
See Also:
Constant Field Values

COMPILE_EXECUTION

public static final int COMPILE_EXECUTION
See Also:
Constant Field Values

LOCALISER

protected static final Localiser LOCALISER
Localiser for messages.


language

protected java.lang.String language
Language of this query (e.g JDOQL, JPQL).


query

protected Query query
The query being compiled.


imports

protected Imports imports
Imports to use for the resolution of classes.


parameters

protected java.util.Map parameters
Map of parameter values, keyed by their name.


executionCompile

protected boolean executionCompile
Flag for whether the current compile is for execution (using param values).


candidateClass

protected java.lang.Class candidateClass
Candidate class for the query. May be updated during the compilation.


candidateAlias

protected java.lang.String candidateAlias
Alias for the candidate class.


parameterNames

protected java.util.List parameterNames
The parameter names.


parameterTypesByName

protected java.util.Map parameterTypesByName
Look-up for the parameter types, keyed by the name.


variableNames

protected java.util.List variableNames
List of variable names.


variableTypesByName

protected java.util.Map variableTypesByName
Look-up for the variables types, keyed by the name.

Constructor Detail

QueryCompiler

public QueryCompiler(Query query,
                     Imports imports,
                     java.util.Map parameters)
Constructor for a compiler of java queries.

Parameters:
query - The query to compile
imports - The imports to use
parameters - Any parameters
Method Detail

close

public void close()
Method to close the Compiler.


compile

public java.lang.Object compile(int type)
Method to compile the query.

Parameters:
type - Type of compilation. This compiler only supports explicit parameters, explicit variables
Returns:
the compilation artifact (if any)

getCandidateClass

public java.lang.Class getCandidateClass()
Accessor for the candidate class. May have been updated during the compile process.

Returns:
Candidate class

getCandidateAlias

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

Returns:
Candidate alias

getParameterNames

public java.lang.String[] getParameterNames()
Accessor for the (explicit) parameter names.

Returns:
Parameter names

getParameterTypesByName

public java.util.Map getParameterTypesByName()
Accessor for the parameter types keyed by the parameter name. Generated during compile of explicit parameters.

Returns:
Map of parameter type keyed by name

compileExplicitParameters

protected void compileExplicitParameters()
Method to compile all parameters declared for this query. Takes the input "parameters" and populates "parameterNames", "parameterTypesByName" for convenience.


compileExplicitVariables

protected void compileExplicitVariables()
Method to compile all variables declared for this query. Takes the input "variables" and populates "variableNames", "variableTypesByName" for convenience.



Copyright © 2009. All Rights Reserved.