Top Description Inners Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.resolver

public Class DeclarationResolver

extends Resolver
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.tools.resolver.EclipseLinkDeclarationResolver
Imports
java.util.HashMap, .HashSet, .LinkedList, .List, .Locale, .Map, .Set, org.eclipse.persistence.jpa.jpql.ExpressionTools, .LiteralType, org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor, .AbstractSchemaName, .AnonymousExpressionVisitor, .CollectionExpression, .CollectionMemberDeclaration, .CollectionValuedPathExpression, .DeleteClause, .DeleteStatement, .Expression, .FromClause, .IdentificationVariable, .IdentificationVariableDeclaration, .JPQLExpression, .Join, .NullExpression, .RangeVariableDeclaration, .ResultVariable, .SelectClause, .SelectStatement, .SimpleFromClause, .SimpleSelectClause, .SimpleSelectStatement, .SubExpression, .UpdateClause, .UpdateStatement, org.eclipse.persistence.jpa.jpql.tools.JPQLQueryContext, org.eclipse.persistence.jpa.jpql.tools.spi.IMapping, .IQuery, .IType, .ITypeDeclaration

This Resolver is responsible to visit the current query (which is either the top-level query or a subquery) and gathers the information from the declaration clause. For a SELECT or DELETE clause, the information will be retrieved from the FROM clause. For an UDPATE clause, it will be retrieved from the unique identification range variable declaration.
Author
Pascal Filion
Since
2.3
Version
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
protected static class
protected class
DeclarationResolver.RootObjectExpressionVisitor

This visitor takes care to support a subquery defined as a "root" object.

Field Summary

Modifier and TypeField and Description
private List<Declaration>
declarations

The Declarations of the current query that was parsed.

private DeclarationResolver.DeclarationVisitor
declarationVisitor

This visitor is responsible to visit the current query's declaration and populate this resolver with the list of declarations.

private DeclarationResolver.QualifyRangeDeclarationVisitor
qualifyRangeDeclarationVisitor

This visitor is responsible to convert the abstract schema name into a path expression.

private JPQLQueryContext
queryContext

The context used to query information about the query.

private Map<String, Resolver>
resolvers

Hides org.eclipse.persistence.jpa.jpql.tools.resolver.Resolver.resolvers.

The identification variable names mapped to their resolvers.
private Map<IdentificationVariable, String>
resultVariables

The variables identifying the select expressions, if any was defined or an empty set if none were defined.

private DeclarationResolver.RootObjectExpressionVisitor
rootObjectExpressionVisitor

This visitor resolves the "root" object represented by the given Expression.

Constructor Summary

AccessConstructor and Description
public
DeclarationResolver(DeclarationResolver
The parent resolver if this is used for a subquery or null if it's used for the top-level query
parent
,
JPQLQueryContext
The context used to query information about the query
queryContext
)

Creates a new DeclarationResolver.

Method Summary

Modifier and TypeMethod and Description
protected final void
addDeclaration(Declaration
The Declaration representing a single variable declaration
declaration
)

Adds the given Declaration at the end of the list.

public void
addRangeVariableDeclaration(String
The name of the entity to be accessible with the given variable name
entityName
,
String
The identification variable used to navigate to the entity
variableName
)

Registers a range variable declaration that will be used when a JPQL fragment is parsed.

protected DeclarationResolver.DeclarationVisitor
protected DeclarationResolver.RootObjectExpressionVisitor
protected IType
buildType()

Overrides org.eclipse.persistence.jpa.jpql.tools.resolver.Resolver.buildType.

Resolves the IType of the property handled by this Resolver.
protected ITypeDeclaration
protected void
public void
convertUnqualifiedDeclaration(Declaration
The Declaration that was parsed to range over an abstract schema name but is actually ranging over a path expression
declaration
,
String
The identification variable coming from the parent identification variable declaration
outerVariableName
)

Converts the given Declaration from being set as a range variable declaration to a path expression declaration.

public void
dispose()

Disposes the internal data.

public Declaration

Returns:

The Declaration containing the information about the identification variable declaration
getDeclaration
(String
The name of the identification variable that is used to navigate a "root" object
variableName
)

Retrieves the Declaration for which the given variable name is used to navigate to the "root" object.

public List<Declaration>

Returns:

The Declarations of the current query that was parsed
getDeclarations
()

Returns the ordered list of Declarations.

protected DeclarationResolver.DeclarationVisitor
public DeclarationResolver
public IQuery
getQuery()

Overrides org.eclipse.persistence.jpa.jpql.tools.resolver.Resolver.getQuery.

Returns the external form representing the JPQL query.
protected JPQLQueryContext

Returns:

The JPQLQueryContext holding onto the JPQL query and the cached information
getQueryContext
()

Returns the JPQLQueryContext that is used by this visitor.

public Resolver

Returns:

The Resolver mapped with the given identification variable
getResolver
(String
The identification variable that maps a Resolver
variableName
)

Retrieves the Resolver mapped with the given identification variable.

protected Resolver

Returns:

The Resolver mapped with the given identification variable
getResolverImp
(String
The identification variable that maps a Resolver
variableName
)

Retrieves the Resolver mapped with the given identification variable.

public Set<String>

Returns:

The variables identifying the select expressions, if any was defined or an empty set if none were defined
getResultVariables
()

Returns the variables that got defined in the select expression.

public Map<IdentificationVariable, String>

Returns:

The variables identifying the select expressions, if any was defined or an empty map if none were defined
getResultVariablesMap
()

Returns the map of result variables that got used to define a select expression.

protected DeclarationResolver.RootObjectExpressionVisitor
public boolean

Returns:

true if the query or subquery being traversed contains JOIN expressions; false otherwise
hasJoins
()

Determines whether the JPQL expression has JOIN expressions.

protected void
initialize(JPQLQueryContext
The context used to query information about the query
queryContext
)

Initializes this DeclarationResolver.

public boolean

Returns:

true if the given identification variable maps a collection-valued field defined in a JOIN or IN expression; false otherwise
isCollectionIdentificationVariable
(String
The identification variable to check for what it maps
variableName
)

Determines whether the given identification variable is defining a JOIN expression or in a IN expressions for a collection-valued field.

protected boolean

Returns:

true if the given identification variable maps a collection-valued field defined in a JOIN or IN expression; false otherwise
isCollectionIdentificationVariableImp
(String
The identification variable to check for what it maps
variableName
)

Determines whether the given identification variable is defining a JOIN expression or in a IN expressions for a collection-valued field.

public boolean

Returns:

true if the variable name is mapping an abstract schema name; false if it's defined in a collection member declaration
isRangeIdentificationVariable
(String
The name of the variable to verify if it's defined in a range variable declaration in the current query or any parent query
variableName
)

Determines whether the given variable name is an identification variable name mapping an entity.

protected boolean

Returns:

true if the variable name is mapping an abstract schema name; false if it's defined in a collection member declaration
isRangeIdentificationVariableImp
(String
The name of the variable to verify if it's defined in a range variable declaration in the current query or any parent query
variableName
)

Determines whether the given variable name is an identification variable name mapping an entity.

public boolean

Returns:

true if the given variable is defined as a result variable; false otherwise
isResultVariable
(String
The variable to check if it's a result variable
variable
)

Determines if the given variable is a result variable.

public void
populate(Expression
The Expression to visit in order to retrieve the information contained in the given query's declaration
expression
)

Visits the current query (which is either the top-level query or a subquery) and gathers the information from the declaration clause.

protected DeclarationResolver.QualifyRangeDeclarationVisitor
protected Resolver

Returns:

The Resolver for the given Expression
resolveRootObject
(Expression
The Expression to visit, which represents the "root" object of a declaration
expression
)

Resolves the "root" object represented by the given Expression.

protected String
visitDeclaration(Expression expression, Expression identificationVariable)

Inherited from org.eclipse.persistence.jpa.jpql.tools.resolver.Resolver:
addChildgetChildgetManagedTypegetMappinggetParentManagedTypegetParentMappinggetParentTypegetParentTypeDeclarationgetProvidergetTypegetTypegetTypegetTypeDeclarationgetTypeHelpergetTypeRepositoryisNullAllowedsetNullAllowed