public class GenericSemanticValidatorHelper extends java.lang.Object implements SemanticValidatorHelper
SemanticValidatorHelper that uses JPQLQueryContext to return
the required information and Hermes SPI.
Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
GenericSemanticValidatorHelper.IdentificationVariableVisitor |
| Constructor and Description |
|---|
GenericSemanticValidatorHelper(JPQLQueryContext queryContext)
Creates a new
GenericSemanticValidatorHelper. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addIdentificationVariable(IdentificationVariable identificationVariable,
java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables) |
protected GenericSemanticValidatorHelper.IdentificationVariableVisitor |
buildIdentificationVariableVisitor() |
void |
collectAllDeclarationIdentificationVariables(java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables)
Collects the identification variables that are defined in the
FROM clause of the
current query and from the parent queries. |
protected void |
collectLocalDeclarationIdentificationVariables(JPQLQueryContext queryContext,
java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables) |
void |
collectLocalDeclarationIdentificationVariables(java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables)
Collects the identification variables that are defined in the
FROM clause of the
current query. |
void |
disposeSubqueryContext()
Disposes this context, which is the current context being used by a subquery.
|
java.lang.String[] |
entityNames()
Returns the name of the all entities that are present in the context of a persistence unit.
|
java.util.List<JPQLQueryDeclaration> |
getAllDeclarations()
Returns the ordered list of
JPQLQueryDeclaration, which contain the information
contained in the query's FROM clause. |
IConstructor[] |
getConstructors(java.lang.Object type)
Returns the constructors for the given type.
|
java.util.List |
getDeclarations()
Returns the ordered list of
JPQLQueryDeclaration, which contain the information
contained in the query's FROM clause. |
IManagedType |
getEmbeddable(java.lang.Object type)
Retrieves the embeddable with the given type.
|
IEntity |
getEntityNamed(java.lang.String entityName)
Retrieves the entity with the given entity name.
|
java.lang.String[] |
getEnumConstants(java.lang.Object type)
Returns the constant names for the given
Enum type. |
JPQLGrammar |
getGrammar()
Returns the
JPQLGrammar that defines how the JPQL query was parsed. |
protected IdentificationVariable |
getIdentificationVariable(Expression expression) |
protected GenericSemanticValidatorHelper.IdentificationVariableVisitor |
getIdentificationVariableVisitor() |
IManagedType |
getManagedType(Expression expression)
Returns the managed type by resolving the given
Expression. |
IMapping |
getMappingNamed(java.lang.Object managedType,
java.lang.String path)
Returns the mapping with the given name.
|
IType |
getMappingType(java.lang.Object mapping)
Returns the type of the given mapping object.
|
ITypeDeclaration[] |
getMethodParameterTypeDeclarations(java.lang.Object constructor)
Returns the list of type declarations representing the given constructor's parameter types.
|
JPQLQueryContext |
getQueryContext()
Returns the context used to query information about the JPQL query.
|
IManagedType |
getReferenceManagedType(java.lang.Object relationshipMapping)
Returns the reference managed type from the given relationship mapping.
|
IType |
getType(Expression expression)
Returns the type by resolving the given
Expression. |
IType |
getType(java.lang.Object typeDeclaration)
Returns the type defined for the Java member.
|
IType |
getType(java.lang.String typeName)
Retrieves the class with the given fully qualified name.
|
ITypeDeclaration |
getTypeDeclaration(Expression expression)
Returns the type declaration for the given
Expression's type. |
ITypeHelper |
getTypeHelper()
Returns the helper that gives access to the most common class metadata.
|
java.lang.String |
getTypeName(java.lang.Object type)
Returns the fully qualified class name of the given type.
|
boolean |
isAssignableTo(java.lang.Object type1,
java.lang.Object type2)
Determines whether type 1 is an instance of type 2.
|
boolean |
isCollectionIdentificationVariable(java.lang.String variableName)
Determines whether the given identification variable is defining a join or a collection member
declaration expressions.
|
boolean |
isCollectionMapping(java.lang.Object mapping)
Determines whether the given mapping is a collection type mapping.
|
boolean |
isEnumType(java.lang.Object type)
Determines whether the given type represents an
Enum. |
boolean |
isIdentificationVariableValidInComparison(IdentificationVariable expression)
Determines whether an identification variable can be used in a comparison expression when the
operator is either '<', '<=', '>', '>='.
|
boolean |
isManagedTypeResolvable(java.lang.Object managedType)
Determines whether the given managed type actually exists.
|
boolean |
isPropertyMapping(java.lang.Object mapping)
Determines whether the given mapping is a property type mapping.
|
boolean |
isRelationshipMapping(java.lang.Object mapping)
Determines whether the given mapping is a relationship type mapping.
|
boolean |
isResultVariable(java.lang.String variableName)
Determines if the given variable is a result variable.
|
boolean |
isTransient(java.lang.Object mapping)
Determines whether the given mapping is a transient attribute.
|
boolean |
isTypeDeclarationAssignableTo(java.lang.Object typeDeclaration1,
java.lang.Object typeDeclaration2)
Determines whether type declaration 1 is an instance of type declaration 2.
|
boolean |
isTypeResolvable(java.lang.Object type)
Determines whether the given type actually exists.
|
void |
newSubqueryContext(SimpleSelectStatement expression)
Changes the state of this helper to use the given subquery.
|
IMapping |
resolveMapping(Expression expression)
Returns the mapping for the field represented by the given
Expression. |
IMapping |
resolveMapping(java.lang.String variableName,
java.lang.String name)
Returns the mapping that should be a persistence field from the entity defined by the given
identification variable.
|
public GenericSemanticValidatorHelper(JPQLQueryContext queryContext)
GenericSemanticValidatorHelper.queryContext - The context used to query information about the JPQL queryjava.lang.NullPointerException - The given JPQLQueryContext cannot be nullprotected void addIdentificationVariable(IdentificationVariable identificationVariable, java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables)
protected GenericSemanticValidatorHelper.IdentificationVariableVisitor buildIdentificationVariableVisitor()
public void collectAllDeclarationIdentificationVariables(java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables)
FROM clause of the
current query and from the parent queries.collectAllDeclarationIdentificationVariables in interface SemanticValidatorHelperidentificationVariables - The Map used to store the variablesprotected void collectLocalDeclarationIdentificationVariables(JPQLQueryContext queryContext, java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables)
public void collectLocalDeclarationIdentificationVariables(java.util.Map<java.lang.String,java.util.List<IdentificationVariable>> identificationVariables)
FROM clause of the
current query.collectLocalDeclarationIdentificationVariables in interface SemanticValidatorHelperidentificationVariables - The Map used to store the variablespublic void disposeSubqueryContext()
disposeSubqueryContext in interface SemanticValidatorHelperpublic java.lang.String[] entityNames()
entityNames in interface SemanticValidatorHelperpublic java.util.List<JPQLQueryDeclaration> getAllDeclarations()
JPQLQueryDeclaration, which contain the information
contained in the query's FROM clause.getAllDeclarations in interface SemanticValidatorHelperJPQLQueryDeclaration of the current query that was parsed and from
the parent queriespublic IConstructor[] getConstructors(java.lang.Object type)
If it was going through Hermes SPI, the type of the argument would be IType and the return type would be IConstructor.
getConstructors in interface SemanticValidatorHelperpublic java.util.List getDeclarations()
JPQLQueryDeclaration, which contain the information
contained in the query's FROM clause.getDeclarations in interface SemanticValidatorHelperJPQLQueryDeclaration of the current query that was parsedpublic IManagedType getEmbeddable(java.lang.Object type)
getEmbeddable in interface SemanticValidatorHelpertype - The Java type of the embeddable to retrievenull
otherwisepublic IEntity getEntityNamed(java.lang.String entityName)
getEntityNamed in interface SemanticValidatorHelperentityName - The abstract schema name of the entity to retrievenull otherwisepublic java.lang.String[] getEnumConstants(java.lang.Object type)
Enum type.
If it was going through Hermes SPI, the type of the argument would be
IType.
getEnumConstants in interface SemanticValidatorHelpertype - The Enum typepublic JPQLGrammar getGrammar()
JPQLGrammar that defines how the JPQL query was parsed.getGrammar in interface SemanticValidatorHelperJPQLGrammar that was used to parse the JPQL queryprotected IdentificationVariable getIdentificationVariable(Expression expression)
protected GenericSemanticValidatorHelper.IdentificationVariableVisitor getIdentificationVariableVisitor()
public IManagedType getManagedType(Expression expression)
Expression.
If it was going through Hermes SPI, the return type would be
IManagedType.
getManagedType in interface SemanticValidatorHelperpublic IMapping getMappingNamed(java.lang.Object managedType, java.lang.String path)
If it was going through Hermes SPI, the type of the argument would be
IManagedType
and the return type would be IMapping.
getMappingNamed in interface SemanticValidatorHelpermanagedType - The managed type that has a mapping with the given namepath - The name of the mapping to retrievenull if it could not be foundpublic IType getMappingType(java.lang.Object mapping)
If it was going through Hermes SPI, the type of the argument would be IMapping and the return type
would be IType.
getMappingType in interface SemanticValidatorHelpermapping - The mapping objectpublic ITypeDeclaration[] getMethodParameterTypeDeclarations(java.lang.Object constructor)
If it was going through Hermes SPI, the type of the argument would be IConstructor and the return type would be
ITypeDeclaration.
getMethodParameterTypeDeclarations in interface SemanticValidatorHelperconstructor - The constructor to return its parameter typespublic JPQLQueryContext getQueryContext()
public IManagedType getReferenceManagedType(java.lang.Object relationshipMapping)
If it was going through Hermes SPI, the type of the argument would be IMapping and the return type would be IManagedType.
getReferenceManagedType in interface SemanticValidatorHelperrelationshipMapping - The relationship mappingpublic IType getType(Expression expression)
Expression.
If it was going through Hermes SPI, the return type would be
IType.
getType in interface SemanticValidatorHelperexpression - The Expression to resolveExpression or null if it could not be
validatedpublic IType getType(java.lang.Object typeDeclaration)
If it was going through Hermes SPI, the type of the argument would be ITypeDeclaration and the return type would be
IType.
getType in interface SemanticValidatorHelperpublic IType getType(java.lang.String typeName)
If it was going through Hermes SPI, an IType would be returned.
getType in interface SemanticValidatorHelpertypeName - The fully qualified name of the class to retrievepublic ITypeDeclaration getTypeDeclaration(Expression expression)
Expression's type.
If it was going through Hermes SPI, the type of the argument would be
ITypeDeclaration.
getTypeDeclaration in interface SemanticValidatorHelperexpression - The Expression to resolveExpressionpublic ITypeHelper getTypeHelper()
getTypeHelper in interface SemanticValidatorHelperpublic java.lang.String getTypeName(java.lang.Object type)
If it was going through Hermes SPI, the type of the argument would be
IType.
getTypeName in interface SemanticValidatorHelpertype - The type to retrieve its namepublic boolean isAssignableTo(java.lang.Object type1,
java.lang.Object type2)
If it was going through Hermes SPI, the type of the arguments would be
IType.
isAssignableTo in interface SemanticValidatorHelpertype1 - The type to check if it is an instance of type 2type2 - The type used to determine if the class represented by type 1 is an instance
of with onetrue if type 1 is an instance of the type 2; false otherwisepublic boolean isCollectionIdentificationVariable(java.lang.String variableName)
isCollectionIdentificationVariable in interface SemanticValidatorHelpervariableName - 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 isCollectionMapping(java.lang.Object mapping)
If it was going through Hermes SPI, the type of the arguments would be
IMapping.
isCollectionMapping in interface SemanticValidatorHelpermapping - The mapping object to verify if it represents a collection mappingtrue if the given mapping is a collection mapping; false
otherwisepublic boolean isEnumType(java.lang.Object type)
Enum.
If it was going through Hermes SPI, the type of the argument would be
IType.
isEnumType in interface SemanticValidatorHelpertrue if the given type is an Enum; false otherwisepublic boolean isIdentificationVariableValidInComparison(IdentificationVariable expression)
isIdentificationVariableValidInComparison in interface SemanticValidatorHelperexpression - The IdentificationVariable that is mapped to either an entity, a
singled-object value field, a collection-valued object fieldtrue if it can be used in a ordering comparison expression; false
if it can'tpublic boolean isManagedTypeResolvable(java.lang.Object managedType)
If it was going through Hermes SPI, the type of the argument would be
IManagedType.
isManagedTypeResolvable in interface SemanticValidatorHelpertrue if the given managed type can be located; false if it
could not be foundpublic boolean isPropertyMapping(java.lang.Object mapping)
If it was going through Hermes SPI, the type of the arguments would be
IMapping.
isPropertyMapping in interface SemanticValidatorHelpermapping - The mapping object to verify if it represents a property mappingtrue if the given mapping is a property mapping; false otherwisepublic boolean isRelationshipMapping(java.lang.Object mapping)
If it was going through Hermes SPI, the type of the arguments would be
IMapping.
isRelationshipMapping in interface SemanticValidatorHelpermapping - The mapping object to verify if it represents a relationship mappingtrue if the given mapping is a relationship mapping; false otherwisepublic boolean isResultVariable(java.lang.String variableName)
isResultVariable in interface SemanticValidatorHelpervariableName - The variable to check if it's a result variabletrue if the given variable is defined as a result variable;
false otherwisepublic boolean isTransient(java.lang.Object mapping)
If it was going through Hermes SPI, the type of the arguments would be
IMapping.
isTransient in interface SemanticValidatorHelpermapping - The mapping object to verify if it represents a transient attributetrue if the given attribute is a transient mapping; false otherwisepublic boolean isTypeDeclarationAssignableTo(java.lang.Object typeDeclaration1,
java.lang.Object typeDeclaration2)
If it was going through Hermes SPI, the type of the arguments would be
ITypeDeclaration.
isTypeDeclarationAssignableTo in interface SemanticValidatorHelpertypeDeclaration1 - The type declaration to check if it is an instance of type declaration 2typeDeclaration2 - The type used to determine if the class represented by type
declaration 1 is an instance of with onetrue if type declaration 1 is an instance of the type declaration 2;
false otherwisepublic boolean isTypeResolvable(java.lang.Object type)
If it was going through Hermes SPI, the type of the argument would be
IType.
isTypeResolvable in interface SemanticValidatorHelpertrue if the actual class exists; false otherwisepublic void newSubqueryContext(SimpleSelectStatement expression)
newSubqueryContext in interface SemanticValidatorHelperexpression - The parsed tree representation of the subquery that will become the current querySemanticValidatorHelper.disposeSubqueryContext()public IMapping resolveMapping(Expression expression)
Expression.
If it was going through Hermes SPI, the return type would be
IMapping.
resolveMapping in interface SemanticValidatorHelperexpression - The Expression representing a state field path expression or a
collection-valued path expressionnull if none existspublic IMapping resolveMapping(java.lang.String variableName, java.lang.String name)
If it was going through Hermes SPI, the return type would be
IMapping.
resolveMapping in interface SemanticValidatorHelpervariableName - The identification variable that is defined in the FROM
clause of the query (which can be in the current subquery) or in one of the parent queries.name - The name of the persistent field to retrievenull if it could not be found