Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.jpa.internal.jpql
Class AbstractValidator

java.lang.Object
  extended by org.eclipse.persistence.jpa.internal.jpql.parser.AnonymousExpressionVisitor
      extended by org.eclipse.persistence.jpa.internal.jpql.AbstractVisitor
          extended by org.eclipse.persistence.jpa.internal.jpql.AbstractValidator

All Implemented Interfaces:
ExpressionVisitor
Direct Known Subclasses:
GrammarValidator, SemanticValidator

public abstract class AbstractValidator
extends AbstractVisitor

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

Since:
2.3
Version:
2.3
Author:
Pascal Filion
See Also:
GrammarValidator, SemanticValidator

Nested Class Summary
protected static class AbstractValidator.BypassChildCollectionExpressionVisitor
          This visitor is responsible to traverse the children of a CollectionExpression in order to properly validate the Expression.
protected static class AbstractValidator.BypassParentSubExpressionVisitor
          This visitor is responsible to traverse the parent hierarchy and to skip SubExpression if it's a parent.
private static class AbstractValidator.ChildrenCollectorVisitor
          This visitor gathers the children of a CollectionExpression or a single visited Expression.
protected static class AbstractValidator.ExpressionValidator
          This visitor validates any Expression by checking its BNF against some BNFs.
protected static class AbstractValidator.OwningClauseVisitor
          This visitor retrieves the clause owning the visited Expression.

 

Field Summary
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  AbstractValidator.OwningClauseVisitor owningClauseVisitor
          This visitor is responsible to traverse the parent hierarchy and to retrieve the owning clause of the Expression being visited.
private  java.util.List<JPQLQueryProblem> problems
          The list of QueryProblems describing grammatical and semantic issues found in the query.
private  java.util.Map<java.lang.String,AbstractValidator.ExpressionValidator> validators
          The ExpressionValidators mapped by the BNF IDs.

 

Fields inherited from class org.eclipse.persistence.jpa.internal.jpql.AbstractVisitor
queryContext

 

Constructor Summary
protected AbstractValidator(JPQLQueryContext queryContext)
          Creates a new AbstractValidator.

 

Method Summary
protected  void addProblem(Expression expression, int startIndex, int endIndex, java.lang.String messageKey, java.lang.String... messageArguments)
          Adds a new validation problem that was found in the given Expression.
protected  void addProblem(Expression expression, java.lang.String messageKey)
          Adds a new validation problem that was found in the given Expression.
protected  void addProblem(Expression expression, java.lang.String messageKey, java.lang.String... arguments)
          Adds a new validation problem that was found in the given Expression.
protected  AbstractValidator.ExpressionValidator buildExpressionValidator(java.lang.String... queryBNFs)
           
private  JPQLQueryProblem buildProblem(Expression expression, int startIndex, int endIndex, java.lang.String messageKey, java.lang.String... messageArguments)
          Creates a new validation problem that was found in the given Expression.
protected  AbstractValidator.BypassChildCollectionExpressionVisitor bypassChildCollectionExpressionVisitor()
           
protected  AbstractValidator.BypassParentSubExpressionVisitor bypassParentSubExpressionVisitor()
           
private  int calculatePosition(Expression expression, int position)
           
protected  java.util.Collection<Expression> children(Expression expression)
          Retrieves the children of the given Expression.
private  AbstractValidator.ChildrenCollectorVisitor childrenCollectorVisitor()
           
 void dispose()
          Disposes of the internal data.
protected  AbstractValidator.ExpressionValidator expressionValidator(java.lang.String queryBNF)
           
protected  void initialize()
          Initializes this class.
protected  AbstractValidator.ExpressionValidator internalOrderByItemBNFValidator(IPlatform platform)
           
protected  boolean isOwnedByConditionalClause(Expression expression)
          Determines whether the given Expression is a child of a conditional clause, i.e.
protected  boolean isOwnedByFromClause(Expression expression)
          Determines whether the given Expression is a child of the FROM clause of the top-level query.
protected  boolean isOwnedBySubFromClause(Expression expression)
          Determines whether the given Expression is a child of the FROM clause of a subquery.
protected  boolean isValid(Expression expression, java.lang.String queryBNF)
          Determines whether the given Expression part is an expression of the given query BNF.
protected  boolean isValidJavaIdentifier(java.lang.String variable)
          Determines whether the given variable is a valid Java identifier, which means it follows the Java specification.
protected  boolean isValidWithChildCollectionBypass(Expression expression, java.lang.String queryBNF)
          Determines whether the given Expression part is an expression of the given query BNF.
protected  boolean isValidWithFindQueryBNF(AbstractExpression expression, java.lang.String queryBNF)
           
protected  boolean isValidWithParentSubExpressionBypass(Expression expression, java.lang.String queryBNF)
          Determines whether the given Expression part is an expression of the given query BNF.
protected  int length(Expression expression)
          Returns the length of the string representation of the given Expression.
protected  AbstractValidator.OwningClauseVisitor owningClauseVisitor()
          Returns the visitor that traverses the parent hierarchy of any Expression and stop at the first Expression that is a clause.
protected  int position(Expression expression)
          Calculates the position of the given expression by calculating the length of what is before.
 void setProblems(java.util.List<JPQLQueryProblem> problems)
          Sets the list that will be used to store problems this validator will find in the JPQL query.
protected  void visit(Expression expression)
          Blindly visit the given Expression.

 

Methods inherited from class org.eclipse.persistence.jpa.internal.jpql.AbstractVisitor
collectionExpression, embeddable, entity, getJPAVersion, getManagedType, getManagedType, getMapping, getProvider, getQuery, getQueryExpression, getResolver, getType, getType, getType, getTypeDeclaration, getTypeHelper, getTypeRepository, isEclipseLinkPlatform, isEmbeddable, isEntity, isJavaPlatform, isMappedSuperclass, isNull, mappedSuperclass

 

Methods inherited from class org.eclipse.persistence.jpa.internal.jpql.parser.AnonymousExpressionVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

bypassChildCollectionExpressionVisitor

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

bypassParentSubExpressionVisitor

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

childrenCollectorVisitor

private AbstractValidator.ChildrenCollectorVisitor childrenCollectorVisitor
This visitor gathers the children of a CollectionExpression or a single visited Expression.

owningClauseVisitor

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

problems

private java.util.List<JPQLQueryProblem> problems
The list of QueryProblems describing grammatical and semantic issues found in the query.

validators

private java.util.Map<java.lang.String,AbstractValidator.ExpressionValidator> validators
The ExpressionValidators mapped by the BNF IDs.

Constructor Detail

AbstractValidator

protected AbstractValidator(JPQLQueryContext queryContext)
Creates a new AbstractValidator.
Parameters:
queryContext - The context used to query information about the query

Method Detail

addProblem

protected final void addProblem(Expression expression,
                                int startIndex,
                                int endIndex,
                                java.lang.String messageKey,
                                java.lang.String... messageArguments)
Adds a new validation problem that was found in the given Expression.
Parameters:
expression - The Expression that is either not following the BNF grammar or that has semantic problems
startIndex - The position where the problem was encountered
endIndex - The position where the problem ends, inclusively
messageKey - The key used to retrieve the localized message describing the problem
messageArguments - The list of arguments that can be used to format the localized description of the problem

addProblem

protected final void addProblem(Expression expression,
                                java.lang.String messageKey)
Adds a new validation problem that was found in the given Expression. The start index is the position of the given Expression within the JPQL query and the end index is the end position of the Expression within the JPQL query.
Parameters:
expression - The Expression that is either not following the BNF grammar or that has semantic problems
messageKey - The key used to retrieve the localized message describing the problem

addProblem

protected final void addProblem(Expression expression,
                                java.lang.String messageKey,
                                java.lang.String... arguments)
Adds a new validation problem that was found in the given Expression. The start index is the position of the given Expression within the JPQL query and the end index is the end position of the Expression within the JPQL query.
Parameters:
expression - The Expression that is either not following the BNF grammar or that has semantic problems
messageKey - The key used to retrieve the localized message describing the problem
messageArguments - The list of arguments that can be used to format the localized description of the problem

buildExpressionValidator

protected final AbstractValidator.ExpressionValidator buildExpressionValidator(java.lang.String... queryBNFs)

buildProblem

private JPQLQueryProblem buildProblem(Expression expression,
                                      int startIndex,
                                      int endIndex,
                                      java.lang.String messageKey,
                                      java.lang.String... messageArguments)
Creates a new validation problem that was found in the given Expression.
Parameters:
expression - The Expression that is either not following the BNF grammar or that has semantic problems
startIndex - The position where the problem was encountered
endIndex - The position where the problem ends, inclusively
messageKey - The key used to retrieve the localized message describing the problem
messageArguments - The list of arguments that can be used to format the localized description of the problem
Returns:
The QueryProblem describing a problem

bypassChildCollectionExpressionVisitor

protected final AbstractValidator.BypassChildCollectionExpressionVisitor bypassChildCollectionExpressionVisitor()

bypassParentSubExpressionVisitor

protected final AbstractValidator.BypassParentSubExpressionVisitor bypassParentSubExpressionVisitor()

calculatePosition

private int calculatePosition(Expression expression,
                              int position)

children

protected final java.util.Collection<Expression> children(Expression expression)
Retrieves the children of the given Expression. If it only has one child and it's a CollectionExpression, then its children will be added to the collection.
Parameters:
expression - The Expression to visit
Returns:
The children of the given Expression

childrenCollectorVisitor

private AbstractValidator.ChildrenCollectorVisitor childrenCollectorVisitor()

dispose

public void dispose()
Disposes of the internal data.
Overrides:
dispose in class AbstractVisitor

expressionValidator

protected final AbstractValidator.ExpressionValidator expressionValidator(java.lang.String queryBNF)

initialize

protected void initialize()
Initializes this class.
Overrides:
initialize in class AbstractVisitor

internalOrderByItemBNFValidator

protected final AbstractValidator.ExpressionValidator internalOrderByItemBNFValidator(IPlatform platform)

isOwnedByConditionalClause

protected final boolean isOwnedByConditionalClause(Expression expression)
Determines whether the given Expression is a child of a conditional clause, i.e. either owned by the WHERE or HAVING clause.
Parameters:
expression - The Expression to visit its parent hierarchy up to the clause
Returns:
true if the first parent being a clause is the WHERE or HAVING clause; false otherwise

isOwnedByFromClause

protected final boolean isOwnedByFromClause(Expression expression)
Determines whether the given Expression is a child of the FROM clause of the top-level query.
Parameters:
expression - The Expression to visit its parent hierarchy up to the clause
Returns:
true if the first parent being a clause is the top-level FROM clause; false otherwise

isOwnedBySubFromClause

protected final boolean isOwnedBySubFromClause(Expression expression)
Determines whether the given Expression is a child of the FROM clause of a subquery.
Parameters:
expression - The Expression to visit its parent hierarchy up to the clause
Returns:
true if the first parent being a clause is the FROM clause of a subquery; false otherwise

isValid

protected final boolean isValid(Expression expression,
                                java.lang.String queryBNF)
Determines whether the given Expression part is an expression of the given query BNF.
Parameters:
expression - The Expression to validate based on the query BNF
Returns:
true if the Expression part is a child of the given query BNF; false otherwise

isValidJavaIdentifier

protected final boolean isValidJavaIdentifier(java.lang.String variable)
Determines whether the given variable is a valid Java identifier, which means it follows the Java specification. The first letter has to be a Java identifier start and the others have to be Java identifier parts.
Parameters:
variable - The variable to validate
Returns:
true if the given variable follows the Java identifier specification; false otherwise

isValidWithChildCollectionBypass

protected final boolean isValidWithChildCollectionBypass(Expression expression,
                                                         java.lang.String queryBNF)
Determines whether the given Expression part is an expression of the given query BNF. The CollectionExpression that may be the direct child of the given Expression will be bypassed.
Parameters:
expression - The Expression to validate based on the query BNF
Returns:
true if the Expression part is a child of the given query BNF; false otherwise

isValidWithFindQueryBNF

protected final boolean isValidWithFindQueryBNF(AbstractExpression expression,
                                                java.lang.String queryBNF)

isValidWithParentSubExpressionBypass

protected final boolean isValidWithParentSubExpressionBypass(Expression expression,
                                                             java.lang.String queryBNF)
Determines whether the given Expression part is an expression of the given query BNF. The parent SubExpression that may be the parent of the given Expression will be bypassed.
Parameters:
expression - The Expression to validate based on the query BNF
Returns:
true if the Expression part is a child of the given query BNF; false otherwise

length

protected final int length(Expression expression)
Returns the length of the string representation of the given Expression.
Parameters:
expression - The Expression to retrieve the length of its string
Returns:
The length of the string representation of the given Expression

owningClauseVisitor

protected final AbstractValidator.OwningClauseVisitor owningClauseVisitor()
Returns the visitor that traverses the parent hierarchy of any Expression and stop at the first Expression that is a clause.
Returns:
AbstractValidator.OwningClauseVisitor

position

protected final int position(Expression expression)
Calculates the position of the given expression by calculating the length of what is before.
Parameters:
expression - The expression to determine its position within the parsed tree
Returns:
The length of the string representation of what comes before the given expression

setProblems

public final void setProblems(java.util.List<JPQLQueryProblem> problems)
Sets the list that will be used to store problems this validator will find in the JPQL query.
Parameters:
problems - A non-null list that will be used to store the problems if any was found

visit

protected void visit(Expression expression)
Blindly visit the given Expression.
Specified by:
visit in class AbstractVisitor
Parameters:
expression - The Expression to visit

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.