use of org.eclipse.persistence.jpa.jpql.parser.BetweenExpression in project eclipselink by eclipse-ee4j.
the class AbstractActualJPQLQueryFormatter method visit.
@Override
public void visit(BetweenExpressionStateObject stateObject) {
if (stateObject.isDecorated()) {
toText(stateObject);
} else {
BetweenExpression expression = stateObject.getExpression();
// Expression
if (stateObject.hasStateObject()) {
stateObject.getStateObject().accept(this);
writer.append(SPACE);
}
// 'NOT
if (stateObject.hasNot()) {
appendIdentifier((expression != null) ? expression.getActualNotIdentifier() : NOT, NOT);
writer.append(SPACE);
}
// 'BETWEEN'
appendIdentifier((expression != null) ? expression.getActualBetweenIdentifier() : BETWEEN, BETWEEN);
if (shouldOutput(expression) || expression.hasSpaceAfterBetween()) {
writer.append(SPACE);
}
// Lower bound expression
if (stateObject.hasLowerBound()) {
stateObject.getLowerBound().accept(this);
}
if (shouldOutput(expression) || expression.hasSpaceAfterLowerBound()) {
writer.append(SPACE);
}
// 'AND'
if (shouldOutput(expression) || expression.hasAnd()) {
appendIdentifier((expression != null) ? expression.getActualAndIdentifier() : AND, AND);
}
if (shouldOutput(expression) || expression.hasSpaceAfterAnd()) {
writer.append(SPACE);
}
// Upper bound expression
if (stateObject.hasUpperBound()) {
stateObject.getUpperBound().accept(this);
}
}
}
use of org.eclipse.persistence.jpa.jpql.parser.BetweenExpression in project eclipselink by eclipse-ee4j.
the class ParameterTypeVisitor method visit.
@Override
public void visit(BetweenExpression expression) {
Expression betweenExpression = expression.getExpression();
Expression lowerBound = expression.getLowerBoundExpression();
Expression upperBound = expression.getUpperBoundExpression();
// The input parameter is the expression to be tested within the range of values
if (betweenExpression.isAncestor(inputParameter)) {
if (visitedExpressions.add(expression)) {
lowerBound.accept(this);
visitedExpressions.remove(expression);
} else {
type = null;
ignoreType = true;
expression = null;
}
} else // The input parameter is on the lower bound side, traverse the upper bound
if (lowerBound.isAncestor(inputParameter)) {
if (visitedExpressions.add(expression)) {
upperBound.accept(this);
visitedExpressions.remove(expression);
// The upper bound might also be an input parameter
if ((type == null) && visitedExpressions.add(expression)) {
betweenExpression.accept(this);
visitedExpressions.remove(expression);
}
} else {
type = null;
ignoreType = true;
expression = null;
}
} else // The input parameter is on the upper bound side, traverse the lower bound
if (upperBound.isAncestor(inputParameter)) {
if (visitedExpressions.add(expression)) {
lowerBound.accept(this);
visitedExpressions.remove(expression);
// The lower bound might also be an input parameter
if ((type == null) && visitedExpressions.add(expression)) {
betweenExpression.accept(this);
visitedExpressions.remove(expression);
}
} else {
type = null;
ignoreType = true;
expression = null;
}
} else {
type = Boolean.class;
}
}
use of org.eclipse.persistence.jpa.jpql.parser.BetweenExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateBetweenExpression.
/**
* Validates the given {@link BetweenExpression}. The test to perform is:
* <ul>
* <li>If the "first" expression is a path expression, validation makes sure it is a basic
* mapping, an association field is not allowed.</li>
* </ul>
*
* @param expression The {@link BetweenExpression} to validate
*/
protected int validateBetweenExpression(BetweenExpression expression) {
int result = 0;
// Validate the "first" expression
if (expression.hasExpression()) {
Expression firstExpression = expression.getExpression();
// 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 lower bound expression
expression.getLowerBoundExpression().accept(this);
// Validate the upper bound expression
expression.getUpperBoundExpression().accept(this);
return result;
}
use of org.eclipse.persistence.jpa.jpql.parser.BetweenExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(BetweenExpression expression) {
// First create the Expression for the result expression
expression.getExpression().accept(this);
Expression resultExpression = queryExpression;
// Create the expression for the lower bound expression
expression.getLowerBoundExpression().accept(this);
Expression lowerBoundExpression = queryExpression;
// Create the expression for the upper bound expression
expression.getUpperBoundExpression().accept(this);
Expression upperBoundExpression = queryExpression;
// Create the BETWEEN expression
if (expression.hasNot()) {
queryExpression = resultExpression.notBetween(lowerBoundExpression, upperBoundExpression);
} else {
queryExpression = resultExpression.between(lowerBoundExpression, upperBoundExpression);
}
// Set the expression type
type[0] = Boolean.class;
}
Aggregations