use of org.eclipse.persistence.jpa.jpql.parser.ModExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateModExpression.
/**
* Validates the encapsulated expression of the given <code><b>MOD</b></code> expression. The
* test to perform is:
* <ul>
* <li>If the encapsulated expression is a path expression, validation makes sure it is a basic
* mapping, an association field is not allowed.</li>
* <li>If the encapsulated expression is not a path expression, validation will be redirected to
* that expression but the returned status will not be changed.</li>
* </ul>
*
* @param expression The {@link ModExpression} to validate by validating its encapsulated expression
* @return A number indicating the validation result. {@link #isValid(int, int)} can be used to
* determine the validation status of an expression based on its position
*/
protected int validateModExpression(ModExpression expression) {
int result = 0;
// Validate the first expression
if (expression.hasFirstExpression()) {
Expression firstExpression = expression.getFirstExpression();
// Special case for state field path expression, association field is not allowed
StateFieldPathExpression pathExpression = getStateFieldPathExpression(firstExpression);
if (pathExpression != null) {
boolean valid = validateStateFieldPathExpression(pathExpression, PathType.BASIC_FIELD_ONLY);
updateStatus(result, 0, valid);
} else {
firstExpression.accept(this);
}
}
// Validate the second expression
expression.getSecondExpression().accept(this);
return result;
}
use of org.eclipse.persistence.jpa.jpql.parser.ModExpression in project eclipselink by eclipse-ee4j.
the class ReportItemBuilder method visit.
@Override
public void visit(ModExpression expression) {
Expression queryExpression = queryContext.buildExpression(expression, type);
addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]);
}
use of org.eclipse.persistence.jpa.jpql.parser.ModExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(ModExpression expression) {
// First create the Expression for the first expression
expression.getFirstExpression().accept(this);
Expression leftExpression = queryExpression;
// Now create the Expression for the second expression
expression.getSecondExpression().accept(this);
Expression rightExpression = queryExpression;
// Now create the MOD expression
queryExpression = ExpressionMath.mod(leftExpression, rightExpression);
// Set the expression type
type[0] = Integer.class;
}
Aggregations