|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor org.eclipse.persistence.jpa.jpql.AbstractValidator org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator org.eclipse.persistence.jpa.jpql.DefaultSemanticValidator
public class DefaultSemanticValidator
This validator is responsible to gather the problems found in a JPQL query by validating the content to make sure it is semantically valid. The grammar is not validated by this visitor.
For instance, the function AVG accepts a state field path. The property it represents has
to be of numeric type. AVG(e.name) is parsable but is not semantically valid because the
type of name is a string (the property signature is: "private String name
").
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.
DefaultGrammarValidator
Nested Class Summary | |
---|---|
protected class |
DefaultSemanticValidator.BooleanTypeValidator
This visitor validates expression that is a boolean literal to make sure the type is a Boolean. |
protected static class |
DefaultSemanticValidator.CollectionValuedPathExpressionVisitor
|
protected class |
DefaultSemanticValidator.NullValueVisitor
|
protected class |
DefaultSemanticValidator.NumericTypeValidator
This visitor validates expression that is a numeric literal to make sure the type is an instance of Number. |
protected class |
DefaultSemanticValidator.ResultVariableInOrderByVisitor
|
protected static class |
DefaultSemanticValidator.StateFieldPathExpressionVisitor
This visitor is meant to retrieve an DefaultSemanticValidator.StateFieldPathExpressionVisitor if the visited
Expression is that object. |
protected class |
DefaultSemanticValidator.StringTypeValidator
This visitor validates that the Expression is a string primary and to make sure the
type is String. |
protected class |
DefaultSemanticValidator.TypeValidator
The basic validator for validating the type of an Expression . |
protected class |
DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder
|
protected static class |
DefaultSemanticValidator.VirtualIdentificationVariableFinder
This visitor traverses the parsed tree and retrieves the IdentificationVariable
defined for a range variable declaration. |
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator |
---|
AbstractSemanticValidator.ComparingEntityTypeLiteralVisitor, AbstractSemanticValidator.ComparisonExpressionVisitor, AbstractSemanticValidator.FirstDeclarationVisitor, AbstractSemanticValidator.PathType, AbstractSemanticValidator.SubqueryFirstDeclarationVisitor, AbstractSemanticValidator.TopLevelFirstDeclarationVisitor |
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractValidator |
---|
AbstractValidator.BypassChildCollectionExpressionVisitor, AbstractValidator.BypassParentSubExpressionVisitor, AbstractValidator.ChildrenCollectorVisitor, AbstractValidator.JPQLQueryBNFValidator, AbstractValidator.OwningClauseVisitor, AbstractValidator.OwningStatementVisitor, AbstractValidator.SubqueryVisitor |
Field Summary | |
---|---|
protected DefaultSemanticValidator.NullValueVisitor |
nullValueVisitor
This validator determines whether the Expression visited represents
Expression.NULL . |
protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder |
updateClauseAbstractSchemaNameFinder
This finder is responsible to retrieve the abstract schema name from the UPDATE range declaration expression. |
protected java.util.Map<java.lang.Class<? extends DefaultSemanticValidator.TypeValidator>,DefaultSemanticValidator.TypeValidator> |
validators
The TypeVlidators mapped to their Java class. |
Fields inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator |
---|
collectionValuedPathExpressionVisitor, helper, registerIdentificationVariable, stateFieldPathExpressionVisitor, usedIdentificationVariables, virtualIdentificationVariableFinder |
Constructor Summary | |
---|---|
DefaultSemanticValidator(JPQLQueryContext queryContext)
Creates a new DefaultSemanticValidator . |
|
DefaultSemanticValidator(SemanticValidatorHelper helper)
Creates a new DefaultSemanticValidator . |
Method Summary | |
---|---|
protected boolean |
areTypesEquivalent(java.lang.Object[] typeDeclarations1,
java.lang.Object[] typeDeclarations2)
|
protected LiteralVisitor |
buildLiteralVisitor()
Creates the visitor that can retrieve some information about various literal. |
protected AbstractValidator.OwningClauseVisitor |
buildOwningClauseVisitor()
Creates the visitor that traverses the parent hierarchy of any Expression and stops at
the first Expression that is a clause. |
protected DefaultSemanticValidator.ResultVariableInOrderByVisitor |
buildResultVariableInOrderByVisitor()
|
protected AbstractSchemaName |
findAbstractSchemaName(UpdateItem expression)
|
protected DefaultSemanticValidator.NullValueVisitor |
getNullValueVisitor()
|
protected java.lang.Object |
getType(Expression expression)
|
protected ITypeHelper |
getTypeHelper()
|
protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder |
getUpdateClauseAbstractSchemaNameFinder()
|
protected DefaultSemanticValidator.TypeValidator |
getValidator(java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
|
protected void |
initialize()
Initializes this validator. |
protected boolean |
isBooleanType(Expression expression)
Determines whether the given Expression is of the correct type based on these rules:
The Expression returns a boolean value;
|
protected boolean |
isComparisonEquivalentType(Expression expression1,
Expression expression2)
|
protected boolean |
isEquivalentBetweenType(Expression expression1,
Expression expression2)
|
protected boolean |
isIntegralType(Expression expression)
Determines whether the given Expression is of the correct type based on these rules:
The Expression 's type is an integral type (long or integer). |
protected boolean |
isNullValue(Expression expression)
|
protected boolean |
isNumericType(Expression expression)
Determines whether the given Expression is of the correct type based on these rules:
The Expression returns a numeric value;
|
protected boolean |
isStringType(Expression expression)
Determines whether the given Expression is of the correct type based on these rules:
The Expression 's type is a string type. |
protected boolean |
isValid(Expression expression,
java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
Determines whether the given Expression is of the correct type by using the
DefaultSemanticValidator.BooleanTypeValidator . |
protected boolean |
isValidWithFindQueryBNF(AbstractExpression expression,
java.lang.String queryBNF)
|
protected AbstractSemanticValidator.PathType |
selectClausePathExpressionPathType()
Returns the type of path expression that is allowed in the SELECT clause. |
protected boolean |
validateAbsExpression(AbsExpression expression)
Validates the encapsulated expression of the given ABS expression. |
protected int |
validateArithmeticExpression(ArithmeticExpression expression,
java.lang.String leftExpressionWrongTypeMessageKey,
java.lang.String rightExpressionWrongTypeMessageKey)
Validates the type of the left and right expressions defined by the given ArithmeticExpression . |
protected boolean |
validateAvgFunction(AvgFunction expression)
Validates the encapsulated expression of the given AVG expression. |
protected int |
validateBetweenExpression(BetweenExpression expression)
Validates the given BetweenExpression . |
protected boolean |
validateBooleanType(Expression expression,
java.lang.String messageKey)
Determines whether the given Expression is of the correct type based on these rules:
The Expression returns a boolean value;
The Expression 's type is a boolean type. |
protected int |
validateCollectionMemberExpression(CollectionMemberExpression expression)
Validates the given CollectionMemberExpression . |
protected boolean |
validateComparisonExpression(ComparisonExpression expression)
Validates the left and right expressions of the given ComparisonExpression . |
protected boolean |
validateConcatExpression(ConcatExpression expression)
Validates the encapsulated expression of the given CONCAT expression. |
protected void |
validateConstructorExpression(ConstructorExpression expression)
Validates the given ConstructorExpression . |
protected void |
validateCountFunction(CountFunction expression)
Validates the given CountFunction . |
protected void |
validateEntryExpression(EntryExpression expression)
Validates the given EntryExpression . |
protected boolean |
validateIdentificationVariable(IdentificationVariable expression,
java.lang.String variable)
Validates the given identification variable. |
protected boolean |
validateIntegralType(Expression expression,
java.lang.String queryBNF,
java.lang.String messageKey)
Determines whether the given Expression is of the correct type based on these rules:
The Expression returns a integral value;
The Expression 's type is an integral type (long or integer). |
protected void |
validateKeyExpression(KeyExpression expression)
Validates the given KeyExpression . |
protected boolean |
validateLengthExpression(LengthExpression expression)
Validates the encapsulated expression of the given LENGTH expression. |
protected int |
validateLocateExpression(LocateExpression expression)
Validates the encapsulated expression of the given LOCATE expression. |
protected boolean |
validateLowerExpression(LowerExpression expression)
Validates the encapsulated expression of the given LOWER expression. |
protected void |
validateMapIdentificationVariable(EncapsulatedIdentificationVariableExpression expression)
|
protected int |
validateModExpression(ModExpression expression)
Validates the encapsulated expression of the given MOD expression. |
protected void |
validateNotExpression(NotExpression expression)
Validates the given NotExpression . |
protected void |
validateNullComparisonExpression(NullComparisonExpression expression)
Validates the given NullComparisonExpression . |
protected boolean |
validateNumericType(Expression expression,
java.lang.String messageKey)
Determines whether the given Expression is of the correct type based on these rules:
The Expression returns a numeric value;
The Expression 's type is an numeric type. |
protected boolean |
validateSqrtExpression(SqrtExpression expression)
Validates the encapsulated expression of the given SQRT expression. |
protected boolean |
validateStringType(Expression expression,
java.lang.String messageKey)
Determines whether the given Expression is of the correct type based on these rules:
The Expression returns a String value;
The Expression 's type is a String type. |
protected int |
validateSubstringExpression(SubstringExpression expression)
Validates the encapsulated expression of the given SUBSTRING expression. |
protected boolean |
validateSumFunction(SumFunction expression)
Validates the encapsulated expression of the given MOD expression. |
protected boolean |
validateUpdateItem(UpdateItem expression)
Validates the given UpdateItem by validating the traversability of the path
expression. |
protected void |
validateUpdateItemTypes(UpdateItem expression,
java.lang.Object type)
|
protected boolean |
validateUpperExpression(UpperExpression expression)
Validates the encapsulated expression of the given UPPER expression. |
protected void |
validateValueExpression(ValueExpression expression)
Validates the given ValueExpression . |
Methods inherited from class org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor |
---|
visit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DefaultSemanticValidator.NullValueVisitor nullValueVisitor
Expression
visited represents
Expression.NULL
.
protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder updateClauseAbstractSchemaNameFinder
protected java.util.Map<java.lang.Class<? extends DefaultSemanticValidator.TypeValidator>,DefaultSemanticValidator.TypeValidator> validators
TypeVlidators
mapped to their Java class. Those validators validate
any Expression
by making sure its type matches the desired type.
Constructor Detail |
---|
public DefaultSemanticValidator(JPQLQueryContext queryContext)
DefaultSemanticValidator
.
queryContext
- The context used to query information about the JPQL query
java.lang.NullPointerException
- The given JPQLQueryContext
cannot be null
public DefaultSemanticValidator(SemanticValidatorHelper helper)
DefaultSemanticValidator
.
helper
- The given helper allows the validator to access the JPA artifacts without using
Hermes SPI directly
java.lang.NullPointerException
- The given SemanticValidatorHelper
cannot be null
Method Detail |
---|
protected boolean areTypesEquivalent(java.lang.Object[] typeDeclarations1, java.lang.Object[] typeDeclarations2)
protected LiteralVisitor buildLiteralVisitor()
buildLiteralVisitor
in class AbstractValidator
LiteralVisitor
protected AbstractValidator.OwningClauseVisitor buildOwningClauseVisitor()
Expression
and stops at
the first Expression
that is a clause.
buildOwningClauseVisitor
in class AbstractValidator
AbstractValidator.OwningClauseVisitor
protected DefaultSemanticValidator.ResultVariableInOrderByVisitor buildResultVariableInOrderByVisitor()
protected AbstractSchemaName findAbstractSchemaName(UpdateItem expression)
protected DefaultSemanticValidator.NullValueVisitor getNullValueVisitor()
protected java.lang.Object getType(Expression expression)
protected ITypeHelper getTypeHelper()
protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder getUpdateClauseAbstractSchemaNameFinder()
protected DefaultSemanticValidator.TypeValidator getValidator(java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
protected void initialize()
initialize
in class AbstractSemanticValidator
protected boolean isBooleanType(Expression expression)
Expression
is of the correct type based on these rules:
Expression
returns a boolean value;
expression
- The Expression
to validate
true
if the given Expression
passes the checks; false
otherwiseprotected boolean isComparisonEquivalentType(Expression expression1, Expression expression2)
protected boolean isEquivalentBetweenType(Expression expression1, Expression expression2)
protected boolean isIntegralType(Expression expression)
Expression
is of the correct type based on these rules:
Expression
's type is an integral type (long or integer).
expression
- The Expression
to validate
true
if the given Expression
passes the checks; false
otherwiseprotected boolean isNullValue(Expression expression)
protected boolean isNumericType(Expression expression)
Expression
is of the correct type based on these rules:
Expression
returns a numeric value;
expression
- The Expression
to validate
true
if the given Expression
passes the checks; false
otherwiseprotected boolean isStringType(Expression expression)
Expression
is of the correct type based on these rules:
Expression
's type is a string type.
expression
- The Expression
to validate
true
if the given Expression
passes the checks; false
otherwiseprotected boolean isValid(Expression expression, java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
Expression
is of the correct type by using the
DefaultSemanticValidator.BooleanTypeValidator
.
expression
- The Expression
to validatevalidatorClass
- The Java class of the DefaultSemanticValidator.BooleanTypeValidator
that will determine if the
given Expression
has the right type
true
if the given Expression
passes the checks; false
otherwiseprotected boolean isValidWithFindQueryBNF(AbstractExpression expression, java.lang.String queryBNF)
protected AbstractSemanticValidator.PathType selectClausePathExpressionPathType()
SELECT
clause.
selectClausePathExpressionPathType
in class AbstractSemanticValidator
protected boolean validateAbsExpression(AbsExpression expression)
ABS
expression. The
test to perform is:
validateAbsExpression
in class AbstractSemanticValidator
expression
- The AbsExpression
to validate by validating its encapsulated
expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected int validateArithmeticExpression(ArithmeticExpression expression, java.lang.String leftExpressionWrongTypeMessageKey, java.lang.String rightExpressionWrongTypeMessageKey)
ArithmeticExpression
.
The test to perform is:
validateArithmeticExpression
in class AbstractSemanticValidator
expression
- The ArithmeticExpression
to validateleftExpressionWrongTypeMessageKey
- The key used to describe the left expression does not
have a valid typerightExpressionWrongTypeMessageKey
- The key used to describe the right expression does
not have a valid type
AbstractSemanticValidator.isValid(int, int)
can be used to
determine the validation status of an expression based on its positionprotected boolean validateAvgFunction(AvgFunction expression)
AVG
expression. The
test to perform is:
validateAvgFunction
in class AbstractSemanticValidator
expression
- The AvgFunction
to validate by validating its encapsulated expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected int validateBetweenExpression(BetweenExpression expression)
BetweenExpression
. The test to perform is:
validateBetweenExpression
in class AbstractSemanticValidator
expression
- The BetweenExpression
to validateprotected boolean validateBooleanType(Expression expression, java.lang.String messageKey)
Expression
is of the correct type based on these rules:
Expression
returns a boolean value;Expression
's type is a boolean type.
expression
- The Expression
to validatemessageKey
- The key used to retrieve the localized message describing the problemprotected int validateCollectionMemberExpression(CollectionMemberExpression expression)
CollectionMemberExpression
. Only the collection-valued path
expression is validated.
validateCollectionMemberExpression
in class AbstractSemanticValidator
expression
- The CollectionMemberExpression
to validate
AbstractSemanticValidator.isValid(int, int)
can be used to
determine the validation status of an expression based on its positionprotected boolean validateComparisonExpression(ComparisonExpression expression)
ComparisonExpression
. The tests
to perform are:
validateComparisonExpression
in class AbstractSemanticValidator
expression
- The ConcatExpression
to validate by validating its
left and right expressions
true
if the two expressions pass the rules defined by this method; false
otherwiseprotected boolean validateConcatExpression(ConcatExpression expression)
CONCAT
expression.
The tests to perform are:
validateConcatExpression
in class AbstractSemanticValidator
expression
- The ConcatExpression
to validate by validating its encapsulated expression
false
if the first encapsulated expression was validated and is invalid;
true
otherwiseprotected void validateConstructorExpression(ConstructorExpression expression)
ConstructorExpression
. The default behavior does not require to
semantically validate it.
validateConstructorExpression
in class AbstractSemanticValidator
expression
- The ConstructorExpression
to validateprotected void validateCountFunction(CountFunction expression)
CountFunction
. The default behavior does not require to
semantically validate it.
validateCountFunction
in class AbstractSemanticValidator
expression
- The CountFunction
to validateprotected void validateEntryExpression(EntryExpression expression)
EntryExpression
. The default behavior does not require to
semantically validate it.
validateEntryExpression
in class AbstractSemanticValidator
expression
- The EntryExpression
to validateprotected boolean validateIdentificationVariable(IdentificationVariable expression, java.lang.String variable)
validateIdentificationVariable
in class AbstractSemanticValidator
expression
- The IdentificationVariable
that is being visitedvariable
- The actual identification variable, which is never an empty string
true
if the given identification variable is valid; false
otherwiseprotected boolean validateIntegralType(Expression expression, java.lang.String queryBNF, java.lang.String messageKey)
Expression
is of the correct type based on these rules:
Expression
returns a integral value;Expression
's type is an integral type (long or integer).
expression
- The Expression
to validatequeryBNF
- The unique identifier of the query BNF used to validate the typemessageKey
- The key used to retrieve the localized message describing the problem
false
if the given expression was validated and is invalid;
true
otherwiseprotected void validateKeyExpression(KeyExpression expression)
KeyExpression
. The default behavior does not require to
semantically validate it.
validateKeyExpression
in class AbstractSemanticValidator
expression
- The KeyExpression
to validateprotected boolean validateLengthExpression(LengthExpression expression)
LENGTH
expression. The
test to perform is:
validateLengthExpression
in class AbstractSemanticValidator
expression
- The LengthExpression
to validate by validating its encapsulated expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected int validateLocateExpression(LocateExpression expression)
LOCATE
expression. The
test to perform is:
validateLocateExpression
in class AbstractSemanticValidator
expression
- The LocateExpression
to validate by validating its encapsulated expression
AbstractSemanticValidator.isValid(int, int)
can be used to
determine the validation status of an expression based on its positionprotected boolean validateLowerExpression(LowerExpression expression)
LOWER
expression. The
test to perform is:
validateLowerExpression
in class AbstractSemanticValidator
expression
- The LowerExpression
to validate by validating its encapsulated expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected void validateMapIdentificationVariable(EncapsulatedIdentificationVariableExpression expression)
protected int validateModExpression(ModExpression expression)
MOD
expression. The
test to perform is:
validateModExpression
in class AbstractSemanticValidator
expression
- The ModExpression
to validate by validating its encapsulated expression
AbstractSemanticValidator.isValid(int, int)
can be used to
determine the validation status of an expression based on its positionprotected void validateNotExpression(NotExpression expression)
NotExpression
. The default behavior does not require to
semantically validate it.
validateNotExpression
in class AbstractSemanticValidator
expression
- The NotExpression
to validateprotected void validateNullComparisonExpression(NullComparisonExpression expression)
NullComparisonExpression
. The default behavior does not require to
semantically validate it.
validateNullComparisonExpression
in class AbstractSemanticValidator
expression
- The NullComparisonExpression
to validateprotected boolean validateNumericType(Expression expression, java.lang.String messageKey)
Expression
is of the correct type based on these rules:
Expression
returns a numeric value;Expression
's type is an numeric type.
expression
- The Expression
to validatemessageKey
- The key used to retrieve the localized message describing the problem
false
if the given expression was validated and is invalid;
true
otherwiseprotected boolean validateSqrtExpression(SqrtExpression expression)
SQRT
expression. The
test to perform is:
validateSqrtExpression
in class AbstractSemanticValidator
expression
- The SqrtExpression
to validate by validating its encapsulated expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected boolean validateStringType(Expression expression, java.lang.String messageKey)
Expression
is of the correct type based on these rules:
Expression
returns a String value;Expression
's type is a String type.
expression
- The Expression
to validatemessageKey
- The key used to retrieve the localized message describing the problem
false
if the given expression was validated and is invalid;
true
otherwiseprotected int validateSubstringExpression(SubstringExpression expression)
SUBSTRING
expression.
The test to perform is:
validateSubstringExpression
in class AbstractSemanticValidator
expression
- The SubstringExpression
to validate by validating its encapsulated expression
AbstractSemanticValidator.isValid(int, int)
can be used to
determine the validation status of an expression based on its positionprotected boolean validateSumFunction(SumFunction expression)
MOD
expression. The
test to perform is:
validateSumFunction
in class AbstractSemanticValidator
expression
- The ModExpression
to validate by validating its encapsulated expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected boolean validateUpdateItem(UpdateItem expression)
UpdateItem
by validating the traversability of the path
expression. The path expression is valid if it follows one of the following rules:
validateUpdateItem
in class AbstractSemanticValidator
expression
- UpdateItem
to validate its path expression
true
if the path expression is valid; false
otherwiseprotected void validateUpdateItemTypes(UpdateItem expression, java.lang.Object type)
protected boolean validateUpperExpression(UpperExpression expression)
UPPER
expression. The
test to perform is:
validateUpperExpression
in class AbstractSemanticValidator
expression
- The UpperExpression
to validate by validating its encapsulated expression
false
if the encapsulated expression was validated and is invalid;
true
otherwiseprotected void validateValueExpression(ValueExpression expression)
ValueExpression
. The default behavior does not require to
semantically validate it.
validateValueExpression
in class AbstractSemanticValidator
expression
- The ValueExpression
to validate
|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |