public Object visit(PropertyIsNull filter, Object arg1) { Expression nullCheck = filter.getExpression(); List sourceChecks = (List) nullCheck.accept(this, null); List combined = new ArrayList(sourceChecks.size()); for (Iterator it = sourceChecks.iterator(); it.hasNext(); ) { Expression sourceValue = (Expression) it.next(); Filter newFilter = ff.isNull(sourceValue); combined.add(newFilter); } Filter unrolled = combineOred(combined); return unrolled; }
/** * Parses a null filter from a node known to be a null node. * * @param nullNode the PropertyIsNull node. * @return a null filter of the expression contained in null node. * @throws IllegalFilterException DOCUMENT ME! */ private static PropertyIsNull parseNullFilter(Node nullNode) throws IllegalFilterException { final ExpressionDOMParser expressionDOMParser = new ExpressionDOMParser(FILTER_FACT); LOGGER.finest("parsing null node: " + nullNode); Node value = nullNode.getFirstChild(); while (value.getNodeType() != Node.ELEMENT_NODE) { value = value.getNextSibling(); } LOGGER.finest("add null value -> " + value + "<-"); Expression expr = expressionDOMParser.expression(value); return FILTER_FACT.isNull(expr); } }
/** * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, * org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map) */ public Object getValue(Element element, ElementValue[] value, Attributes attrs, Map hints) throws SAXException { FilterFactory2 factory = FilterSchema.filterFactory(hints); try { Expression expr = (Expression) value[0].getValue(); return factory.isNull(expr); } catch (ClassCastException expressionRequired) { throw new SAXException("Illegal filter for " + element, expressionRequired); } catch (IllegalFilterException e) { throw new SAXException("Illegal filter for " + element); } }
public Object visit(PropertyIsNull filter, Object extraData) { Expression expr = visit(filter.getExpression(), extraData); return getFactory(extraData).isNull(expr); }
static PropertyIsNull propertyIsNull() { return f.isNull(propertyName()); }
/** * Test the null operator. * * @throws IllegalFilterException If the constructed filter is not valid. */ public void testNull() throws IllegalFilterException { PropertyIsNull filter = fac.isNull(fac.property("foo")); assertAttributeName(filter, new String[] {"foo"}); }
/** * Guards the filter against potential null values in the target property name (if it is a * property name, to start with) */ private Filter guardAgainstNulls(Filter filter, Expression potentialPropertyName) { if (potentialPropertyName instanceof PropertyName) { PropertyName pn = (PropertyName) potentialPropertyName; String name = pn.getPropertyName(); if (isNillable(name)) { Not notNull = ff.not(ff.isNull(ff.property(name))); if (filter instanceof And) { And and = (And) filter; List<Filter> children = new ArrayList<Filter>(and.getChildren()); children.add(notNull); return ff.and(children); } else { return ff.and(filter, notNull); } } } return filter; }
private Not propertyNotNull(String name) { return ff.not(ff.isNull(ff.property(name))); } }
public void testIdCollector() { Filter filter = ff.isNull(ff.property("name")); Set fids = (Set) filter.accept(IdCollectorFilterVisitor.ID_COLLECTOR, new HashSet()); assertTrue(fids.isEmpty()); assertFalse(fids.contains("eclesia")); filter = ff.id(Collections.singleton(ff.featureId("eclesia"))); fids = (Set) filter.accept(IdCollectorFilterVisitor.ID_COLLECTOR, new HashSet()); assertFalse(fids.isEmpty()); assertTrue(fids.contains("eclesia")); } }
/** * Test the null operator. * * @throws IllegalFilterException If the constructed filter is not valid. */ public void testNull() throws IllegalFilterException { // Test for false positive. PropertyName testAttribute = new AttributeExpressionImpl(testSchema, "testString"); PropertyIsNull filter = fac.isNull(org.opengis.filter.expression.Expression.NIL); assertTrue(filter.evaluate(testFeature)); filter = fac.isNull(testAttribute); assertFalse(filter.evaluate(testFeature)); }
@Test public void testNull() { Filter filter = ff.isNull(ff.property("name")); Envelope env = (Envelope) filter.accept(visitor, null); assertEquals(infinity, env); }
public void testNullFilterVisitor() { Filter filter = ff.isNull(ff.property("name")); assertEquals(Integer.valueOf(1), filter.accept(NullFilterVisitor.NULL_VISITOR, 1)); filter = Filter.INCLUDE; assertEquals(Integer.valueOf(1), filter.accept(NullFilterVisitor.NULL_VISITOR, 1)); FilterVisitor allFids = new NullFilterVisitor() { public Object visit(Id filter, Object data) { if (data == null) return null; Set set = (Set) data; set.addAll(filter.getIDs()); return set; } }; Filter myFilter = ff.id(Collections.singleton(ff.featureId("fred"))); Set set = (Set) myFilter.accept(allFids, new HashSet()); assertNotNull(set); Set set2 = (Set) myFilter.accept(allFids, null); // set2 will be null assertNull(set2); }
public void testIdFinderFilterVisitor() { Filter filter = ff.isNull(ff.property("name")); boolean found = (Boolean) filter.accept(new IdFinderFilterVisitor(), null); assertFalse(found); filter = ff.id(Collections.singleton(ff.featureId("eclesia"))); found = (Boolean) filter.accept(new IdFinderFilterVisitor(), null); assertTrue(found); }
@Test public void testAndIsNull() throws Exception { final Filter f = ff.and(ff.bbox("geom", -10, -10, 10, 10, null), ff.isNull(ff.literal("someDate"))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testNullFilter() throws Exception { PropertyIsNull nullFilter = ff.isNull(ff.property("measurement/result")); Filter unrolled = (Filter) nullFilter.accept(visitor, null); assertTrue(unrolled instanceof PropertyIsNull); assertNotSame(nullFilter, unrolled); PropertyIsNull unmapped = (PropertyIsNull) unrolled; Expression unmappedAtt = unmapped.getExpression(); assertTrue(unmappedAtt instanceof PropertyName); assertEquals("results_value", ((PropertyName) unmappedAtt).getPropertyName()); }
public Object visit(PropertyIsNull filter, Object arg1) { Expression nullCheck = filter.getExpression(); List sourceChecks = (List) nullCheck.accept(this, null); List combined = new ArrayList(sourceChecks.size()); for (Iterator it = sourceChecks.iterator(); it.hasNext();) { Expression sourceValue = (Expression) it.next(); Filter newFilter = ff.isNull(sourceValue); combined.add(newFilter); } Filter unrolled = combineOred(combined); return unrolled; }
PropertyIsNull nullFilter = fac.isNull(testAttribute);
public Object visit(PropertyIsNull filter, Object extraData) { Expression expr= visit(filter.getExpression(), extraData); return getFactory(extraData).isNull(expr); }
public Object visit(PropertyIsNull filter, Object extraData) { Expression expr=(Expression) filter.getExpression().accept(this, extraData); return getFactory(extraData).isNull(expr); }
@Test public void testNullFilter() throws Exception { PropertyIsNull nullFilter = ff.isNull(ff.property("measurement/result")); Filter unrolled = (Filter) nullFilter.accept(visitor, null); assertTrue(unrolled instanceof PropertyIsNull); assertNotSame(nullFilter, unrolled); PropertyIsNull unmapped = (PropertyIsNull) unrolled; Expression unmappedAtt = unmapped.getExpression(); assertTrue(unmappedAtt instanceof PropertyName); assertEquals("results_value", ((PropertyName) unmappedAtt).getPropertyName()); }