/** * Traverses the expression and returns any encountered property names. * * <p>The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. */ public static Set<PropertyName> propertyNames( Expression expression, final SimpleFeatureType featureType) { if (expression == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); expression.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
/** * Traverses the expression and returns any encountered property names. * * <p>The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. */ public static Set<PropertyName> propertyNames( Expression expression, final SimpleFeatureType featureType) { if (expression == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); expression.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
private <T extends Filter> NestedAttributeExpression getNestedAttributeExpression(T filter) { FilterAttributeExtractor extractor = new FilterAttributeExtractor(); filter.accept(extractor, null); Set<PropertyName> propertyNames = extractor.getPropertyNameSet(); for (PropertyName property : propertyNames) { if (property instanceof NestedAttributeExpression) { return (NestedAttributeExpression) property; } } return null; }
/** * Traverses the filter and returns any encountered property names. * * <p>The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. */ public static Set<PropertyName> propertyNames( Filter filter, final SimpleFeatureType featureType) { if (filter == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); filter.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
/** * Traverses the filter and returns any encountered property names. * * <p>The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. */ public static Set<PropertyName> propertyNames( Filter filter, final SimpleFeatureType featureType) { if (filter == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); filter.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
/** * A filter is considered <em>nested</em> if it operates on at least one nested attribute. * * <p>Technically, this means that at least one of the expressions in it is an instance of * {@link NestedAttributeExpression}. * * @param filter the filter to test * @return <code>true</code> if the filter involves at least one nested attribute, <code>false * </code> otherwise */ public static boolean isNestedFilter(Filter filter) { FilterAttributeExtractor extractor = new FilterAttributeExtractor(); filter.accept(extractor, null); return hasNestedAttributes(extractor.getPropertyNameSet()); }
/** * Returns true if the visitor is geometryless, that is, it's not accessing a geometry field in * the target schema * * @param visitor * @return */ public static boolean isGeometryless(FeatureVisitor visitor, SimpleFeatureType schema) { if (visitor instanceof FeatureAttributeVisitor) { // pass through unless one of the expressions requires the geometry attribute FilterAttributeExtractor extractor = new FilterAttributeExtractor(schema); for (Expression e : ((FeatureAttributeVisitor) visitor).getExpressions()) { e.accept(extractor, null); } for (PropertyName pname : extractor.getPropertyNameSet()) { AttributeDescriptor att = (AttributeDescriptor) pname.evaluate(schema); if (att instanceof GeometryDescriptor) { return false; } } return true; } else if (visitor instanceof CountVisitor) { return true; } return false; } }
/** * Checks if the visitor is accessing only properties available in the specified feature type, * or as a special case, if it's a count visitor accessing no properties at all * * @param visitor * @param featureType * @return */ public static boolean isTypeCompatible(FeatureVisitor visitor, SimpleFeatureType featureType) { if (visitor instanceof FeatureAttributeVisitor) { // pass through if the target schema contains all the necessary attributes FilterAttributeExtractor extractor = new FilterAttributeExtractor(featureType); for (Expression e : ((FeatureAttributeVisitor) visitor).getExpressions()) { e.accept(extractor, null); } for (PropertyName pname : extractor.getPropertyNameSet()) { AttributeDescriptor att = (AttributeDescriptor) pname.evaluate(featureType); if (att == null) { return false; } } return true; } else if (visitor instanceof CountVisitor) { return true; } return false; } }
private void assertAttributeName(org.opengis.filter.Filter filter, String[] names) { fae.clear(); filter.accept(fae, null); Set<String> attNames = fae.getAttributeNameSet(); assertNotNull(attNames); assertEquals(attNames.size(), names.length); for (int i = 0; i < names.length; i++) { assertTrue(attNames.contains(names[i])); } // make sure the property name set is aligned Set<PropertyName> propNames = fae.getPropertyNameSet(); assertNotNull(propNames); assertEquals(attNames.size(), propNames.size()); for (PropertyName pn : propNames) { assertTrue(attNames.contains(pn.getPropertyName())); } }
public void testPropertyNameSet() throws IllegalFilterException { Filter filter = fac.equals(fac.property("testString"), fac.literal("test string data")); Expression expression1 = fac.property("code"); Expression expression2 = fac.function("length", fac.property("identification")); FilterAttributeExtractor extract = new FilterAttributeExtractor(null); Set<String> names = new HashSet<String>(); // used to collect names from expression1, expression2, and filter expression1.accept(extract, names); expression2.accept(extract, names); filter.accept(extract, names); String array[] = extract.getAttributeNames(); Set<String> attributes = extract.getAttributeNameSet(); Set<PropertyName> properties = extract.getPropertyNameSet(); assertEquals(3, array.length); assertEquals(3, attributes.size()); assertEquals(3, properties.size()); } /**
/** * Traverses the filter and returns any encountered property names. * <p> * The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. * </p> */ public static Set<PropertyName> propertyNames(Filter filter, final SimpleFeatureType featureType) { if (filter == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); filter.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
/** * Traverses the filter and returns any encountered property names. * <p> * The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. * </p> */ public static Set<PropertyName> propertyNames(Filter filter, final SimpleFeatureType featureType) { if (filter == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); filter.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
/** * Traverses the expression and returns any encountered property names. * <p> * The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. * </p> */ public static Set<PropertyName> propertyNames(Expression expression, final SimpleFeatureType featureType) { if (expression == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); expression.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
/** * Traverses the expression and returns any encountered property names. * <p> * The feature type is supplied as contexts used to lookup expressions in cases where the * attributeName does not match the actual name of the type. * </p> */ public static Set<PropertyName> propertyNames(Expression expression, final SimpleFeatureType featureType) { if (expression == null) { return Collections.emptySet(); } FilterAttributeExtractor attExtractor = new FilterAttributeExtractor(featureType); expression.accept(attExtractor, null); Set<PropertyName> propertyNames = attExtractor.getPropertyNameSet(); return propertyNames; }
private Set<String> getFilterPrefixes(Filter filter) { FilterAttributeExtractor extractor = new FilterAttributeExtractor(); filter.accept(extractor, null); Set<PropertyName> attributeNames = extractor.getPropertyNameSet(); Set<String> prefixes = new HashSet<>(); for (PropertyName attributeName : attributeNames) {