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

public abstract Class AbstractGrammarValidator

extends AbstractValidator
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.EclipseLinkGrammarValidator, org.eclipse.persistence.jpa.jpql.tools.DefaultGrammarValidator
Annotations
@SuppressWarnings:nls
Imports
java.util.ArrayList, .Collection, .HashMap, .List, .Map, org.eclipse.persistence.jpa.jpql.parser.AbsExpression, .AbstractConditionalClause, .AbstractDoubleEncapsulatedExpression, .AbstractEncapsulatedExpression, .AbstractExpressionVisitor, .AbstractFromClause, .AbstractPathExpression, .AbstractSchemaName, .AbstractSelectClause, .AbstractSelectStatement, .AbstractSingleEncapsulatedExpression, .AbstractTripleEncapsulatedExpression, .AdditionExpression, .AggregateFunction, .AllOrAnyExpression, .AndExpression, .ArithmeticExpression, .ArithmeticExpressionBNF, .ArithmeticFactor, .ArithmeticPrimaryBNF, .ArithmeticTermBNF, .AvgFunction, .BadExpression, .BetweenExpression, .CaseExpression, .CoalesceExpression, .CollectionExpression, .CollectionMemberDeclaration, .CollectionMemberExpression, .CollectionValuedPathExpression, .CollectionValuedPathExpressionBNF, .ComparisonExpression, .CompoundExpression, .ConcatExpression, .ConditionalExpressionBNF, .ConstructorExpression, .CountFunction, .DateTime, .DeleteClause, .DeleteStatement, .DivisionExpression, .EmptyCollectionComparisonExpression, .EntityTypeLiteral, .EntryExpression, .ExistsExpression, .Expression, .FromClause, .FunctionExpression, .GroupByClause, .HavingClause, .IdentificationVariable, .IdentificationVariableBNF, .IdentificationVariableDeclaration, .InExpression, .IndexExpression, .InputParameter, .InternalOrderByItemBNF, .JPQLExpression, .JPQLGrammar, .JPQLQueryBNF, .Join, .JoinAssociationPathExpressionBNF, .KeyExpression, .KeywordExpression, .LengthExpression, .LikeExpression, .LikeExpressionEscapeCharacterBNF, .LocateExpression, .LogicalExpression, .LowerExpression, .MaxFunction, .MinFunction, .ModExpression, .MultiplicationExpression, .NotExpression, .NullComparisonExpression, .NullExpression, .NullIfExpression, .NumericLiteral, .ObjectExpression, .OnClause, .OrExpression, .OrderByClause, .OrderByItem, .RangeDeclarationBNF, .RangeVariableDeclaration, .ResultVariable, .SelectClause, .SelectStatement, .SimpleFromClause, .SimpleSelectClause, .SimpleSelectStatement, .SizeExpression, .SqrtExpression, .StateFieldPathExpression, .StringLiteral, .SubExpression, .SubstringExpression, .SubtractionExpression, .SumFunction, .TreatExpression, .TrimExpression, .TypeExpression, .UnknownExpression, .UpdateClause, .UpdateItem, .UpdateStatement, .UpperExpression, .ValueExpression, .WhenClause, .WhereClause

The base validator responsible to gather the problems found in a JPQL query by validating it against the provided JPQL grammar. The semantic of the JPQL query is not validated by this visitor.

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.

Author
Pascal Filion
See Also
org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract static class
AbstractGrammarValidator.AbstractCollectionValidator

This validate is responsible to validate the collection of Expressions:

  • Making sure they are all separated by a comma or by a space (depending on which one is required);
  • Making sure it does not end with a comma;
  • There is no empty expression between two commas.
protected abstract static class
protected static interface
protected abstract static class
AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<T extends AbstractSingleEncapsulatedExpression>

The abstract implementation of AbstractSingleEncapsulatedExpressionHelper which implements some of the methods since the behavior is the same for all subclasses of AbstractSingleEncapsulatedExpression.

protected abstract static class
private abstract static class
protected static class
protected static class
AbstractGrammarValidator.CollectionSeparatedByCommaValidator

This validator validates a CollectionExpression by making sure each item is separated by a comma.

protected static class
AbstractGrammarValidator.CollectionSeparatedBySpaceValidator

This validator validates a CollectionExpression by making sure each item is not separated by a comma.

protected static class
protected static class
protected static class
AbstractGrammarValidator.NullExpressionVisitor

This visitor checks to see if the visited expression is NullExpression.

Field Summary

Modifier and TypeField and Description
private AbstractGrammarValidator.CollectionExpressionVisitor
collectionExpressionVisitor

This visitor determines whether the visited Expression is the CollectionExpression.

private AbstractGrammarValidator.CollectionSeparatedByCommaValidator
collectionSeparatedByCommaValidator

This validator validates a CollectionExpression by making sure each item is separated by a comma.

private AbstractGrammarValidator.CollectionSeparatedBySpaceValidator
collectionSeparatedBySpaceValidator

This validator validates a CollectionExpression by making sure each item is separated by a space.

private AbstractGrammarValidator.ComparisonExpressionVisitor
comparisonExpressionVisitor

This visitor is responsible to retrieve the visited Expression if it is a ComparisonExpression.

private Map<String, Object>
helpers

The registered expression helper mapped by the unique JPQL identifier of the same expression to validate.

private Collection<InputParameter>
inputParameters

The cached InputParameters that are present in the entire JPQL query.

private JPQLGrammar
jpqlGrammar

The JPQLGrammar that defines how the JPQL query was parsed.

Constructor Summary

AccessConstructor and Description
protected
AbstractGrammarValidator(JPQLGrammar
The JPQLGrammar that defines how the JPQL query was parsed, which cannot be null
jpqlGrammar
)

Creates a new AbstractGrammarValidator.

Method Summary

Modifier and TypeMethod and Description
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<AbsExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<AllOrAnyExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<AvgFunction>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<AbsExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<AllOrAnyExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<AvgFunction>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<CoalesceExpression>
protected AbstractGrammarValidator.CollectionExpressionVisitor
buildCollectionExpressionVisitor()

Creates a visitor that collects the CollectionExpression if it's been visited.

protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ConcatExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<CountFunction>
protected AbstractGrammarValidator.DateTimeVisitor
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<EntryExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ExistsExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<FunctionExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<IndexExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<KeyExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<LengthExpression>
protected AbstractGrammarValidator.AbstractTripleEncapsulatedExpressionHelper<LocateExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<LowerExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<MaxFunction>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<MinFunction>
protected AbstractGrammarValidator.AbstractDoubleEncapsulatedExpressionHelper<ModExpression>
protected AbstractGrammarValidator.NullExpressionVisitor

Returns:

A new NullExpressionVisitor
buildNullExpressionVisitor
()

Creates a visitor that collects the NullExpression if it's been visited.

protected AbstractGrammarValidator.AbstractDoubleEncapsulatedExpressionHelper<NullIfExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ObjectExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<SizeExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<SqrtExpression>
protected AbstractGrammarValidator.AbstractTripleEncapsulatedExpressionHelper<SubstringExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<SumFunction>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<TrimExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<TypeExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<UpperExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ValueExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<CoalesceExpression>
protected AbstractGrammarValidator.CollectionSeparatedByCommaValidator
protected AbstractGrammarValidator.CollectionSeparatedBySpaceValidator
protected AbstractGrammarValidator.ComparisonExpressionVisitor
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ConcatExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<CountFunction>
public void
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<EntryExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ExistsExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<FunctionExpression>
protected CollectionExpression

Returns:

The given Expression if it is a CollectionExpression or null if it is any other object
getCollectionExpression
(Expression
The Expression to cast
expression
)

Casts the given Expression to a CollectionExpression if it is actually an object of that type.

protected AbstractGrammarValidator.CollectionExpressionVisitor
getCollectionExpressionVisitor()

Returns the visitor that collects the CollectionExpression if it's been visited.

protected AbstractGrammarValidator.DateTimeVisitor
protected JPQLGrammar
getGrammar()

Implements abstract org.eclipse.persistence.jpa.jpql.AbstractValidator.getGrammar.

Returns the JPQLGrammar that defines how the JPQL query was parsed.
protected <
This is the type parameter
T
>
T

Returns:

Either the cached helper or null if no helper was previously cached for the given id
getHelper
(String
The key used to retrieve the cached helper, if one was cached
id
)

Returns the registered helper that was cached with the given id.

protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<IndexExpression>
protected void
protected boolean
protected boolean

Returns:

true if the given given Expression is a CollectionExpression; false otherwise
isCollectionExpression
(Expression
The Expression to verify
expression
)

Determines whether the given Expression is a CollectionExpression.

protected boolean

Returns:

true if the given Expression represents one of the tree date constants; false otherwise
isDateTimeConstant
(Expression
The Expression to visit
leftExpression
)

Determines whether the given Expression represents one of the three date constants or not.

protected boolean
protected abstract boolean

Returns:

true if the expression can have an identification variable; false otherwise
isJoinFetchIdentifiable
()

Determines whether a JOIN FETCH expression can be identified by with an identification variable or not.

protected boolean

Returns:

true if the JPQL grammar was defined for JPA 1.0; false if it was defined for a more recent version
isJPA1_0
()

Determines whether the JPA version defined by the JPQL grammar is 1.0.

protected boolean

Returns:

true if the JPQL grammar was defined for JPA 2.0; false if it was defined for a more recent version
isJPA2_0
()

Determines whether the JPA version defined by the JPQL grammar is 2.0.

protected boolean

Returns:

true if the JPQL grammar was defined for JPA 2.1; false if it was defined for a more recent version
isJPA2_1
()

Determines whether the JPA version defined by the JPQL grammar is 2.1.

protected boolean

Returns:

true if it can return more than one item; false if it needs to return only one item
isMultipleSubquerySelectItemsAllowed
(SimpleSelectClause
The subquery SELECT clause
expression
)

Determines whether the given subquery SELECT clause can return more than one item or just a single.

protected final boolean

Returns:

true if this constant represents a newer version and the given constant represents a version that is older; false if the given constant represents a newer and this constant represents an older version
isNewerThan
(JPAVersion
The constant to verify if it's representing a version that is older than this one
version
)

Determines whether the JPA version for which the JPQL grammar was defined represents a version that is newer than the given version.

protected final boolean

Returns:

true if this constant represents a newer version and the given constant represents a version that is older or if it's the same constant; false if the given constant represents a newer and this constant represents an older version
isNewerThanOrEqual
(JPAVersion
The constant to verify if it's representing a version that is older than this one or if it's the same than this one
version
)

Determines whether the JPA version for which the JPQL grammar was defined represents a version that is newer than the given version or if it's the same version.

protected boolean

Returns:

true if the given sequence of characters is a valid numeric literal; false otherwise
isNumericLiteral
(String
The sequence of characters to validate
text
)

Determines whether the given sequence of characters is a numeric literal or not.

protected final boolean

Returns:

true if this constant represents an earlier version and the given constant represents a version that is more recent; false if the given constant represents an earlier version and this constant represents a more recent version
isOlderThan
(JPAVersion
The constant to verify if it's representing a version that is more recent than this one
version
)

Determines whether the JPA version for which the JPQL grammar was defined represents a version that is older than the given version.

protected final boolean

Returns:

true if this constant represents an earlier version and the given constant represents a version that is more recent or if it's the same constant; false if the given constant represents an earlier version and this constant represents a more recent version
isOlderThanOrEqual
(JPAVersion
The constant to verify if it's representing a version that is more recent than this one or if it's the same than this one
version
)

Determines whether the JPA version for which the JPQL grammar was defined represents a version that is older than the given version or if it's the same version.

protected boolean

Returns:

true if the first parent being a clause is the WHERE or HAVING clause; false otherwise
isOwnedByConditionalClause
(Expression
The Expression to visit its parent hierarchy up to the clause
expression
)

Determines whether the given Expression is a child of the WHERE or HAVING clause of the top-level query.

protected boolean

Returns:

true if the first parent being a clause is the top-level FROM clause; false otherwise
isOwnedByFromClause
(Expression
The Expression to visit its parent hierarchy up to the clause
expression
)

Determines whether the given Expression is a child of the FROM clause of the top-level query.

protected boolean

Returns:

true if the first parent being a clause is the FROM clause of a subquery; false otherwise
isOwnedBySubFromClause
(Expression
The Expression to visit its parent hierarchy up to the clause
expression
)

Determines whether the given Expression is a child of the FROM clause of a subquery.

protected abstract boolean

Returns:

true if a subquery can be defined in any clause; false if it can only be used within the WHERE and HAVING defined by the JPA 1.0 and 2.0 specification document
isSubqueryAllowedAnywhere
()

Determines whether a subquery can be used in any clause of the top-level query.

protected boolean

Returns:

true if the given variable follows the Java identifier specification; false otherwise
isValidJavaIdentifier
(String
The variable to validate
variable
)

Determines whether the given variable is a valid Java identifier, which means it follows the Java specification.

protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<KeyExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<LengthExpression>
protected AbstractGrammarValidator.AbstractTripleEncapsulatedExpressionHelper<LocateExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<LowerExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<MaxFunction>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<MinFunction>
protected AbstractGrammarValidator.AbstractDoubleEncapsulatedExpressionHelper<ModExpression>
protected AbstractGrammarValidator.AbstractDoubleEncapsulatedExpressionHelper<NullIfExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ObjectExpression>
protected int
position(Expression expression, int... extras)

protected void
registerHelper(String
The key used to cache the given helper
id
,
Object
The helper to cache for future use
helper
)

Registers the given helper.

protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<SizeExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<SqrtExpression>
protected AbstractGrammarValidator.AbstractTripleEncapsulatedExpressionHelper<SubstringExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<SumFunction>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<TrimExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<TypeExpression>
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<UpperExpression>
protected void
validateAbstractConditionalClause(AbstractConditionalClause expression, String missingConditionalExpressionMessageKey, String invalidConditionalExpressionMessageKey)

protected <
This is the type parameter
T extends AbstractDoubleEncapsulatedExpression
>
void
validateAbstractDoubleEncapsulatedExpression(T expression, AbstractGrammarValidator.AbstractDoubleEncapsulatedExpressionHelper<T>
This helper is used to retrieve specific information related to the expression being validated
helper
)

Validates the content of an AbstractDoubleEncapsulatedExpression, which encapsulates two expressions separated by a comma.

protected void
protected void
validateAbstractSelectClause(AbstractSelectClause
The AbstractSelectClause to validate
expression
,
boolean
Determines whether the SELECT can have one or more select expression or not
multipleSelectItemsAllowed
)

Validates the select expression of the given SELECT clause.

protected void
protected <T extends AbstractSingleEncapsulatedExpression> void
protected <T extends AbstractTripleEncapsulatedExpression> void
protected <T extends AggregateFunction> void
protected void
protected void
validateCollectionSeparatedByComma(Expression
The Expression to validate its children, which should be a series of Expression separated by a comma
expression
,
String
The problem key describing the CollectionExpression is ending with a comma
endsWithCommaProblemKey
,
String
The problem key describing the CollectionExpression has two items not separated by a comma
missingCommaProblemKey
)

Validates the given Expression by making sure each child is separated by a comma.

protected void
validateCollectionSeparatedBySpace(Expression
The Expression to validate its children, which should be a series of Expression separated by a whitespace
expression
,
String
The problem key describing the CollectionExpression is ending with a comma
endsWithCommaProblemKey
,
String
The problem key describing the CollectionExpression has two items separated by a comma
hasCommaProblemKey
)

Validates the given Expression by making sure each child is separated by a whitespace.

protected void
validateCompoundExpression(CompoundExpression expression, String identifier, String missingLeftExpression, String invalidLeftExpression, String missingRightExpression, String invalidRightExpression, String leftExpressionQueryBNF, String rightExpressionQueryBNF)

protected void
protected void
validateIdentifier(Expression
The expression to validate
expression
,
String
The text to actually validate
variableName
,
int
The actual length of the text, which can be longer than the text that is validated
variableLength
,
String
The problem key used when the variable name is a reserved JPQL identifier
reservedWordProblemKey
,
String
The problem key used when the variable name is not a valid Java identifier
invalidJavaIdentifierProblemKey
)

Validates the given variable name to make sure:

  • It is not a JPQL reserved identifier;
  • It is a valid Java identifier.
protected void
protected void
protected void
protected void
validateLogicalExpression(LogicalExpression expression, String leftExpressionQueryBNF, String rightExpressionQueryBNF)

protected void
protected void
protected void
protected AbstractGrammarValidator.AbstractSingleEncapsulatedExpressionHelper<ValueExpression>
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
Inherited from org.eclipse.persistence.jpa.jpql.AbstractValidator:
addProblemaddProblemaddProblemaddProblembuildChildrenCollectorbuildLiteralVisitorbuildNestedArrayVisitorbuildOwningClauseVisitorbuildOwningStatementVisitorbuildProblembuildSubqueryVisitorgetBypassChildCollectionExpressionVisitorgetBypassParentSubExpressionVisitorgetChildrengetChildrenCollectorVisitorgetExpressionRegistrygetExpressionValidatorgetJPAVersiongetJPQLQueryBNFValidatorgetJPQLQueryBNFValidatorgetLiteralVisitorgetNestedArrayVisitorgetOwningClauseVisitorgetOwningStatementVisitorgetProvidergetProviderVersiongetQueryBNFgetSubqueryVisitorisNestedArrayisSubqueryisValidisValidisValidisValidWithChildCollectionBypassisWithinSubqueryisWithinTopLevelQuerylengthliteralnestedArraySizepositionproblemsSizesetProblemsvisit