|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.store.query.QueryCompiler
org.jpox.store.rdbms.query.JavaQueryCompiler
public abstract class JavaQueryCompiler
Base definition of a query compiler for a Java query language. This is to be extended to provide query compilers for JDOQL, JPQL and any other java-based query languages.
| Field Summary | |
|---|---|
protected org.jpox.metadata.AbstractClassMetaData |
candidateCmd
ClassMetaData for the candidate. |
protected org.jpox.store.mapped.query.Queryable |
candidates
Candidates for the query. |
protected boolean |
distinct
Whether we should use distinct for results. |
protected java.util.Map |
expressionsByVariableName
|
protected org.jpox.store.mapped.expression.QueryExpression |
parentExpr
Parent query expression (if this is a subquery). |
protected org.jpox.store.mapped.expression.QueryExpression |
qs
QueryExpression for this query. |
protected long |
rangeFromIncl
Range from position (inclusive). |
protected long |
rangeToExcl
Range to position (exclusive). |
protected java.lang.Class |
resultClass
Result class to be used. |
protected org.jpox.store.query.JPOXResultSetMetaData |
resultMetaData
ResultMetaData for the query (set in the compile process, so is null before that). |
protected java.lang.String |
subqueryCandidateExpr
Candidate expression when treating as a subquery. |
protected org.jpox.store.rdbms.query.JavaQueryCompiler.AliasJoinInformation |
subqueryCandidateExprRootAliasInfo
Alias join info for the subquery candidate expression root (if not using parent query candidate). |
| Fields inherited from class org.jpox.store.query.QueryCompiler |
|---|
candidateAlias, candidateClass, COMPILE_EXECUTION, COMPILE_EXPLICIT_PARAMETERS, COMPILE_EXPLICIT_VARIABLES, COMPILE_SYNTAX, executionCompile, imports, language, LOCALISER, p, parameterNames, parameters, parameterTypesByName, query, variableNames, variableTypesByName |
| Constructor Summary | |
|---|---|
JavaQueryCompiler(org.jpox.store.query.AbstractJavaQuery query,
org.jpox.util.Imports imports,
java.util.Map parameters)
Constructor for a compiler of java queries. |
|
| Method Summary | |
|---|---|
void |
bindVariable(java.lang.String name,
org.jpox.store.mapped.expression.ScalarExpression expr)
Bind a variable to the query. |
protected org.jpox.store.mapped.expression.ScalarExpression |
callUserDefinedScalarExpression(java.lang.String method)
Instanciate a ScalarExpression and invoke a method |
protected void |
checkExpressionsAgainstGrouping(org.jpox.store.mapped.expression.ScalarExpression[] exprs,
org.jpox.store.mapped.expression.ScalarExpression[] groupExprs,
java.lang.String localiserErrorString)
Convenience method to check the expressions against those specified in the grouping. |
protected void |
checkVariableBinding()
Convenience method to check that all variables have been bound to the query. |
void |
close()
Method to close the Compiler. |
java.lang.Object |
compile(int type)
Method to compile the query. |
protected org.jpox.store.mapped.expression.ScalarExpression |
compileAdditiveExpression()
|
protected abstract void |
compileCandidates()
Convenience method to process the candidates for this query. |
protected org.jpox.store.mapped.expression.ScalarExpression |
compileCastExpression()
|
protected org.jpox.store.mapped.expression.ScalarExpression |
compileExplicitVariable(java.lang.String id)
Method to compile an explicit variable. |
protected abstract org.jpox.store.mapped.expression.ScalarExpression |
compileExpression()
Principal method for compiling an expression. |
protected abstract org.jpox.store.mapped.expression.ScalarExpression |
compileExpressionFromString(java.lang.String str)
Convenience method to parse an expression string into its query expression. |
protected org.jpox.store.mapped.expression.ScalarExpression[] |
compileExpressionsFromString(java.lang.String str)
Convenience method to parse an expression string into its component query expressions. |
protected void |
compileFilter(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String filter)
Convenience method to compile the filter. |
protected void |
compileGrouping(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String groupingClause)
Convenience method to compile the grouping. |
protected void |
compileHaving(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String havingClause)
Convenience method to compile the having clause |
protected org.jpox.store.mapped.expression.ScalarExpression |
compileLiteral()
A literal is one value of any type. |
protected org.jpox.store.mapped.expression.ScalarExpression |
compileMultiplicativeExpression()
|
protected org.jpox.store.mapped.expression.ScalarExpression |
compileNewObject()
Method to generate an expression for a new object. |
protected abstract org.jpox.store.mapped.expression.ScalarExpression |
compilePrimary()
Compiles a primary. |
protected void |
compileRange(org.jpox.store.mapped.expression.QueryExpression qs)
Convenience method to compile the range. |
protected void |
compileResult(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String result)
Compile the result expressions and class. |
protected void |
compileSubqueryCandidateExpression(boolean caseSensitive)
Method to process any " |
protected org.jpox.store.mapped.expression.ScalarExpression |
compileUnaryExpression()
|
protected org.jpox.store.mapped.expression.ScalarExpression |
compileUnaryExpressionNotPlusMinus()
|
protected org.jpox.store.mapped.expression.QueryExpression |
executionCompile()
Method to execution-compile the query. |
org.jpox.store.mapped.query.Queryable |
getCandidates()
Accessor for the candidates for the query. |
boolean |
getDistinct()
Accessor for whether the candidate result should be distinct. |
long |
getRangeFromIncl()
Accessor for the range "from" value. |
long |
getRangeToExcl()
Accessor for the range "to" value. |
java.lang.Class |
getResultClass()
Accessor for the result class. |
org.jpox.store.query.JPOXResultSetMetaData |
getResultMetaData()
Accessor for the result MetaData. |
protected abstract void |
performCompile(org.jpox.store.mapped.expression.QueryExpression qs)
Perform the actual compilation of the query. |
protected void |
preCompile()
Method to provide pre-compilation checks to catch errors. |
| Methods inherited from class org.jpox.store.query.QueryCompiler |
|---|
compileExplicitParameters, compileExplicitVariables, getCandidateAlias, getCandidateClass, getParameterNames, getParameterTypesByName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.jpox.store.query.JPOXResultSetMetaData resultMetaData
protected org.jpox.store.mapped.expression.QueryExpression qs
protected org.jpox.store.mapped.expression.QueryExpression parentExpr
protected java.util.Map expressionsByVariableName
protected org.jpox.metadata.AbstractClassMetaData candidateCmd
protected org.jpox.store.mapped.query.Queryable candidates
protected boolean distinct
protected java.lang.Class resultClass
protected long rangeFromIncl
protected long rangeToExcl
protected java.lang.String subqueryCandidateExpr
protected org.jpox.store.rdbms.query.JavaQueryCompiler.AliasJoinInformation subqueryCandidateExprRootAliasInfo
| Constructor Detail |
|---|
public JavaQueryCompiler(org.jpox.store.query.AbstractJavaQuery query,
org.jpox.util.Imports imports,
java.util.Map parameters)
query - The query to compileimports - The imports to useparameters - Any parameters| Method Detail |
|---|
public void close()
close in class org.jpox.store.query.QueryCompilerpublic java.lang.Object compile(int type)
compile in class org.jpox.store.query.QueryCompilertype - Type of compilation
protected void preCompile()
protected org.jpox.store.mapped.expression.QueryExpression executionCompile()
public org.jpox.store.query.JPOXResultSetMetaData getResultMetaData()
public org.jpox.store.mapped.query.Queryable getCandidates()
public boolean getDistinct()
public java.lang.Class getResultClass()
public long getRangeFromIncl()
public long getRangeToExcl()
protected abstract void performCompile(org.jpox.store.mapped.expression.QueryExpression qs)
qs - The QueryExpression to use during compilation (if required)protected abstract void compileCandidates()
protected void compileSubqueryCandidateExpression(boolean caseSensitive)
Method to process any "this.department.employees
would result in a table expression for the
Department table being added to this subquery FROM, with an INNER JOIN to the subquery candidate table,
and an AND condition from the Department table back to the outer query candidate table.
The subqueryCandidateExpr should either start "this." (hence from the parent query candidate) or, if not, the "subqueryCandidateExprRootAliasInfo" will be set and will define the candidate root of the subquery candidate expression. This second use is used in JPQL where we have a subquery using a field of another alias from the parent query e.g
SELECT c FROM Customer c JOIN c.orders o WHERE EXISTS (SELECT o FROM o.lineItems l where l.quantity > 3)so "o" is the root alias for the subquery, and the "subqueryCandidateExprRootAliasInfo" will define the table expression in the parent query, and the class it represents.
protected void compileFilter(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String filter)
qs - The Query Expression to apply the filter to (if specified)filter - The filter specification
protected void compileResult(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String result)
qs - Query Expression to apply the result to (if required)result - Result clause to compile
protected void compileGrouping(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String groupingClause)
qs - The QueryExpression to update (if specified)groupingClause - The grouping clause string
protected void compileHaving(org.jpox.store.mapped.expression.QueryExpression qs,
java.lang.String havingClause)
qs - The QueryExpression to update (if specified)havingClause - The having clause stringprotected void compileRange(org.jpox.store.mapped.expression.QueryExpression qs)
qs - QueryExpression to apply the range to (if specified)
protected void checkExpressionsAgainstGrouping(org.jpox.store.mapped.expression.ScalarExpression[] exprs,
org.jpox.store.mapped.expression.ScalarExpression[] groupExprs,
java.lang.String localiserErrorString)
exprs - The expressions to checkgroupExprs - The grouping expressionslocaliserErrorString - Name of a localiser error message to throw as the JPOXUserException message.
public void bindVariable(java.lang.String name,
org.jpox.store.mapped.expression.ScalarExpression expr)
bindVariable in interface org.jpox.store.mapped.expression.UnboundVariable.VariableBindername - Name of the variableexpr - The expressionprotected void checkVariableBinding()
org.jpox.exceptions.JPOXUserException - Thrown if a variable is found that is not bound.protected org.jpox.store.mapped.expression.ScalarExpression[] compileExpressionsFromString(java.lang.String str)
str - The string
protected abstract org.jpox.store.mapped.expression.ScalarExpression compileExpressionFromString(java.lang.String str)
str - The string
protected abstract org.jpox.store.mapped.expression.ScalarExpression compileExpression()
protected org.jpox.store.mapped.expression.ScalarExpression compileAdditiveExpression()
protected org.jpox.store.mapped.expression.ScalarExpression compileMultiplicativeExpression()
protected org.jpox.store.mapped.expression.ScalarExpression compileUnaryExpression()
protected org.jpox.store.mapped.expression.ScalarExpression compileUnaryExpressionNotPlusMinus()
protected org.jpox.store.mapped.expression.ScalarExpression compileCastExpression()
protected abstract org.jpox.store.mapped.expression.ScalarExpression compilePrimary()
protected org.jpox.store.mapped.expression.ScalarExpression compileLiteral()
protected org.jpox.store.mapped.expression.ScalarExpression compileNewObject()
new MyObject(param1, param2)
protected org.jpox.store.mapped.expression.ScalarExpression compileExplicitVariable(java.lang.String id)
id - Identifier of the variable
protected org.jpox.store.mapped.expression.ScalarExpression callUserDefinedScalarExpression(java.lang.String method)
method - the method name prefixed by the class name (fully qualified or not)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||