use of org.eclipse.persistence.jpa.jpql.parser.SubstringExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateSubstringExpression.
/**
* Validates the encapsulated expression of the given <code><b>SUBSTRING</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 SubstringExpression} 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 validateSubstringExpression(SubstringExpression 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);
// Validate the third expression
expression.getThirdExpression().accept(this);
return result;
}
use of org.eclipse.persistence.jpa.jpql.parser.SubstringExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(SubstringExpression expression) {
// Create the first expression
expression.getFirstExpression().accept(this);
Expression firstExpression = queryExpression;
// Create the second expression
expression.getSecondExpression().accept(this);
Expression secondExpression = queryExpression;
// Create the third expression
expression.getThirdExpression().accept(this);
Expression thirdExpression = queryExpression;
// Now create the SUBSTRING expression
if (thirdExpression != null) {
queryExpression = firstExpression.substring(secondExpression, thirdExpression);
} else {
queryExpression = firstExpression.substring(secondExpression);
}
// Set the expression type
type[0] = String.class;
}
use of org.eclipse.persistence.jpa.jpql.parser.SubstringExpression in project eclipselink by eclipse-ee4j.
the class ReportItemBuilder method visit.
@Override
public void visit(SubstringExpression expression) {
Expression queryExpression = queryContext.buildExpression(expression, type);
addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]);
}
Aggregations