/** * Returns a predicate that checks a CatalogInfo object's property for inequality with the * provided property value. * * <p>The <tt>property</tt> parameter may be specified as a "path" of the form "prop1.prop2". If * any of the resulting properties along the path result in null this method will return null. * * <p>Indexed access to nested list and array properties is supported through the syntax {@code * "prop1[M].prop2.prop3[N]"}, where {@code prop1} and {@code prop3} are list or array * properties, {@code M} is the index of the {@code prop2} element to retrieve from {@code * prop1}, and {@code N} is the index of array or list property {@code prop3} to retrieve. * Indexed access to {{java.util.Set}} properties is <b>not</b> supported. * * <p>Evaluation of nested properties for <b>any</b> member of a collection property is at the * moment not supported * * <p> * * @param property the qualified property name of the predicate's input object to evaluate * @param expected the value to check the input object's property against * @see PropertyIsEqualTo */ public static Filter notEqual(final String property, final Object expected) { return factory.notEqual(factory.property(property), factory.literal(expected)); } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e1 = (Expression) node.getChildValue(0); Expression e2 = (Expression) node.getChildValue(1); // filter 1.1 only // <xsd:attribute default="true" name="matchCase" type="xsd:boolean" use="optional"/> Boolean matchCase = Boolean.TRUE; if (node.hasAttribute("matchCase")) { matchCase = (Boolean) node.getAttributeValue("matchCase"); } return filterfactory.notEqual(e1, e2, matchCase.booleanValue()); } }
PropertyIsNotEqualTo ne = ff.notEqual(variable, ff.literal(exclusion)); exclusionFilters.add(ne);
public void testCaseSensitivity() { Expression e1 = filterFactory.literal("foo"); Expression e2 = filterFactory.literal("FoO"); PropertyIsNotEqualTo caseSensitive = filterFactory.notEqual(e1, e2, true); assertTrue(caseSensitive.evaluate(null)); PropertyIsNotEqualTo caseInsensitive = filterFactory.notEqual(e1, e2, false); assertFalse(caseInsensitive.evaluate(null)); } }
public String encodeInComparison( String functionName, boolean equality, String literal, Object... valueList) throws FilterToSQLException { FilterToSQL encoder = new FilterToSQL(output); Function function = buildInFunction(functionName, valueList); Filter filter; if (equality) { filter = filterFac.equal(function, filterFac.literal(literal), true); } else { filter = filterFac.notEqual(function, filterFac.literal(literal), true); } encoder.encode(filter); String result = output.getBuffer().toString(); output.getBuffer().setLength(0); return result; }
public void testOperandsSameType() { Expression e1 = filterFactory.literal(1); Expression e2 = filterFactory.literal(2); PropertyIsNotEqualTo notEqual = filterFactory.notEqual(e1, e2, true); assertTrue(notEqual.evaluate(null)); }
public void testOperandsDifferentType() { Expression e1 = filterFactory.literal(1); Expression e2 = filterFactory.literal("2"); PropertyIsNotEqualTo notEqual = filterFactory.notEqual(e1, e2, true); assertTrue(notEqual.evaluate(null)); }
public void testOperandsIntDouble() { Expression e1 = filterFactory.literal(1); Expression e2 = filterFactory.literal("1.0"); PropertyIsNotEqualTo notEqual = filterFactory.notEqual(e1, e2, true); assertFalse(notEqual.evaluate(null)); }
@Test public void notEqualsTest() { // forward PropertyIsNotEqualTo source = ff.notEqual(ff.property("i"), ff.literal("10"), true); PropertyIsNotEqualTo bound = (PropertyIsNotEqualTo) source.accept(visitor, null); assertEquals(Integer.valueOf(10), ((Literal) bound.getExpression2()).getValue()); // flip it source = ff.notEqual(ff.literal("10"), ff.property("i"), true); bound = (PropertyIsNotEqualTo) source.accept(visitor, null); assertEquals(Integer.valueOf(10), ((Literal) bound.getExpression1()).getValue()); }
public void testNegateEquals() { Filter f = ff.not(ff.equals(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.notEqual(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testTripleNegation() { PropertyIsEqualTo equal = ff.equals(ff.property("prop"), ff.literal(10)); Filter f = ff.not(ff.not(ff.not(equal))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.notEqual(ff.property("prop"), ff.literal(10)), result); }
public void testNotEqual() throws IOException { FilterFactory ff = dataStore.getFilterFactory(); Function function = ff.function( "in", ff.property(aname("intProperty")), ff.literal("1"), ff.literal("2")); Filter filter = ff.notEqual(function, ff.literal("true"), false); SimpleFeatureSource fs = dataStore.getFeatureSource(tname("ft1")); SimpleFeatureCollection fc = fs.getFeatures(filter); assertEquals(getCaseInsensitiveSet("ft1.0"), collectFeatureIds(fc)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e1 = (Expression) node.getChildValue(0); Expression e2 = (Expression) node.getChildValue(1); //filter 1.1 only //<xsd:attribute default="true" name="matchCase" type="xsd:boolean" use="optional"/> Boolean matchCase = Boolean.TRUE; if (node.hasAttribute("matchCase")) { matchCase = (Boolean) node.getAttributeValue("matchCase"); } return filterfactory.notEqual(e1, e2, matchCase.booleanValue()); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Expression e1 = (Expression) node.getChildValue(0); Expression e2 = (Expression) node.getChildValue(1); //filter 1.1 only //<xsd:attribute default="true" name="matchCase" type="xsd:boolean" use="optional"/> Boolean matchCase = Boolean.TRUE; if (node.hasAttribute("matchCase")) { matchCase = (Boolean) node.getAttributeValue("matchCase"); } return filterfactory.notEqual(e1, e2, matchCase.booleanValue()); } }
org.opengis.filter.Filter compareFilter(Class type) throws ExpressionException { try { org.opengis.filter.expression.Expression right = expression(); org.opengis.filter.expression.Expression left = expression(); org.opengis.filter.Filter f; if (PropertyIsLessThanOrEqualTo.class == type) { f = factory.lessOrEqual(left, right); } else if (PropertyIsLessThan.class == type) { f = factory.less(left, right); } else if (PropertyIsGreaterThanOrEqualTo.class == type) { f = factory.greaterOrEqual(left, right); } else if (PropertyIsGreaterThan.class == type) { f = factory.greater(left, right); } else if (PropertyIsEqualTo.class == type) { f = factory.equals(left, right); } else if (PropertyIsNotEqualTo.class == type) { f = factory.notEqual(left, right, false); } else { throw new IllegalArgumentException(); } return f; } catch (IllegalFilterException ife) { throw new ExpressionException("Exception building CompareFilter",getToken(0),ife); } }