Class FilterAttributeExtractor

Object
DefaultFilterVisitor
FilterAttributeExtractor
All Implemented Interfaces:
ExpressionVisitor, FilterVisitor
Direct Known Subclasses:
MetaBufferEstimator, MultipleValueExtractor, StyleAttributeExtractor

public class FilterAttributeExtractor extends DefaultFilterVisitor
A simple visitor that extracts every attribute used by a filter or an expression

Access to this class is available via:

  • DataUtilities.attributeNames( Filter )
  • DataUtilities.attributeNames( Filter, FeatureType )
  • DataUtilities.attributeNames( Expression )
  • DataUtilities.attributeNames( Expression, FeatureType )
The class can also be used to determine if an expression is "static", that is, despite a complex structure does not use attribute or volatile functions, and can be thus replaced by a constant: for this use case refer to the isConstantExpression() method
Author:
Andrea Aime - GeoSolutions
  • Field Details

    • attributeNames

      protected Set<String> attributeNames
      Last set visited
    • propertyNames

      protected Set<PropertyName> propertyNames
    • usingVolatileFunctions

      protected boolean usingVolatileFunctions
    • usingDynamicProperties

      protected boolean usingDynamicProperties
    • featureType

      protected SimpleFeatureType featureType
      feature type to evaluate against
  • Constructor Details

    • FilterAttributeExtractor

      public FilterAttributeExtractor()
      Just extract the property names; don't check against a feature type.
    • FilterAttributeExtractor

      public FilterAttributeExtractor(SimpleFeatureType featureType)
      Use the provided feature type as a sanity check when extracting property names.
  • Method Details

    • getAttributeNameSet

      public Set<String> getAttributeNameSet()
      Attributes names found (so far).
      Returns:
      an unmofiable set of the attribute names found so far during the visit
    • getPropertyNameSet

      public Set<PropertyName> getPropertyNameSet()
      Lists the PropertyNames found so far; useful when dealing with cpath expressions involving namespace informaiton.
    • getAttributeNames

      public String[] getAttributeNames()
      Array of attribute names found (so far).
      Returns:
      an array of the attribute names found so far during the visit
    • clear

      public void clear()
      Resets the attributes found so that a new attribute search can be performed
    • visit

      public Object visit(PropertyName expression, Object data)
      Specified by:
      visit in interface ExpressionVisitor
      Overrides:
      visit in class DefaultFilterVisitor
    • visit

      public Object visit(Function expression, Object data)
      Specified by:
      visit in interface ExpressionVisitor
      Overrides:
      visit in class DefaultFilterVisitor
    • isConstantExpression

      public boolean isConstantExpression()
      Returns true if the last visited expression is a constant, that is, does not depend on any attribute and does not use any VolatileFunction
    • isUsingDynamincProperties

      public boolean isUsingDynamincProperties()
      Returns true if the expression is using dynamic property names, so a static analysis of the expression won't be able to return all the properties in use