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

public abstract Class AbstractValidator

extends AnonymousExpressionVisitor
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.AbstractGrammarValidator, org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
Annotations
@SuppressWarnings:nls
Imports
java.util.Collection, .HashMap, .HashSet, .LinkedList, .List, .Map, .Set, org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor, .AbstractTraverseParentVisitor, .AnonymousExpressionVisitor, .BadExpression, .CollectionExpression, .DeleteClause, .DeleteStatement, .Expression, .ExpressionRegistry, .ExpressionVisitor, .FromClause, .GroupByClause, .HavingClause, .JPQLGrammar, .JPQLQueryBNF, .NullExpression, .OrderByClause, .SelectClause, .SelectStatement, .SimpleFromClause, .SimpleSelectClause, .SimpleSelectStatement, .SubExpression, .UnknownExpression, .UpdateClause, .UpdateStatement, .WhereClause, org.eclipse.persistence.jpa.jpql.utility.CollectionTools

The abstract definition of a validator, which provides helper methods and visitors.

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
Since
2.4
Version
2.5
See Also
AbstractGrammarValidator, AbstractSemanticValidator

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AbstractValidator.BypassChildCollectionExpressionVisitor

This visitor is responsible to traverse the children of a CollectionExpression in order to properly validate the Expression.

public static class
AbstractValidator.BypassParentSubExpressionVisitor

This visitor is responsible to traverse the parent hierarchy and to skip SubExpression if it's a parent.

public static class
AbstractValidator.ChildrenCollectorVisitor

This visitor gathers the children of a CollectionExpression or a single visited Expression.

public static class
AbstractValidator.JPQLQueryBNFValidator

This visitor validates any Expression by checking its BNF against some BNFs.

protected static class
public static class
AbstractValidator.OwningClauseVisitor

This visitor retrieves the clause owning the visited Expression.

protected static class
AbstractValidator.OwningStatementVisitor

This visitor retrieves the statement owning the visited Expression.

protected static class
AbstractValidator.SubqueryVisitor

This visitor retrieves the statement owning the visited Expression.

Field Summary

Modifier and TypeField and Description
private AbstractValidator.BypassChildCollectionExpressionVisitor
bypassChildCollectionExpressionVisitor

This visitor is responsible to traverse the children of a CollectionExpression in order to properly validate the Expression.

private AbstractValidator.BypassParentSubExpressionVisitor
bypassParentSubExpressionVisitor

This visitor is responsible to traverse the parent hierarchy and to skip SubExpression if it's a parent.

private AbstractValidator.ChildrenCollectorVisitor
childrenCollectorVisitor

This visitor gathers the children of a CollectionExpression or a single visited Expression.

private LiteralVisitor
literalVisitor

This visitor is used to retrieve a variable name from various type of JPQL Expression.

private AbstractValidator.NestedArrayVisitor
private AbstractValidator.OwningClauseVisitor
owningClauseVisitor

This visitor is responsible to traverse the parent hierarchy and to retrieve the owning clause of the Expression being visited.

private AbstractValidator.OwningStatementVisitor
owningStatementVisitor

This visitor is responsible to traverse the parent hierarchy and to retrieve the owning statement of the Expression being visited.

private Collection<JPQLQueryProblem>
problems

The list of JPQLQueryProblem describing grammatical and semantic issues found in the query.

private AbstractValidator.SubqueryVisitor
subqueryVisitor

This visitor determines whether the visited Expression is a subquery or not.

private Map<String, AbstractValidator.JPQLQueryBNFValidator>
validators

The JPQLQueryBNFValidator mapped by the BNF IDs.

Constructor Summary

AccessConstructor and Description
protected
AbstractValidator()

Creates a new AbstractValidator.

Method Summary

Modifier and TypeMethod and Description
protected void
addProblem(Expression
The Expression that is either not following the BNF grammar or that has semantic problems
expression
,
int
The position where the problem was encountered
startPosition
,
int
The position where the problem ends, inclusively
endPosition
,
String
The key used to retrieve the localized message describing the problem
messageKey
,
String...
The list of arguments that can be used to format the localized description of the problem
messageArguments
)

Adds a new validation problem that was found in the given Expression.

protected void
addProblem(Expression
The Expression that is either not following the BNF grammar or that has semantic problems
expression
,
int
The position where the problem was encountered
startPosition
,
String
The key used to retrieve the localized message describing the problem
messageKey
,
String...
The list of arguments that can be used to format the localized description of the problem
messageArguments
)

Adds a new validation problem that was found in the given Expression.

protected void
addProblem(Expression
The Expression that is either not following the BNF grammar or that has semantic problems
expression
,
String
The key used to retrieve the localized message describing the problem
messageKey
)

Adds a new validation problem that was found in the given Expression.

protected void
addProblem(Expression
The Expression that is either not following the BNF grammar or that has semantic problems
expression
,
String
The key used to retrieve the localized message describing the problem
messageKey
,
String...
The list of arguments that can be used to format the localized description of the problem
arguments
)

Adds a new validation problem that was found in the given Expression.

protected AbstractValidator.ChildrenCollectorVisitor
protected abstract LiteralVisitor

Returns:

A new LiteralVisitor
buildLiteralVisitor
()

Creates the visitor that can retrieve some information about various literal.

protected AbstractValidator.NestedArrayVisitor

Returns:

A new NestedArrayVisitor
buildNestedArrayVisitor
()

Creates the visitor that traverses an Expression and determines if it's a nested array or not.

protected abstract AbstractValidator.OwningClauseVisitor

Returns:

A new OwningClauseVisitor
buildOwningClauseVisitor
()

Creates the visitor that traverses the parent hierarchy of any Expression and stops at the first Expression that is a clause.

protected AbstractValidator.OwningStatementVisitor

Returns:

A new OwningStatementVisitor
buildOwningStatementVisitor
()

Creates the visitor that traverses the parent hierarchy of any Expression and stops at the first Expression that is a statement.

protected JPQLQueryProblem

Returns:

The JPQLQueryProblem describing a problem
buildProblem
(Expression
The Expression that is either not following the BNF grammar or that has semantic problems
expression
,
int
The position where the problem was encountered
startPosition
,
int
The position where the problem ends, inclusively
endPosition
,
String
The key used to retrieve the localized message describing the problem
messageKey
,
String...
The list of arguments that can be used to format the localized description of the problem
messageArguments
)

Creates a new validation problem that was found in the given Expression.

protected AbstractValidator.SubqueryVisitor

Returns:

A new SubqueryVisitor
buildSubqueryVisitor
()

Creates the visitor that checks if the visited expression is a subquery or not..

public void
dispose()

Disposes this visitor.

protected AbstractValidator.BypassChildCollectionExpressionVisitor
protected AbstractValidator.BypassParentSubExpressionVisitor
protected List<Expression>

Returns:

A list containing either the given Expression or the children of CollectionExpression
getChildren
(Expression
The Expression to visit
expression
)

Returns a list containing either the given Expression if it's not a CollectionExpression or the children of the given CollectionExpression.

protected AbstractValidator.ChildrenCollectorVisitor
protected ExpressionRegistry

Returns:

The registry containing the information related to the JPQL grammar
getExpressionRegistry
()

Returns the registry containing the JPQLQueryBNFs and the ExpressionFactories that are used to properly parse a JPQL query.

protected AbstractValidator.JPQLQueryBNFValidator
protected abstract JPQLGrammar

Returns:

The JPQLGrammar that was used to parse the JPQL query
getGrammar
()

Returns the JPQLGrammar that defines how the JPQL query was parsed.

protected JPAVersion

Returns:

The version of the Java Persistence being used
getJPAVersion
()

Returns the version of the Java Persistence this entity for which it was defined.

protected AbstractValidator.JPQLQueryBNFValidator

Returns:

A JPQLQueryBNFValidator that can determine if an Expression follows the given BNF
getJPQLQueryBNFValidator
(JPQLQueryBNF
The BNF used to determine the validity of an Expression
queryBNF
)

Returns the JPQLQueryBNFValidator that can be used to validate an Expression by making sure its BNF is part of the given BNF.

protected AbstractValidator.JPQLQueryBNFValidator

Returns:

A JPQLQueryBNFValidator that can determine if an Expression follows the given BNF
getJPQLQueryBNFValidator
(String
The BNF used to determine the validity of an Expression
queryBNF
)

Returns the JPQLQueryBNFValidator that can be used to validate an Expression by making sure its BNF is part of the given BNF.

protected LiteralVisitor

Returns:

A LiteralVisitor
getLiteralVisitor
()

Returns the visitor that can retrieve some information about various literal.

protected AbstractValidator.NestedArrayVisitor
getNestedArrayVisitor()

Returns the visitor that can determine if an Expression represents a nested array.

protected AbstractValidator.OwningClauseVisitor
getOwningClauseVisitor()

Returns the visitor that traverses the parent hierarchy of any Expression and stops at the first Expression that is a clause.

protected AbstractValidator.OwningStatementVisitor
getOwningStatementVisitor()

Returns the visitor that traverses the parent hierarchy of any Expression and stops at the first Expression that is a statement.

protected String

Returns:

The name of the persistence provider, null should never be returned
getProvider
()

Returns the persistence provider name.

protected String

Returns:

The version of the persistence provider, if one is extending the default JPQL grammar defined in the Java Persistence specification, otherwise returns an empty string
getProviderVersion
()

Returns the version of the persistence provider.

protected JPQLQueryBNF

Returns:

The JPQLQueryBNF representing a section of the grammar
getQueryBNF
(String
The unique identifier of the JPQLQueryBNF to retrieve
queryBNFId
)

Retrieves the BNF object that was registered for the given unique identifier.

protected AbstractValidator.SubqueryVisitor
getSubqueryVisitor()

Returns the visitor that checks if the visited expression is a subquery or not.

protected void
initialize()

Initializes this validator.

protected boolean

Returns:

true if the given Expression is a nested array; false otherwise
isNestedArray
(Expression
The Expression to check its size
expression
)

Determines whether the given Expression represents a nested array or not.

protected boolean

Returns:

true if the given Expression is a subquery; false otherwise
isSubquery
(Expression
The Expression to check its type
expression
)

Determines whether the given Expression is a subquery.

protected boolean

Returns:

true if the Expression's JPQLQueryBNF is either the JPQLQueryBNF or a child of it; false otherwise
isValid
(Expression
The Expression to validate based on the query BNF
expression
,
JPQLQueryBNF
The JPQLQueryBNF that determines if the given Expression is valid
queryBNF
)

Determines whether the given Expression is valid by checking its JPQLQueryBNF with the given JPQLQueryBNF.

protected boolean

Returns:

true if the Expression's JPQLQueryBNF is either the JPQLQueryBNF or a child of it; false otherwise
isValid
(Expression
The Expression to validate based on the query BNF
expression
,
String
The unique identifier of the JPQLQueryBNF that determines if the given Expression is valid
queryBNFId
)

Determines whether the given Expression is valid by checking its JPQLQueryBNF with the JPQLQueryBNF associated with the given unique identifier.

protected boolean

Returns:

true if the Expression's JPQLQueryBNF is either the JPQLQueryBNF or a child of it; false otherwise
isValid
(Expression
The Expression to validate based on the query BNF
expression
,
String...
The unique identifier of the JPQLQueryBNF that determines if the given Expression is valid
queryBNFIds
)

Determines whether the given Expression is valid by checking its JPQLQueryBNF with the list of JPQLQueryBNF associated with the given unique identifiers.

protected boolean

Returns:

true if the Expression part is a child of the given query BNF; false otherwise
isValidWithChildCollectionBypass
(Expression
The Expression to validate based on the query BNF
expression
,
String
The unique identifier of the JPQLQueryBNF that looks up the JPQLQueryBNFValidator
queryBNF
)

Determines whether the given Expression part is an expression of the given query BNF.

protected boolean

Returns:

true if the given Expression is part of a subquery; false if it's part of the top-level query
isWithinSubquery
(Expression
The Expression to start scanning its location
expression
)

Determines whether the given Expression is part of a subquery.

protected boolean

Returns:

true if the given Expression is part of the top-level query; false if it's part of a subquery
isWithinTopLevelQuery
(Expression
The Expression to start scanning its location
expression
)

Determines whether the given Expression is part of the top-level query.

protected int

Returns:

The length of the string representation of the given Expression
length
(Expression
The Expression to retrieve the length of its string
expression
)

Returns the length of the string representation of the given Expression.

protected String

Returns:

A value from the given Expression or an empty string if the given Expression and the LiteralType do not match
literal
(Expression
The Expression to visit
expression
,
LiteralType
The LiteralType helps to determine what to retrieve from the visited Expression
type
)

Retrieves the "literal" from the given Expression.

protected int

Returns:

The number of items in the array or -1 if the Expression is not a nested array
nestedArraySize
(Expression
The Expression to visit
expression
)

Returns the number of items in the nested array if the given Expression represents one.

protected int

Returns:

The length of the string representation of what comes before the given expression
position
(Expression
The expression to determine its position within the parsed tree
expression
)

Calculates the position of the given expression by calculating the length of what is before.

public final int

Returns:

The current number of problems
problemsSize
()

Returns the current number of problems that were registered during validation.

public void
setProblems(Collection<JPQLQueryProblem>
A non-null collection that will be used to store the problems if any was found
problems
)

Sets the collection that will be used to store problems this validator will find in the JPQL query.

protected void
Inherited from org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor:
visitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisit