org.apache.openjpa.kernel.jpql
Class JPQLExpressionBuilder

java.lang.Object
  extended by org.apache.openjpa.kernel.exps.AbstractExpressionBuilder
      extended by org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder
All Implemented Interfaces:
org.apache.openjpa.kernel.jpql.JPQLTreeConstants

public class JPQLExpressionBuilder
extends AbstractExpressionBuilder
implements org.apache.openjpa.kernel.jpql.JPQLTreeConstants

Builder for JPQL expressions. This class takes the query parsed in JPQLExpressionBuilder.ParsedJPQL and converts it to an expression tree using an ExpressionFactory. Public for unit testing purposes.

Author:
Marc Prud'hommeaux, Patrick Linskey

Nested Class Summary
protected static class JPQLExpressionBuilder.JPQLNode
          Base node that will be generated by the JPQLExpressionBuilder; base class of the SimpleNode that is used by JPQLExpressionBuilder.ParsedJPQL.
static class JPQLExpressionBuilder.ParsedJPQL
          Public for unit testing purposes.
 
Field Summary
 
Fields inherited from class org.apache.openjpa.kernel.exps.AbstractExpressionBuilder
CONTAINS_TYPE_ELEMENT, CONTAINS_TYPE_KEY, CONTAINS_TYPE_VALUE, EX_FATAL, EX_UNSUPPORTED, EX_USER, factory, resolver, TYPE_CHAR_OBJ, TYPE_COLLECTION, TYPE_MAP, TYPE_NUMBER, TYPE_OBJECT, TYPE_STRING
 
Fields inherited from interface org.apache.openjpa.kernel.jpql.JPQLTreeConstants
JJTABS, JJTABSTRACTSCHEMANAME, JJTADD, JJTAGGREGATE, JJTALL, JJTAND, JJTANY, JJTASCENDING, JJTAVERAGE, JJTBETWEEN, JJTBOOLEANLITERAL, JJTCLASSNAME, JJTCONCAT, JJTCONSTRUCTOR, JJTCONSTRUCTORPARAM, JJTCONSTRUCTORPARAMS, JJTCOUNT, JJTCURRENTDATE, JJTCURRENTTIME, JJTCURRENTTIMESTAMP, JJTDECIMALLITERAL, JJTDELETE, JJTDESCENDING, JJTDISTINCT, JJTDISTINCTPATH, JJTDIVIDE, JJTEQUALS, JJTESCAPECHARACTER, JJTEXISTS, JJTFROM, JJTFROMITEM, JJTGREATEROREQUAL, JJTGREATERTHAN, JJTGROUPBY, JJTHAVING, JJTIDENTIFICATIONVARIABLE, JJTIDENTIFIER, JJTIN, JJTINNERFETCHJOIN, JJTINNERJOIN, JJTINTEGERLITERAL, JJTISEMPTY, JJTISNULL, JJTLENGTH, JJTLESSOREQUAL, JJTLESSTHAN, JJTLIKE, JJTLOCATE, JJTLOWER, JJTMAX, JJTMEMBEROF, JJTMIN, JJTMOD, JJTMULTIPLY, JJTNAMEDINPUTPARAMETER, JJTNEGATIVE, jjtNodeName, JJTNOT, JJTNOTEQUALS, JJTOR, JJTORDERBY, JJTORDERBYITEM, JJTOUTERFETCHJOIN, JJTOUTERJOIN, JJTPATH, JJTPATTERNVALUE, JJTPOSITIONALINPUTPARAMETER, JJTSELECT, JJTSELECTCLAUSE, JJTSELECTEXPRESSION, JJTSELECTEXPRESSIONS, JJTSIZE, JJTSQRT, JJTSTRINGLITERAL, JJTSUBSELECT, JJTSUBSTRING, JJTSUBTRACT, JJTSUM, JJTTOK, JJTTRIM, JJTTRIMBOTH, JJTTRIMCHARACTER, JJTTRIMLEADING, JJTTRIMTRAILING, JJTUPDATE, JJTUPDATEFIELD, JJTUPDATEITEM, JJTUPDATEVALUE, JJTUPPER, JJTVOID, JJTWHERE
 
Constructor Summary
JPQLExpressionBuilder(ExpressionFactory factory, ExpressionStoreQuery query, Object parsedQuery)
          Constructor.
 
Method Summary
protected  String currentQuery()
          Returns the current string being parsed; used for error messages.
protected  Expression evalFetchJoins(QueryExpressions exps)
           
protected  void evalSetClause(QueryExpressions exps)
           
protected  ClassMetaData getCandidateMetaData(JPQLExpressionBuilder.JPQLNode node)
           
protected  ClassLoader getClassLoader()
          Returns the class loader that should be used for resolving class names (in addition to the resolver in the query).
protected  Class getDeclaredVariableType(String name)
          Returns the type of the named variabe if it has been declared.
protected  Localizer getLocalizer()
          Used for obtaining the Localizer to use for translating error messages.
protected  JPQLExpressionBuilder.ParsedJPQL getParsedQuery()
           
protected  JPQLExpressionBuilder.ParsedJPQL getParsedQuery(String jpql)
           
protected  Value getVariable(String id, boolean bind)
          Identification variables in JPQL are case insensitive, so lower-case all variables we are going to bind.
protected  boolean isDeclaredVariable(String name)
          Returns whether the specified variable name has been explicitly declared.
protected  boolean isSeendVariable(String id)
           
protected  ClassMetaData resolveClassMetaData(JPQLExpressionBuilder.JPQLNode node)
           
protected  void setImplicitTypes(Value val1, Value val2, Class expected)
          Set the implicit types of the given values based on the fact that they're used together, and based on the operator type.
 
Methods inherited from class org.apache.openjpa.kernel.exps.AbstractExpressionBuilder
addAccessPath, assertUnboundVariablesValid, bind, getAccessPath, getMetaData, getMetaData, isBound, isSeenVariable, parseException, setImplicitContainsTypes, setImplicitType, traversePath, traversePath, traverseStaticField
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPQLExpressionBuilder

public JPQLExpressionBuilder(ExpressionFactory factory,
                             ExpressionStoreQuery query,
                             Object parsedQuery)
Constructor.

Parameters:
factory - the expression factory to use
query - used to resolve variables, parameters, and class names used in the query
parsedQuery - the parsed query
Method Detail

getLocalizer

protected Localizer getLocalizer()
Description copied from class: AbstractExpressionBuilder
Used for obtaining the Localizer to use for translating error messages.

Specified by:
getLocalizer in class AbstractExpressionBuilder

getClassLoader

protected ClassLoader getClassLoader()
Description copied from class: AbstractExpressionBuilder
Returns the class loader that should be used for resolving class names (in addition to the resolver in the query).

Specified by:
getClassLoader in class AbstractExpressionBuilder

getParsedQuery

protected JPQLExpressionBuilder.ParsedJPQL getParsedQuery()

getParsedQuery

protected JPQLExpressionBuilder.ParsedJPQL getParsedQuery(String jpql)

resolveClassMetaData

protected ClassMetaData resolveClassMetaData(JPQLExpressionBuilder.JPQLNode node)

getCandidateMetaData

protected ClassMetaData getCandidateMetaData(JPQLExpressionBuilder.JPQLNode node)

currentQuery

protected String currentQuery()
Description copied from class: AbstractExpressionBuilder
Returns the current string being parsed; used for error messages.

Specified by:
currentQuery in class AbstractExpressionBuilder

evalFetchJoins

protected Expression evalFetchJoins(QueryExpressions exps)

evalSetClause

protected void evalSetClause(QueryExpressions exps)

isDeclaredVariable

protected boolean isDeclaredVariable(String name)
Description copied from class: AbstractExpressionBuilder
Returns whether the specified variable name has been explicitly declared. Note all query languages necessarily support declaring variables.

Specified by:
isDeclaredVariable in class AbstractExpressionBuilder
Parameters:
name - the variable to check
Returns:
true if the variabe has been explicitely declared

getVariable

protected Value getVariable(String id,
                            boolean bind)
Identification variables in JPQL are case insensitive, so lower-case all variables we are going to bind.

Overrides:
getVariable in class AbstractExpressionBuilder

isSeendVariable

protected boolean isSeendVariable(String id)

setImplicitTypes

protected void setImplicitTypes(Value val1,
                                Value val2,
                                Class expected)
Description copied from class: AbstractExpressionBuilder
Set the implicit types of the given values based on the fact that they're used together, and based on the operator type.

Overrides:
setImplicitTypes in class AbstractExpressionBuilder

getDeclaredVariableType

protected Class getDeclaredVariableType(String name)
Description copied from class: AbstractExpressionBuilder
Returns the type of the named variabe if it has been declared.

Specified by:
getDeclaredVariableType in class AbstractExpressionBuilder


Copyright © 2006-2007 Apache Software Foundation. All Rights Reserved.