public class JPQLQueryContext extends Object
Constructor and Description |
---|
JPQLQueryContext()
Creates a new
JPQLQueryContext . |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes the internal data.
|
void |
disposeSubqueryContext()
Disposes this context, which is the current context being used for a subquery.
|
DeclarationResolver |
getActualDeclarationResolver()
Returns the
DeclarationResolver of this context and not from the current query's
declaration. |
Expression |
getCurrentQuery()
Returns the current
Expression being manipulated, which is either the top-level query
or a subquery. |
List<DeclarationResolver.Declaration> |
getDeclarations()
Returns the ordered list of
Declarations . |
IType |
getEnumType(String enumTypeName)
Returns the
IType representing the possible given enum type. |
Collection<JoinFetch> |
getJoinFetches(String variableName)
Returns the parsed representation of a JOIN FETCH that were defined in the same
declaration than the given range identification variable name.
|
JPQLExpression |
getJPQLExpression()
Returns the parsed tree representation of the JPQL query.
|
String |
getJPQLQuery()
Returns the string representation of the JPQL query.
|
IMapping |
getMapping(Expression expression)
Returns the
IMapping for the field represented by the given Expession . |
IType |
getParameterType(InputParameter inputParameter)
Retrieves, if it can be determined, the type of the given
InputParameter . |
JPQLQueryContext |
getParent()
Returns the parent context if the current context is not the root context.
|
IManagedTypeProvider |
getProvider()
Retrieves the provider of managed types.
|
IQuery |
getQuery()
Returns the external form of the JPQL query.
|
Resolver |
getResolver(Expression expression)
Creates or retrieved the cached
Resolver for the given Expression . |
Resolver |
getResolver(String variableName)
Retrieves the
Resolver mapped with the given identification variable. |
Set<String> |
getResultVariables()
Returns the variables that got defined in the select expression.
|
IType |
getType(Class<?> type)
Retrieves the external type for the given Java type.
|
IType |
getType(Expression expression)
Returns the
IType of the given Expression . |
IType |
getType(String typeName)
Retrieves the external class for the given fully qualified class name.
|
ITypeDeclaration |
getTypeDeclaration(Expression expression)
Returns the
ITypeDeclaration of the field handled by this Resolver . |
TypeHelper |
getTypeHelper()
Returns a helper that gives access to the most common
types . |
ITypeRepository |
getTypeRepository()
Returns the type repository for the application.
|
boolean |
hasJoins()
Determines whether the JPQL expression has JOIN expressions.
|
boolean |
isCollectionVariableName(String variableName)
Determines whether the given identification variable is defining a join or a collection member
declaration expressions.
|
boolean |
isRangeIdentificationVariable(String variableName)
Determines whether the given variable name is an identification variable name used to define
an abstract schema name.
|
String |
literal(Expression expression,
LiteralType type)
Retrieves the "literal" from the given
Expression . |
void |
newSubqueryContext(Expression currentQuery)
Changes the state of this context to use the given subquery.
|
void |
setJPQLExpression(JPQLExpression jpqlExpression)
Sets the parsed tree representation of the JPQL query.
|
void |
setQuery(IQuery query)
Sets the external form of the JPQL query, which will be parsed and information will be
extracted for later access.
|
String |
toString() |
public void dispose()
public void disposeSubqueryContext()
public DeclarationResolver getActualDeclarationResolver()
DeclarationResolver
of this context and not from the current query's
declaration.DeclarationResolver
for this contextpublic Expression getCurrentQuery()
Expression
being manipulated, which is either the top-level query
or a subquery.public List<DeclarationResolver.Declaration> getDeclarations()
Declarations
.Declarations
of the current query that was parsedpublic IType getEnumType(String enumTypeName)
IType
representing the possible given enum type. If the type nameenumTypeName
- The fully qualified enum type with the constantpublic Collection<JoinFetch> getJoinFetches(String variableName)
variableName
- The name of the identification variable that should be used to define an
abstract schema namepublic JPQLExpression getJPQLExpression()
public String getJPQLQuery()
public IMapping getMapping(Expression expression)
IMapping
for the field represented by the given Expession
.expression
- The Expression
representing a state field path expression or a
collection-valued path expressionIMapping
or null
if none existspublic IType getParameterType(InputParameter inputParameter)
InputParameter
. The type
will be guessed based on its location within expression.
Note: Both named and positional input parameter can be used.
inputParameter
- The InputParameter
to retrieve its typenull
if the type could
not be determinedpublic JPQLQueryContext getParent()
null
if the current context is the rootpublic IManagedTypeProvider getProvider()
public IQuery getQuery()
public Resolver getResolver(Expression expression)
Resolver
for the given Expression
. The
Resolver
can return the IType
and ITypeDeclaration
of the Expression
and either the IManagedType
or the IMapping
.expression
- The Expression
for which its Resolver
will be retrievedResolver
for the given Expression
public Resolver getResolver(String variableName)
Resolver
mapped with the given identification variable. If the
identification is not defined in the declaration traversed by this resolver, than the search
will traverse the parent hierarchy.public Set<String> getResultVariables()
public IType getType(Class<?> type)
type
- The Java type to wrap with an external formpublic IType getType(Expression expression)
IType
of the given Expression
.expression
- The Expression
for which its type will be calculatedIType
that was resolved by this Resolver
or the
IType
for IType.UNRESOLVABLE_TYPE
if it could not be resolvedpublic IType getType(String typeName)
name
- The fully qualified class name of the class to retrievepublic ITypeDeclaration getTypeDeclaration(Expression expression)
ITypeDeclaration
of the field handled by this Resolver
.expression
- The Expression
for which its type declaration will be calculatedITypeDeclaration
that was resolved by this Resolver
or the
ITypeDeclaration
for IType.UNRESOLVABLE_TYPE
if it could not be resolvedpublic TypeHelper getTypeHelper()
types
.IType
public ITypeRepository getTypeRepository()
ITypes
public boolean hasJoins()
true
if the query or subquery being traversed contains JOIN
expressions; false
otherwisepublic boolean isCollectionVariableName(String variableName)
variableName
- The identification variable to check for what it mapstrue
if the given identification variable maps a collection-valued field
defined in a JOIN
or IN
expression; false
if it's not
defined or it's mapping an abstract schema namepublic boolean isRangeIdentificationVariable(String variableName)
variableName
- The name of the variable to verify if it's defined in a range variable
declaration in the current query or any parent querytrue
if the variable name is mapping an abstract schema name; false
if it's defined in a collection member declarationpublic String literal(Expression expression, LiteralType type)
Expression
. The literal to retrieve depends on
the given type
. The literal is basically a string value like an
identification variable name, an input parameter, a path expression, an abstract schema name,
etc.expression
- The Expression
to visittype
- The LiteralType
helps to determine what to retrieve from the visited
Expression
Expression
or an empty string if the given Expression
and the LiteralType
do not matchpublic void newSubqueryContext(Expression currentQuery)
currentQuery
- The parsed tree representation of the subquery that will become the
current query#disposeSubQueryContext()
public void setJPQLExpression(JPQLExpression jpqlExpression)
setQuery(IQuery)
because the JPQL query is automatically parsed by that method.jpqlExpression
- The parsed representation of the JPQL query to manipulatesetQuery(IQuery)
public void setQuery(IQuery query)
query
- The external form of the JPQL querysetJPQLExpression(JPQLExpression)
EclipseLink 2.3.2, "build v20111125-r10461" API Reference