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 classDefaultSemanticValidator.BooleanTypeValidatorThis visitor validates expression that is a boolean literal to make sure the type is a Boolean.protected static classDefaultSemanticValidator.NullValueVisitorprotected classDefaultSemanticValidator.NumericTypeValidatorThis visitor validates expression that is a numeric literal to make sure the type is an instance of Number.protected static classDefaultSemanticValidator.ResultVariableInOrderByVisitorprotected classDefaultSemanticValidator.StringTypeValidatorThis visitor validates that theExpressionis a string primary and to make sure the type is String.protected classDefaultSemanticValidator.TypeValidatorThe basic validator for validating the type of anExpression.protected static classDefaultSemanticValidator.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.NullValueVisitornullValueVisitorThis validator determines whether theExpressionvisited representsExpression.NULL.protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFinderupdateClauseAbstractSchemaNameFinderThis 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>validatorsTheTypeVlidatorsmapped 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 booleanareTypesEquivalent(java.lang.Object[] typeDeclarations1, java.lang.Object[] typeDeclarations2)protected LiteralVisitorbuildLiteralVisitor()Creates the visitor that can retrieve some information about various literal.protected AbstractValidator.OwningClauseVisitorbuildOwningClauseVisitor()Creates the visitor that traverses the parent hierarchy of anyExpressionand stops at the firstExpressionthat is a clause.protected DefaultSemanticValidator.ResultVariableInOrderByVisitorbuildResultVariableInOrderByVisitor()protected AbstractSchemaNamefindAbstractSchemaName(UpdateItem expression)protected DefaultSemanticValidator.NullValueVisitorgetNullValueVisitor()protected java.lang.ObjectgetType(Expression expression)protected ITypeHelpergetTypeHelper()protected DefaultSemanticValidator.UpdateClauseAbstractSchemaNameFindergetUpdateClauseAbstractSchemaNameFinder()protected DefaultSemanticValidator.TypeValidatorgetValidator(java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)protected voidinitialize()Initializes this validator.protected booleanisBooleanType(Expression expression)Determines whether the givenExpressionis of the correct type based on these rules: TheExpressionreturns a boolean value;protected booleanisComparisonEquivalentType(Expression expression1, Expression expression2)protected booleanisEquivalentBetweenType(Expression expression1, Expression expression2)protected booleanisIntegralType(Expression expression)Determines whether the givenExpressionis of the correct type based on these rules: TheExpression's type is an integral type (long or integer).protected booleanisNullValue(Expression expression)protected booleanisNumericType(Expression expression)Determines whether the givenExpressionis of the correct type based on these rules: TheExpressionreturns a numeric value;protected booleanisStringType(Expression expression)Determines whether the givenExpressionis of the correct type based on these rules: TheExpression's type is a string type.protected booleanisValid(Expression expression, java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)Determines whether the givenExpressionis of the correct type by using theDefaultSemanticValidator.TypeValidator.protected booleanisValidWithFindQueryBNF(AbstractExpression expression, java.lang.String queryBNF)protected AbstractSemanticValidator.PathTypeselectClausePathExpressionPathType()Returns the type of path expression that is allowed in theSELECTclause.protected booleanvalidateAbsExpression(AbsExpression expression)Validates the encapsulated expression of the givenABSexpression.protected intvalidateArithmeticExpression(ArithmeticExpression expression, java.lang.String leftExpressionWrongTypeMessageKey, java.lang.String rightExpressionWrongTypeMessageKey)Validates the type of the left and right expressions defined by the givenArithmeticExpression.protected booleanvalidateAvgFunction(AvgFunction expression)Validates the encapsulated expression of the givenAVGexpression.protected intvalidateBetweenExpression(BetweenExpression expression)Validates the givenBetweenExpression.protected booleanvalidateBooleanType(Expression expression, java.lang.String messageKey)Determines whether the givenExpressionis of the correct type based on these rules: TheExpressionreturns a boolean value; TheExpression's type is a boolean type.protected intvalidateCollectionMemberExpression(CollectionMemberExpression expression)Validates the givenCollectionMemberExpression.protected booleanvalidateComparisonExpression(ComparisonExpression expression)Validates the left and right expressions of the givenComparisonExpression.protected booleanvalidateConcatExpression(ConcatExpression expression)Validates the encapsulated expression of the givenCONCATexpression.protected voidvalidateConstructorExpression(ConstructorExpression expression)Validates the givenConstructorExpression.protected voidvalidateCountFunction(CountFunction expression)Validates the givenCountFunction.protected voidvalidateEntryExpression(EntryExpression expression)Validates the givenEntryExpression.protected booleanvalidateIdentificationVariable(IdentificationVariable expression, java.lang.String variable)Validates the given identification variable.protected booleanvalidateIntegralType(Expression expression, java.lang.String queryBNF, java.lang.String messageKey)Determines whether the givenExpressionis of the correct type based on these rules: TheExpressionreturns a integral value; TheExpression's type is an integral type (long or integer).protected voidvalidateKeyExpression(KeyExpression expression)Validates the givenKeyExpression.protected booleanvalidateLengthExpression(LengthExpression expression)Validates the encapsulated expression of the givenLENGTHexpression.protected intvalidateLocateExpression(LocateExpression expression)Validates the encapsulated expression of the givenLOCATEexpression.protected booleanvalidateLowerExpression(LowerExpression expression)Validates the encapsulated expression of the givenLOWERexpression.protected voidvalidateMapIdentificationVariable(EncapsulatedIdentificationVariableExpression expression)protected intvalidateModExpression(ModExpression expression)Validates the encapsulated expression of the givenMODexpression.protected voidvalidateNotExpression(NotExpression expression)Validates the givenNotExpression.protected voidvalidateNullComparisonExpression(NullComparisonExpression expression)Validates the givenNullComparisonExpression.protected booleanvalidateNumericType(Expression expression, java.lang.String messageKey)Determines whether the givenExpressionis of the correct type based on these rules: TheExpressionreturns a numeric value; TheExpression's type is an numeric type.protected booleanvalidateSqrtExpression(SqrtExpression expression)Validates the encapsulated expression of the givenSQRTexpression.protected booleanvalidateStringType(Expression expression, java.lang.String messageKey)Determines whether the givenExpressionis of the correct type based on these rules: TheExpressionreturns a String value; TheExpression's type is a String type.protected intvalidateSubstringExpression(SubstringExpression expression)Validates the encapsulated expression of the givenSUBSTRINGexpression.protected booleanvalidateSumFunction(SumFunction expression)Validates the encapsulated expression of the givenMODexpression.protected booleanvalidateUpdateItem(UpdateItem expression)Validates the givenUpdateItemby validating the traversability of the path expression.protected voidvalidateUpdateItemTypes(UpdateItem expression, java.lang.Object type)protected booleanvalidateUpperExpression(UpperExpression expression)Validates the encapsulated expression of the givenUPPERexpression.protected voidvalidateValueExpression(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 theExpressionvisited 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
TheTypeVlidatorsmapped to their Java class. Those validators validate anyExpressionby 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 givenJPQLQueryContextcannot 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 givenSemanticValidatorHelpercannot 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:
buildLiteralVisitorin classAbstractValidator- Returns:
- A new
LiteralVisitor
-
buildOwningClauseVisitor
protected AbstractValidator.OwningClauseVisitor buildOwningClauseVisitor()
Creates the visitor that traverses the parent hierarchy of anyExpressionand stops at the firstExpressionthat is a clause.- Specified by:
buildOwningClauseVisitorin 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:
initializein classAbstractSemanticValidator
-
isBooleanType
protected boolean isBooleanType(Expression expression)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expressionreturns a boolean value;
- Parameters:
expression- TheExpressionto validate- Returns:
trueif the givenExpressionpasses the checks;falseotherwise
- 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 givenExpressionis of the correct type based on these rules:- The
Expression's type is an integral type (long or integer).
- Parameters:
expression- TheExpressionto validate- Returns:
trueif the givenExpressionpasses the checks;falseotherwise
- The
-
isNullValue
protected boolean isNullValue(Expression expression)
-
isNumericType
protected boolean isNumericType(Expression expression)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expressionreturns a numeric value;
- Parameters:
expression- TheExpressionto validate- Returns:
trueif the givenExpressionpasses the checks;falseotherwise
- The
-
isStringType
protected boolean isStringType(Expression expression)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expression's type is a string type.
- Parameters:
expression- TheExpressionto validate- Returns:
trueif the givenExpressionpasses the checks;falseotherwise
- The
-
isValid
protected boolean isValid(Expression expression, java.lang.Class<? extends DefaultSemanticValidator.TypeValidator> validatorClass)
Determines whether the givenExpressionis of the correct type by using theDefaultSemanticValidator.TypeValidator.- Parameters:
expression- TheExpressionto validatevalidatorClass- The Java class of theDefaultSemanticValidator.TypeValidatorthat will determine if the givenExpressionhas the right type- Returns:
trueif the givenExpressionpasses the checks;falseotherwise
-
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 theSELECTclause.- Specified by:
selectClausePathExpressionPathTypein 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 givenABSexpression. 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:
validateAbsExpressionin classAbstractSemanticValidator- Parameters:
expression- TheAbsExpressionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
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:
validateArithmeticExpressionin classAbstractSemanticValidator- Parameters:
expression- TheArithmeticExpressionto 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 givenAVGexpression. 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:
validateAvgFunctionin classAbstractSemanticValidator- Parameters:
expression- TheAvgFunctionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
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:
validateBetweenExpressionin classAbstractSemanticValidator- Parameters:
expression- TheBetweenExpressionto validate
-
validateBooleanType
protected boolean validateBooleanType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expressionreturns a boolean value; - The
Expression's type is a boolean type.
- Parameters:
expression- TheExpressionto 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:
validateCollectionMemberExpressionin classAbstractSemanticValidator- Parameters:
expression- TheCollectionMemberExpressionto 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:
validateComparisonExpressionin classAbstractSemanticValidator- Parameters:
expression- TheConcatExpressionto validate by validating its left and right expressions- Returns:
- The status of the comparison between the left and right expression:
trueif the two expressions pass the rules defined by this method;falseotherwise
- If the comparison operator is either '=' or '<>'. The expressions can only be
-
validateConcatExpression
protected boolean validateConcatExpression(ConcatExpression expression)
Validates the encapsulated expression of the givenCONCATexpression. 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:
validateConcatExpressionin classAbstractSemanticValidator- Parameters:
expression- TheConcatExpressionto validate by validating its encapsulated expression- Returns:
falseif the first encapsulated expression was validated and is invalid;trueotherwise
-
validateConstructorExpression
protected void validateConstructorExpression(ConstructorExpression expression)
Validates the givenConstructorExpression. The default behavior does not require to semantically validate it.- Overrides:
validateConstructorExpressionin classAbstractSemanticValidator- Parameters:
expression- TheConstructorExpressionto validate
-
validateCountFunction
protected void validateCountFunction(CountFunction expression)
Validates the givenCountFunction. The default behavior does not require to semantically validate it.- Overrides:
validateCountFunctionin classAbstractSemanticValidator- Parameters:
expression- TheCountFunctionto validate
-
validateEntryExpression
protected void validateEntryExpression(EntryExpression expression)
Validates the givenEntryExpression. The default behavior does not require to semantically validate it.- Overrides:
validateEntryExpressionin classAbstractSemanticValidator- Parameters:
expression- TheEntryExpressionto 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:
validateIdentificationVariablein classAbstractSemanticValidator- Parameters:
expression- TheIdentificationVariablethat is being visitedvariable- The actual identification variable, which is never an empty string- Returns:
trueif the given identification variable is valid;falseotherwise
-
validateIntegralType
protected boolean validateIntegralType(Expression expression, java.lang.String queryBNF, java.lang.String messageKey)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expressionreturns a integral value; - The
Expression's type is an integral type (long or integer).
- Parameters:
expression- TheExpressionto 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:
falseif the given expression was validated and is invalid;trueotherwise
- The
-
validateKeyExpression
protected void validateKeyExpression(KeyExpression expression)
Validates the givenKeyExpression. The default behavior does not require to semantically validate it.- Overrides:
validateKeyExpressionin classAbstractSemanticValidator- Parameters:
expression- TheKeyExpressionto validate
-
validateLengthExpression
protected boolean validateLengthExpression(LengthExpression expression)
Validates the encapsulated expression of the givenLENGTHexpression. 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:
validateLengthExpressionin classAbstractSemanticValidator- Parameters:
expression- TheLengthExpressionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
validateLocateExpression
protected int validateLocateExpression(LocateExpression expression)
Validates the encapsulated expression of the givenLOCATEexpression. 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:
validateLocateExpressionin classAbstractSemanticValidator- Parameters:
expression- TheLocateExpressionto 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 givenLOWERexpression. 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:
validateLowerExpressionin classAbstractSemanticValidator- Parameters:
expression- TheLowerExpressionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
validateMapIdentificationVariable
protected void validateMapIdentificationVariable(EncapsulatedIdentificationVariableExpression expression)
-
validateModExpression
protected int validateModExpression(ModExpression expression)
Validates the encapsulated expression of the givenMODexpression. 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:
validateModExpressionin classAbstractSemanticValidator- Parameters:
expression- TheModExpressionto 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:
validateNotExpressionin classAbstractSemanticValidator- Parameters:
expression- TheNotExpressionto validate
-
validateNullComparisonExpression
protected void validateNullComparisonExpression(NullComparisonExpression expression)
Validates the givenNullComparisonExpression. The default behavior does not require to semantically validate it.- Overrides:
validateNullComparisonExpressionin classAbstractSemanticValidator- Parameters:
expression- TheNullComparisonExpressionto validate
-
validateNumericType
protected boolean validateNumericType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expressionreturns a numeric value; - The
Expression's type is an numeric type.
- Parameters:
expression- TheExpressionto validatemessageKey- The key used to retrieve the localized message describing the problem- Returns:
falseif the given expression was validated and is invalid;trueotherwise
- The
-
validateSqrtExpression
protected boolean validateSqrtExpression(SqrtExpression expression)
Validates the encapsulated expression of the givenSQRTexpression. 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:
validateSqrtExpressionin classAbstractSemanticValidator- Parameters:
expression- TheSqrtExpressionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
validateStringType
protected boolean validateStringType(Expression expression, java.lang.String messageKey)
Determines whether the givenExpressionis of the correct type based on these rules:- The
Expressionreturns a String value; - The
Expression's type is a String type.
- Parameters:
expression- TheExpressionto validatemessageKey- The key used to retrieve the localized message describing the problem- Returns:
falseif the given expression was validated and is invalid;trueotherwise
- The
-
validateSubstringExpression
protected int validateSubstringExpression(SubstringExpression expression)
Validates the encapsulated expression of the givenSUBSTRINGexpression. 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:
validateSubstringExpressionin classAbstractSemanticValidator- Parameters:
expression- TheSubstringExpressionto 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 givenMODexpression. 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:
validateSumFunctionin classAbstractSemanticValidator- Parameters:
expression- TheModExpressionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
validateUpdateItem
protected boolean validateUpdateItem(UpdateItem expression)
Validates the givenUpdateItemby 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:
validateUpdateItemin classAbstractSemanticValidator- Parameters:
expression-UpdateItemto validate its path expression- Returns:
trueif the path expression is valid;falseotherwise
-
validateUpdateItemTypes
protected void validateUpdateItemTypes(UpdateItem expression, java.lang.Object type)
-
validateUpperExpression
protected boolean validateUpperExpression(UpperExpression expression)
Validates the encapsulated expression of the givenUPPERexpression. 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:
validateUpperExpressionin classAbstractSemanticValidator- Parameters:
expression- TheUpperExpressionto validate by validating its encapsulated expression- Returns:
falseif the encapsulated expression was validated and is invalid;trueotherwise
-
validateValueExpression
protected void validateValueExpression(ValueExpression expression)
Validates the givenValueExpression. The default behavior does not require to semantically validate it.- Overrides:
validateValueExpressionin classAbstractSemanticValidator- Parameters:
expression- TheValueExpressionto validate
-
-