return operand1 + " " + operator + " " + operand2;
}
@Override
public void restrict(FilterImpl f) {
PropertyValue v = operand2.currentValue();
if (!PropertyValues.canConvert(
operand2.getPropertyType(),
operand1.getPropertyType())) {
throw new IllegalArgumentException(
"Unsupported conversion from property type " +
PropertyType.nameFromValue(operand2.getPropertyType()) +
" to property type " +
PropertyType.nameFromValue(operand1.getPropertyType()));
}
if (v != null) {
if (operator == Operator.LIKE) {
String pattern;
pattern = v.getValue(Type.STRING);
LikePattern p = new LikePattern(pattern);
String lowerBound = p.getLowerBound();
if (lowerBound != null) {
String upperBound = p.getUpperBound();
if (lowerBound.equals(upperBound)) {
// no wildcards
operand1.restrict(f, Operator.EQUAL, v);
} else if (operand1.supportsRangeConditions()) {
if (lowerBound != null) {
PropertyValue pv = PropertyValues.newString(lowerBound);
operand1.restrict(f, Operator.GREATER_OR_EQUAL, pv);
}
if (upperBound != null) {
PropertyValue pv = PropertyValues.newString(upperBound);
operand1.restrict(f, Operator.LESS_OR_EQUAL, pv);
}
} else {
// path conditions
operand1.restrict(f, operator, v);