use of org.eclipse.persistence.jpa.jpql.parser.LocateExpression in project eclipselink by eclipse-ee4j.
the class ParameterTypeVisitor method visit.
@Override
public void visit(LocateExpression expression) {
Expression firstExpression = expression.getFirstExpression();
Expression secondExpression = expression.getSecondExpression();
// The first two expressions should be a string
if (firstExpression.isAncestor(inputParameter) || secondExpression.isAncestor(inputParameter)) {
this.type = String.class;
} else // It either returns an integer or the third argument is an integer
{
this.type = Integer.class;
}
}
use of org.eclipse.persistence.jpa.jpql.parser.LocateExpression in project eclipselink by eclipse-ee4j.
the class AbstractSemanticValidator method validateLocateExpression.
/**
* Validates the encapsulated expression of the given <code><b>LOCATE</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 LocateExpression} 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 validateLocateExpression(LocateExpression 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.LocateExpression in project eclipselink by eclipse-ee4j.
the class ReportItemBuilder method visit.
@Override
public void visit(LocateExpression expression) {
Expression queryExpression = queryContext.buildExpression(expression, type);
addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]);
}
use of org.eclipse.persistence.jpa.jpql.parser.LocateExpression in project eclipselink by eclipse-ee4j.
the class ExpressionBuilderVisitor method visit.
@Override
public void visit(LocateExpression expression) {
// Create the string to find in the find in expression
expression.getFirstExpression().accept(this);
Expression findExpression = queryExpression;
// Create the find in string expression
expression.getSecondExpression().accept(this);
Expression findInExpression = queryExpression;
// Create the expression for the start position
expression.getThirdExpression().accept(this);
Expression startPositionExpression = queryExpression;
// Create the LOCATE expression
if (startPositionExpression != null) {
queryExpression = findInExpression.locate(findExpression, startPositionExpression);
} else {
queryExpression = findInExpression.locate(findExpression);
}
// Set the expression type
type[0] = Integer.class;
}
Aggregations