@Override public Expression getExpression1(BinaryComparisonOperator filter) { return filter.getExpression1(); }
@Override protected void visitBinaryComparisonOperator(BinaryComparisonOperator filter) { Expression expression1 = filter.getExpression1(); Expression expression2 = filter.getExpression2(); if ((expression1 instanceof JsonSelectFunction || expression1 instanceof JsonSelectAllFunction) && expression2 instanceof Literal) { preStack.push(filter); } else if ((expression2 instanceof JsonSelectFunction || expression2 instanceof JsonSelectAllFunction) && expression1 instanceof Literal) { preStack.push(filter); } }
public Object getProperty(Object object, QName name) throws Exception { if (OGC.expression.equals(name)) { BinaryComparisonOperator op = (BinaryComparisonOperator) object; return new Expression[] {op.getExpression1(), op.getExpression2()}; } // filter 1.1 only if ("matchCase".equals(name.getLocalPart())) { BinaryComparisonOperator op = (BinaryComparisonOperator) object; return Boolean.valueOf(op.isMatchingCase()); } return null; } }
@Override public Object getProperty(Object object, QName name) throws Exception { BinaryComparisonOperator op = (BinaryComparisonOperator) object; if ("matchAction".equals(name.getLocalPart())) { return op.getMatchAction().name(); } if ("matchCase".equals(name.getLocalPart())) { return op.isMatchingCase(); } if (FES.expression.equals(name)) { return new Expression[] {op.getExpression1(), op.getExpression2()}; } return null; } }
/** * Visits filter.getExpression1(), and filter.getExpression2() if an expression visitor was set. */ protected Object visit(BinaryComparisonOperator filter, Object data) { if (expressionVisitor != null) { if (filter.getExpression1() != null) { filter.getExpression1().accept(expressionVisitor, data); } if (filter.getExpression2() != null) { filter.getExpression2().accept(expressionVisitor, data); } } return filter; }
private void visitBinaryComparisonOperator(BinaryComparisonOperator filter) { visitBinaryOperator(filter, filter.getExpression1(), filter.getExpression2()); }
Expression leftValue = filter.getExpression1(); Expression rightValue = filter.getExpression2(); if (leftValue == null || rightValue == null) {
/** * Returns a CompareFilter of the same type than <code>filter</code>, but built on the unmapped * expressions pointing to the surrogate type attributes. * * @return the scalar product of the evaluation of both expressions */ public Expression[][] visitBinaryComparisonOperator(BinaryComparisonOperator filter) { Expression left = filter.getExpression1(); Expression right = filter.getExpression2(); List leftExpressions = (List) left.accept(this, null); List rightExpressions = (List) right.accept(this, null); if (leftExpressions.size() == 0) { throw new IllegalStateException(left + " mapping not found"); } if (rightExpressions.size() == 0) { throw new IllegalStateException(right + " mapping not found"); } Expression[][] product = buildExpressionsMatrix(leftExpressions, rightExpressions); return product; }
private Object guardAgainstNulls(BinaryComparisonOperator clone) { Filter result = guardAgainstNulls(clone, clone.getExpression1()); result = guardAgainstNulls(result, clone.getExpression2()); return result; }
|| f instanceof PropertyIsLessThanOrEqualTo) { BinaryComparisonOperator cf = (BinaryComparisonOperator) f; Expression e = cf.getExpression1(); if (e != null && e instanceof LengthFunction) { length = length = Integer.parseInt( ((Literal) cf.getExpression1()) .getValue() .toString());
/** * Builds a comparison predicate inserting the operato1 or operator2 taking into account the * PropertyName position in the comparison filter. * * @param filter * @param extraData * @param operator an operator * @return SringBuffer */ public static Object buildComparison( BinaryComparisonOperator filter, Object extraData, String operator) { StringBuilder output = asStringBuilder(extraData); ExpressionToText visitor = new ExpressionToText(); Expression expr = filter.getExpression1(); expr.accept(visitor, output); output.append(" ").append(operator).append(" "); filter.getExpression2().accept(visitor, output); return output; }
private Object simplifyBinaryComparisonOperator(BinaryComparisonOperator clone) { if (isConstant(clone.getExpression1()) && isConstant(clone.getExpression2())) { return staticFilterEvaluate(clone); } else { return clone; } }
BasicDBObject encodeBinaryComparisonOp( BinaryComparisonOperator filter, String op, Object extraData) { BasicDBObject output = asDBObject(extraData); Expression left = filter.getExpression1(); Expression right = filter.getExpression2(); Class<?> leftValueType = getValueType(right), rightValueType = getValueType(left); Object leftValue = filter.getExpression1().accept(this, leftValueType); Object rightValue = filter.getExpression2().accept(this, rightValueType); if (rightValue instanceof String && !(leftValue instanceof String)) { // reverse Object tmp = leftValue; leftValue = rightValue; rightValue = tmp; } output.put((String) leftValue, op == null ? rightValue : new BasicDBObject(op, rightValue)); return output; }
Object transform(BinaryComparisonOperator filter, Object extraData) { // binary filters may use two random expressions, check if we have // enough information for a reprojection PropertyName name; Expression other; if ((filter.getExpression1() instanceof PropertyName)) { name = (PropertyName) filter.getExpression1(); other = filter.getExpression2(); } else if (filter.getExpression2() instanceof PropertyName) { name = (PropertyName) filter.getExpression2(); other = filter.getExpression1(); } else { return cloneFilter(filter, extraData); } CoordinateReferenceSystem propertyCrs = findPropertyCRS(name); // we have to reproject only if the property is geometric if (propertyCrs == null) return cloneFilter(filter, extraData); // "transformed" expressions Expression ex1 = (Expression) name.accept(ReprojectingFilterVisitor.this, extraData); Expression ex2 = reproject(other, propertyCrs, false); if (ex2 == null) ex2 = (Expression) other.accept(ReprojectingFilterVisitor.this, extraData); return cloneFilter(filter, extraData, ex1, ex2); }
if (cf.getExpression1() instanceof LengthFunction) { filterLength = cf.getExpression2().evaluate(null, Integer.class) - 1; if (cf.getExpression1() instanceof LengthFunction) { filterLength = cf.getExpression2().evaluate(null, Integer.class); BinaryComparisonOperator cf = (BinaryComparisonOperator) f; if (cf.getExpression2() instanceof LengthFunction) { filterLength = cf.getExpression1().evaluate(null, Integer.class) - 1; filterLength = cf.getExpression1().evaluate(null, Integer.class);
if (!(filter1.getExpression2().equals(filter2.getExpression1()))) { throw new IllegalArgumentException( "Subfilters or subExpressions in incorrect order"); attrExpression = ((BinaryComparisonOperator) ((Or) filter).getChildren().get(0)) .getExpression1(); } else { // COMPARE_EQUALS (simple explicit expression) attrExpression = ((PropertyIsEqualTo) filter).getExpression1();
/** * Overrides base behavior to handler arrays * * @param filter the comparison to be turned into SQL. * @param extraData * @throws RuntimeException */ protected void visitBinaryComparisonOperator(BinaryComparisonOperator filter, Object extraData) throws RuntimeException { Expression left = filter.getExpression1(); Expression right = filter.getExpression2(); Class rightContext = super.getExpressionType(left); Class leftContext = super.getExpressionType(right); // array comparison in PostgreSQL is strict, need to know the base type, that info is // available only in the property name userdata String type = (String) extraData; if ((helper.isArray(rightContext) || helper.isArray(leftContext)) && (left instanceof PropertyName || right instanceof PropertyName)) { helper.out = out; helper.visitArrayComparison(filter, left, right, rightContext, leftContext, type); } else { super.visitBinaryComparisonOperator(filter, extraData); } }
/** * Overrides base behavior to handler arrays * * @param filter the comparison to be turned into SQL. * @param extraData * @throws RuntimeException */ protected void visitBinaryComparisonOperator(BinaryComparisonOperator filter, Object extraData) throws RuntimeException { Expression left = filter.getExpression1(); Expression right = filter.getExpression2(); Class rightContext = super.getExpressionType(left); Class leftContext = super.getExpressionType(right); // array comparison in PostgreSQL is strict, need to know the base type, that info is // available only in the property name userdata String type = (String) extraData; if ((helper.isArray(rightContext) || helper.isArray(leftContext)) && (left instanceof PropertyName || right instanceof PropertyName)) { helper.out = out; helper.visitArrayComparison(filter, left, right, rightContext, leftContext, type); } else { super.visitBinaryComparisonOperator(filter, extraData); } }
private ExpressionRange getRange(BinaryComparisonOperator op) { Range range = null; Expression expression = null; if (!(isStatic(op.getExpression1()))) { expression = op.getExpression1(); Class binding = getTypeIfComparable(expression); if (binding != null) { Class binding = getTypeIfComparable(expression); if (binding != null) { Object value = evaluate(op.getExpression1(), binding); if (value != null) { if (op instanceof PropertyIsLessThan) {
/** * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element, * java.lang.Object, org.geotools.xml.PrintHandler, java.util.Map) */ public void encode(Element element, Object value, PrintHandler output, Map hints) throws IOException, OperationNotSupportedException { if (!canEncode(element, value, hints)) { return; } BinaryComparisonOperator cf = (BinaryComparisonOperator) value; output.startElement(element.getNamespace(), element.getName(), null); // TODO is this order dependant? encodeExpr(cf.getExpression1(), output, hints); encodeExpr(cf.getExpression2(), output, hints); output.endElement(element.getNamespace(), element.getName()); } }