Class DefaultSemanticValidator
- 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.tools.DefaultSemanticValidator
-
- All Implemented Interfaces:
ExpressionVisitor
public class DefaultSemanticValidator extends AbstractSemanticValidator
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.
- Version:
- 2.5
- See Also:
DefaultGrammarValidator
- Author:
- Pascal Filion
- Since:
- 2.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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.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 static class
DefaultSemanticValidator.ResultVariableInOrderByVisitor
protected class
DefaultSemanticValidator.StringTypeValidator
This visitor validates that theExpression
is a string primary and to make sure the type is String.protected class
DefaultSemanticValidator.TypeValidator
The basic validator for validating the type of anExpression
.protected static class
DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder
-
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
AbstractSemanticValidator.CollectionValuedPathExpressionVisitor, AbstractSemanticValidator.ComparingEntityTypeLiteralVisitor, AbstractSemanticValidator.ComparisonExpressionVisitor, AbstractSemanticValidator.FirstDeclarationVisitor, AbstractSemanticValidator.InItemsVisitor, AbstractSemanticValidator.PathType, AbstractSemanticValidator.StateFieldPathExpressionVisitor, 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.NestedArrayVisitor, AbstractValidator.OwningClauseVisitor, AbstractValidator.OwningStatementVisitor, AbstractValidator.SubqueryVisitor
-
-
Field Summary
Fields Modifier and Type Field Description protected DefaultSemanticValidator.NullValueVisitor
nullValueVisitor
This validator determines whether theExpression
visited representsExpression.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
TheTypeVlidators
mapped to their Java class.-
Fields inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
collectionValuedPathExpressionVisitor, helper, registerIdentificationVariable, stateFieldPathExpressionVisitor, usedIdentificationVariables, virtualIdentificationVariableFinder
-
-
Constructor Summary
Constructors Constructor Description DefaultSemanticValidator(SemanticValidatorHelper helper)
Creates a newDefaultSemanticValidator
.DefaultSemanticValidator(JPQLQueryContext queryContext)
Creates a newDefaultSemanticValidator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 anyExpression
and stops at the firstExpression
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 givenExpression
is of the correct type based on these rules: TheExpression
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 givenExpression
is of the correct type based on these rules: TheExpression
's type is an integral type (long or integer).protected boolean
isNullValue(Expression expression)
protected boolean
isNumericType(Expression expression)
Determines whether the givenExpression
is of the correct type based on these rules: TheExpression
returns a numeric value;protected boolean
isStringType(Expression expression)
Determines whether the givenExpression
is of the correct type based on these rules: TheExpression
's type is a string type.protected boolean
isValid(Expression expression, java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
Determines whether the givenExpression
is of the correct type by using theDefaultSemanticValidator.TypeValidator
.protected boolean
isValidWithFindQueryBNF(AbstractExpression expression, java.lang.String queryBNF)
protected AbstractSemanticValidator.PathType
selectClausePathExpressionPathType()
Returns the type of path expression that is allowed in theSELECT
clause.protected boolean
validateAbsExpression(AbsExpression expression)
Validates the encapsulated expression of the givenABS
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 givenArithmeticExpression
.protected boolean
validateAvgFunction(AvgFunction expression)
Validates the encapsulated expression of the givenAVG
expression.protected int
validateBetweenExpression(BetweenExpression expression)
Validates the givenBetweenExpression
.protected boolean
validateBooleanType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpression
is of the correct type based on these rules: TheExpression
returns a boolean value; TheExpression
's type is a boolean type.protected int
validateCollectionMemberExpression(CollectionMemberExpression expression)
Validates the givenCollectionMemberExpression
.protected boolean
validateComparisonExpression(ComparisonExpression expression)
Validates the left and right expressions of the givenComparisonExpression
.protected boolean
validateConcatExpression(ConcatExpression expression)
Validates the encapsulated expression of the givenCONCAT
expression.protected void
validateConstructorExpression(ConstructorExpression expression)
Validates the givenConstructorExpression
.protected void
validateCountFunction(CountFunction expression)
Validates the givenCountFunction
.protected void
validateEntryExpression(EntryExpression expression)
Validates the givenEntryExpression
.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 givenExpression
is of the correct type based on these rules: TheExpression
returns a integral value; TheExpression
's type is an integral type (long or integer).protected void
validateKeyExpression(KeyExpression expression)
Validates the givenKeyExpression
.protected boolean
validateLengthExpression(LengthExpression expression)
Validates the encapsulated expression of the givenLENGTH
expression.protected int
validateLocateExpression(LocateExpression expression)
Validates the encapsulated expression of the givenLOCATE
expression.protected boolean
validateLowerExpression(LowerExpression expression)
Validates the encapsulated expression of the givenLOWER
expression.protected void
validateMapIdentificationVariable(EncapsulatedIdentificationVariableExpression expression)
protected int
validateModExpression(ModExpression expression)
Validates the encapsulated expression of the givenMOD
expression.protected void
validateNotExpression(NotExpression expression)
Validates the givenNotExpression
.protected void
validateNullComparisonExpression(NullComparisonExpression expression)
Validates the givenNullComparisonExpression
.protected boolean
validateNumericType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpression
is of the correct type based on these rules: TheExpression
returns a numeric value; TheExpression
's type is an numeric type.protected boolean
validateSqrtExpression(SqrtExpression expression)
Validates the encapsulated expression of the givenSQRT
expression.protected boolean
validateStringType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpression
is of the correct type based on these rules: TheExpression
returns a String value; TheExpression
's type is a String type.protected int
validateSubstringExpression(SubstringExpression expression)
Validates the encapsulated expression of the givenSUBSTRING
expression.protected boolean
validateSumFunction(SumFunction expression)
Validates the encapsulated expression of the givenMOD
expression.protected boolean
validateUpdateItem(UpdateItem expression)
Validates the givenUpdateItem
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 givenUPPER
expression.protected void
validateValueExpression(ValueExpression expression)
Validates the givenValueExpression
.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
buildComparingEntityTypeLiteralVisitor, buildInItemsVisitor, buildSubqueryFirstDeclarationVisitor, buildTopLevelFirstDeclarationVisitor, dispose, findVirtualIdentificationVariable, getCollectionValuedPathExpression, getCollectionValuedPathExpressionVisitor, getComparingEntityTypeLiteralVisitor, getComparisonExpressionVisitor, getGrammar, getInItemsVisitor, getStateFieldPathExpression, getStateFieldPathExpressionVisitor, getVirtualIdentificationVariableFinder, isComparingEntityTypeLiteral, isIdentificationVariableDeclaredAfter, isIdentificationVariableValidInComparison, isOrderComparison, isValid, subqueryFirstDeclarationVisitor, topLevelFirstDeclarationVisitor, updateStatus, validateAbstractFromClause, validateAbstractSchemaName, validateAdditionExpression, validateAllOrAnyExpression, validateAndExpression, validateArithmeticExpression, validateCaseExpression, validateCoalesceExpression, validateCollectionMemberDeclaration, validateCollectionValuedPathExpression, validateDateTime, validateDeleteClause, validateDeleteStatement, validateDivisionExpression, validateEntityTypeLiteral, validateExistsExpression, validateFirstDeclaration, validateFromClause, validateFunctionExpression, validateFunctionPathExpression, validateFunctionPathExpression, validateGroupByClause, validateHavingClause, validateIdentificationVariable, validateIdentificationVariableDeclaration, validateIdentificationVariables, validateIndexExpression, validateInExpression, validateJoin, validateJoinCollectionValuedPathExpression, validateJoinsIdentificationVariable, validateLikeExpression, validateMaxFunction, validateMinFunction, validateMultiplicationExpression, validateNullIfExpression, validateObjectExpression, validateOnClause, validateOrderByClause, validateOrderByItem, validateOrExpression, validateRangeVariableDeclaration, validateRangeVariableDeclarationRootObject, validateResultVariable, validateSelectClause, validateSelectStatement, validateSimpleFromClause, validateSimpleSelectClause, validateSimpleSelectStatement, validateSizeExpression, validateStateFieldPathExpression, validateSubtractionExpression, validateThirdPartyStateFieldPathExpression, validateTreatExpression, validateTrimExpression, validateTypeExpression, validateUpdateClause, validateUpdateStatement, validateWhenClause, validateWhereClause, validPathExpressionTypeForCountFunction, validPathExpressionTypeForInExpression, validPathExpressionTypeForInItem, validPathExpressionTypeForStringExpression, 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 org.eclipse.persistence.jpa.jpql.AbstractValidator
addProblem, addProblem, addProblem, addProblem, buildChildrenCollector, buildNestedArrayVisitor, buildOwningStatementVisitor, buildProblem, buildSubqueryVisitor, getBypassChildCollectionExpressionVisitor, getBypassParentSubExpressionVisitor, getChildren, getChildrenCollectorVisitor, getExpressionRegistry, getExpressionValidator, getJPAVersion, getJPQLQueryBNFValidator, getJPQLQueryBNFValidator, getLiteralVisitor, getNestedArrayVisitor, getOwningClauseVisitor, getOwningStatementVisitor, getProvider, getProviderVersion, getQueryBNF, getSubqueryVisitor, isNestedArray, isSubquery, isValid, isValid, isValid, isValidWithChildCollectionBypass, isWithinSubquery, isWithinTopLevelQuery, length, literal, nestedArraySize, position, problemsSize, setProblems, visit
-
-
-
-
Field Detail
-
nullValueVisitor
protected DefaultSemanticValidator.NullValueVisitor nullValueVisitor
This validator determines whether theExpression
visited representsExpression.NULL
.
-
updateClauseAbstractSchemaNameFinder
protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder updateClauseAbstractSchemaNameFinder
This finder is responsible to retrieve the abstract schema name from the UPDATE range declaration expression.
-
validators
protected java.util.Map<java.lang.Class<? extends DefaultSemanticValidator.TypeValidator>,DefaultSemanticValidator.TypeValidator> validators
TheTypeVlidators
mapped to their Java class. Those validators validate anyExpression
by making sure its type matches the desired type.
-
-
Constructor Detail
-
DefaultSemanticValidator
public DefaultSemanticValidator(JPQLQueryContext queryContext)
Creates a newDefaultSemanticValidator
.- Parameters:
queryContext
- The context used to query information about the JPQL query- Throws:
java.lang.NullPointerException
- The givenJPQLQueryContext
cannot benull
-
DefaultSemanticValidator
public DefaultSemanticValidator(SemanticValidatorHelper helper)
Creates a newDefaultSemanticValidator
.- Parameters:
helper
- The given helper allows the validator to access the JPA artifacts without using Hermes SPI directly- Throws:
java.lang.NullPointerException
- The givenSemanticValidatorHelper
cannot benull
- Since:
- 2.4
-
-
Method Detail
-
areTypesEquivalent
protected boolean areTypesEquivalent(java.lang.Object[] typeDeclarations1, java.lang.Object[] typeDeclarations2)
-
buildLiteralVisitor
protected LiteralVisitor buildLiteralVisitor()
Creates the visitor that can retrieve some information about various literal.- Specified by:
buildLiteralVisitor
in classAbstractValidator
- Returns:
- A new
LiteralVisitor
-
buildOwningClauseVisitor
protected AbstractValidator.OwningClauseVisitor buildOwningClauseVisitor()
Creates the visitor that traverses the parent hierarchy of anyExpression
and stops at the firstExpression
that is a clause.- Specified by:
buildOwningClauseVisitor
in classAbstractValidator
- Returns:
- A new
AbstractValidator.OwningClauseVisitor
-
buildResultVariableInOrderByVisitor
protected DefaultSemanticValidator.ResultVariableInOrderByVisitor buildResultVariableInOrderByVisitor()
-
findAbstractSchemaName
protected AbstractSchemaName findAbstractSchemaName(UpdateItem expression)
-
getNullValueVisitor
protected DefaultSemanticValidator.NullValueVisitor getNullValueVisitor()
-
getType
protected java.lang.Object getType(Expression expression)
-
getTypeHelper
protected ITypeHelper getTypeHelper()
-
getUpdateClauseAbstractSchemaNameFinder
protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinder getUpdateClauseAbstractSchemaNameFinder()
-
getValidator
protected DefaultSemanticValidator.TypeValidator getValidator(java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
-
initialize
protected void initialize()
Initializes this validator.- Overrides:
initialize
in classAbstractSemanticValidator
-
isBooleanType
protected boolean isBooleanType(Expression expression)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
returns a boolean value;
- Parameters:
expression
- TheExpression
to validate- Returns:
true
if the givenExpression
passes the checks;false
otherwise
- The
-
isComparisonEquivalentType
protected boolean isComparisonEquivalentType(Expression expression1, Expression expression2)
-
isEquivalentBetweenType
protected boolean isEquivalentBetweenType(Expression expression1, Expression expression2)
-
isIntegralType
protected boolean isIntegralType(Expression expression)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
's type is an integral type (long or integer).
- Parameters:
expression
- TheExpression
to validate- Returns:
true
if the givenExpression
passes the checks;false
otherwise
- The
-
isNullValue
protected boolean isNullValue(Expression expression)
-
isNumericType
protected boolean isNumericType(Expression expression)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
returns a numeric value;
- Parameters:
expression
- TheExpression
to validate- Returns:
true
if the givenExpression
passes the checks;false
otherwise
- The
-
isStringType
protected boolean isStringType(Expression expression)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
's type is a string type.
- Parameters:
expression
- TheExpression
to validate- Returns:
true
if the givenExpression
passes the checks;false
otherwise
- The
-
isValid
protected boolean isValid(Expression expression, java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
Determines whether the givenExpression
is of the correct type by using theDefaultSemanticValidator.TypeValidator
.- Parameters:
expression
- TheExpression
to validatevalidatorClass
- The Java class of theDefaultSemanticValidator.TypeValidator
that will determine if the givenExpression
has the right type- Returns:
true
if the givenExpression
passes the checks;false
otherwise
-
isValidWithFindQueryBNF
protected boolean isValidWithFindQueryBNF(AbstractExpression expression, java.lang.String queryBNF)
-
selectClausePathExpressionPathType
protected AbstractSemanticValidator.PathType selectClausePathExpressionPathType()
Returns the type of path expression that is allowed in theSELECT
clause.- Specified by:
selectClausePathExpressionPathType
in classAbstractSemanticValidator
- Returns:
- The type of path expressions allowed. The spec defines it as basic or object mapping only, i.e. collection-valued path expression is not allowed
-
validateAbsExpression
protected boolean validateAbsExpression(AbsExpression expression)
Validates the encapsulated expression of the givenABS
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateAbsExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheAbsExpression
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateArithmeticExpression
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 givenArithmeticExpression
. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateArithmeticExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheArithmeticExpression
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- Returns:
- A number indicating the validation result.
AbstractSemanticValidator.isValid(int, int)
can be used to determine the validation status of an expression based on its position
-
validateAvgFunction
protected boolean validateAvgFunction(AvgFunction expression)
Validates the encapsulated expression of the givenAVG
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateAvgFunction
in classAbstractSemanticValidator
- Parameters:
expression
- TheAvgFunction
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateBetweenExpression
protected int validateBetweenExpression(BetweenExpression expression)
Validates the givenBetweenExpression
. The test to perform is:- If the "first" expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- Overrides:
validateBetweenExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheBetweenExpression
to validate
-
validateBooleanType
protected boolean validateBooleanType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
returns a boolean value; - The
Expression
's type is a boolean type.
- Parameters:
expression
- TheExpression
to validatemessageKey
- The key used to retrieve the localized message describing the problem
- The
-
validateCollectionMemberExpression
protected int validateCollectionMemberExpression(CollectionMemberExpression expression)
Validates the givenCollectionMemberExpression
. Only the collection-valued path expression is validated.- Overrides:
validateCollectionMemberExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheCollectionMemberExpression
to validate- Returns:
- A number indicating the validation result.
AbstractSemanticValidator.isValid(int, int)
can be used to determine the validation status of an expression based on its position
-
validateComparisonExpression
protected boolean validateComparisonExpression(ComparisonExpression expression)
Validates the left and right expressions of the givenComparisonExpression
. The tests to perform are:- If the comparison operator is either '=' or '<>'. The expressions can only be
- Two identification variables;
- Two path expressions resolving to an association field;
- One can be a path expression resolving to a basic field and the other one has to resolve to a basic value.
- If the comparison operator is either '<', '<=', '>=', '>'. The expressions cannot be
- Two identification variables;
- Two path expressions resolving to an association field;
- Overrides:
validateComparisonExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheConcatExpression
to validate by validating its left and right expressions- Returns:
- The status of the comparison between the left and right expression:
true
if the two expressions pass the rules defined by this method;false
otherwise
- If the comparison operator is either '=' or '<>'. The expressions can only be
-
validateConcatExpression
protected boolean validateConcatExpression(ConcatExpression expression)
Validates the encapsulated expression of the givenCONCAT
expression. The tests to perform are:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateConcatExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheConcatExpression
to validate by validating its encapsulated expression- Returns:
false
if the first encapsulated expression was validated and is invalid;true
otherwise
-
validateConstructorExpression
protected void validateConstructorExpression(ConstructorExpression expression)
Validates the givenConstructorExpression
. The default behavior does not require to semantically validate it.- Overrides:
validateConstructorExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheConstructorExpression
to validate
-
validateCountFunction
protected void validateCountFunction(CountFunction expression)
Validates the givenCountFunction
. The default behavior does not require to semantically validate it.- Overrides:
validateCountFunction
in classAbstractSemanticValidator
- Parameters:
expression
- TheCountFunction
to validate
-
validateEntryExpression
protected void validateEntryExpression(EntryExpression expression)
Validates the givenEntryExpression
. The default behavior does not require to semantically validate it.- Overrides:
validateEntryExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheEntryExpression
to validate
-
validateIdentificationVariable
protected boolean validateIdentificationVariable(IdentificationVariable expression, java.lang.String variable)
Validates the given identification variable. The default behavior is to not validate it.- Overrides:
validateIdentificationVariable
in classAbstractSemanticValidator
- Parameters:
expression
- TheIdentificationVariable
that is being visitedvariable
- The actual identification variable, which is never an empty string- Returns:
true
if the given identification variable is valid;false
otherwise
-
validateIntegralType
protected boolean validateIntegralType(Expression expression, java.lang.String queryBNF, java.lang.String messageKey)
Determines whether the givenExpression
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).
- Parameters:
expression
- TheExpression
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- Returns:
false
if the given expression was validated and is invalid;true
otherwise
- The
-
validateKeyExpression
protected void validateKeyExpression(KeyExpression expression)
Validates the givenKeyExpression
. The default behavior does not require to semantically validate it.- Overrides:
validateKeyExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheKeyExpression
to validate
-
validateLengthExpression
protected boolean validateLengthExpression(LengthExpression expression)
Validates the encapsulated expression of the givenLENGTH
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateLengthExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheLengthExpression
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateLocateExpression
protected int validateLocateExpression(LocateExpression expression)
Validates the encapsulated expression of the givenLOCATE
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateLocateExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheLocateExpression
to validate by validating its encapsulated expression- Returns:
- A number indicating the validation result.
AbstractSemanticValidator.isValid(int, int)
can be used to determine the validation status of an expression based on its position
-
validateLowerExpression
protected boolean validateLowerExpression(LowerExpression expression)
Validates the encapsulated expression of the givenLOWER
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateLowerExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheLowerExpression
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateMapIdentificationVariable
protected void validateMapIdentificationVariable(EncapsulatedIdentificationVariableExpression expression)
-
validateModExpression
protected int validateModExpression(ModExpression expression)
Validates the encapsulated expression of the givenMOD
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateModExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheModExpression
to validate by validating its encapsulated expression- Returns:
- A number indicating the validation result.
AbstractSemanticValidator.isValid(int, int)
can be used to determine the validation status of an expression based on its position
-
validateNotExpression
protected void validateNotExpression(NotExpression expression)
Validates the givenNotExpression
. The default behavior does not require to semantically validate it.- Overrides:
validateNotExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheNotExpression
to validate
-
validateNullComparisonExpression
protected void validateNullComparisonExpression(NullComparisonExpression expression)
Validates the givenNullComparisonExpression
. The default behavior does not require to semantically validate it.- Overrides:
validateNullComparisonExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheNullComparisonExpression
to validate
-
validateNumericType
protected boolean validateNumericType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
returns a numeric value; - The
Expression
's type is an numeric type.
- Parameters:
expression
- TheExpression
to validatemessageKey
- The key used to retrieve the localized message describing the problem- Returns:
false
if the given expression was validated and is invalid;true
otherwise
- The
-
validateSqrtExpression
protected boolean validateSqrtExpression(SqrtExpression expression)
Validates the encapsulated expression of the givenSQRT
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateSqrtExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheSqrtExpression
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateStringType
protected boolean validateStringType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpression
is of the correct type based on these rules:- The
Expression
returns a String value; - The
Expression
's type is a String type.
- Parameters:
expression
- TheExpression
to validatemessageKey
- The key used to retrieve the localized message describing the problem- Returns:
false
if the given expression was validated and is invalid;true
otherwise
- The
-
validateSubstringExpression
protected int validateSubstringExpression(SubstringExpression expression)
Validates the encapsulated expression of the givenSUBSTRING
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateSubstringExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheSubstringExpression
to validate by validating its encapsulated expression- Returns:
- A number indicating the validation result.
AbstractSemanticValidator.isValid(int, int)
can be used to determine the validation status of an expression based on its position
-
validateSumFunction
protected boolean validateSumFunction(SumFunction expression)
Validates the encapsulated expression of the givenMOD
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateSumFunction
in classAbstractSemanticValidator
- Parameters:
expression
- TheModExpression
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateUpdateItem
protected boolean validateUpdateItem(UpdateItem expression)
Validates the givenUpdateItem
by validating the traversability of the path expression. The path expression is valid if it follows one of the following rules:- The identification variable is omitted if it's not defined in the FROM clause;
- The last path is a state field;
- Only embedded field can be traversed.
- Overrides:
validateUpdateItem
in classAbstractSemanticValidator
- Parameters:
expression
-UpdateItem
to validate its path expression- Returns:
true
if the path expression is valid;false
otherwise
-
validateUpdateItemTypes
protected void validateUpdateItemTypes(UpdateItem expression, java.lang.Object type)
-
validateUpperExpression
protected boolean validateUpperExpression(UpperExpression expression)
Validates the encapsulated expression of the givenUPPER
expression. The test to perform is:- If the encapsulated expression is a path expression, validation makes sure it is a basic mapping, an association field is not allowed.
- If the encapsulated expression is not a path expression, validation will be redirected to that expression but the returned status will not be changed.
- Overrides:
validateUpperExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheUpperExpression
to validate by validating its encapsulated expression- Returns:
false
if the encapsulated expression was validated and is invalid;true
otherwise
-
validateValueExpression
protected void validateValueExpression(ValueExpression expression)
Validates the givenValueExpression
. The default behavior does not require to semantically validate it.- Overrides:
validateValueExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheValueExpression
to validate
-
-