Class AttributeExpressionImpl

All Implemented Interfaces:
Expression, PropertyName
Direct Known Subclasses:
JdbcMultipleValue, JoinPropertyName, NestedAttributeExpression

public class AttributeExpressionImpl extends DefaultExpression implements PropertyName
Defines a complex filter (could also be called logical filter). This filter holds one or more filters together and relates them logically in an internally defined manner.
Author:
Rob Hranac, TOPP
  • Field Details

    • attPath

      protected String attPath
      Holds all sub filters of this filter.
    • schema

      protected SimpleFeatureType schema
      Used to validate attribute references to ensure they match the provided schema
    • namespaceSupport

      public NamespaceSupport namespaceSupport
      NamespaceSupport used to defining the prefix information for the xpath expression
    • lenient

      protected boolean lenient
      Configures whether evaluate should return null if it cannot find a working property accessor, rather than throwing an exception (default behaviour).
  • Constructor Details

    • AttributeExpressionImpl

      protected AttributeExpressionImpl(SimpleFeatureType schema)
      Constructor with the schema for this attribute.
      Parameters:
      schema - The schema for this attribute.
    • AttributeExpressionImpl

      public AttributeExpressionImpl(String xpath)
      Constructor with schema and path to the attribute.
      Parameters:
      xpath - the String xpath to the attribute.
    • AttributeExpressionImpl

      public AttributeExpressionImpl(Name name)
      Constructor with full attribute name.
      Parameters:
      name - Attribute Name.
    • AttributeExpressionImpl

      public AttributeExpressionImpl(String xpath, NamespaceSupport namespaceContext)
      Constructor with schema and path to the attribute.
      Parameters:
      xpath - the String xpath to the attribute.
      namespaceContext - Defining the prefix information for the xpath expression
    • AttributeExpressionImpl

      public AttributeExpressionImpl(String xpath, Hints hints)
      Parameters:
      xpath - xpath expression
      hints - Hints passed to the property accessor during evaulation
    • AttributeExpressionImpl

      protected AttributeExpressionImpl(SimpleFeatureType schema, String attPath) throws IllegalFilterException
      Constructor with schema and path to the attribute.
      Parameters:
      schema - The initial (required) sub filter.
      attPath - the xpath to the attribute.
      Throws:
      IllegalFilterException - If the attribute path is not in the schema.
  • Method Details

    • getNamespaceContext

      public NamespaceSupport getNamespaceContext()
      Description copied from interface: PropertyName
      Returns namespace context information, or null if unavailable/inapplicable
      Specified by:
      getNamespaceContext in interface PropertyName
      Returns:
      namespace context information, or null if unavailable/inapplicable
    • getPropertyName

      public String getPropertyName()
      Gets the path to the attribute to be evaluated by this expression.

      PropertyName.getPropertyName()

      Specified by:
      getPropertyName in interface PropertyName
    • setPropertyName

      public void setPropertyName(String attPath)
    • evaluate

      public Object evaluate(Object obj)
      Gets the value of this property from the passed object.
      Specified by:
      evaluate in interface Expression
      Overrides:
      evaluate in class ExpressionAbstract
      Parameters:
      obj - Object from which we need to extract a property value.
      Returns:
      default implementation returns null
    • evaluate

      public <T> T evaluate(Object obj, Class<T> target)
      Gets the value of this attribute from the passed object.
      Specified by:
      evaluate in interface Expression
      Overrides:
      evaluate in class ExpressionAbstract
      Type Parameters:
      T - The type of the returned object.
      Parameters:
      obj - Object from which to extract attribute value.
      target - Target Class
      Returns:
      Evaluates the given expression based on the content of the given object an an instance of context.
    • toString

      public String toString()
      Return this expression as a string.
      Overrides:
      toString in class Object
      Returns:
      String representation of this attribute expression.
    • equals

      public boolean equals(Object obj)
      Compares this filter to the specified object. Returns true if the passed in object is the same as this expression. Checks to make sure the expression types are the same as well as the attribute paths and schemas.
      Overrides:
      equals in class Object
      Parameters:
      obj - - the object to compare this ExpressionAttribute against.
      Returns:
      true if specified object is equal to this filter; else false
    • hashCode

      public int hashCode()
      Override of hashCode method.
      Overrides:
      hashCode in class Object
      Returns:
      a code to hash this object by.
    • accept

      public Object accept(ExpressionVisitor visitor, Object extraData)
      Used by FilterVisitors to perform some action on this filter instance. Typicaly used by Filter decoders, but may also be used by any thing which needs infomration from filter structure. Implementations should always call: visitor.visit(this); It is importatant that this is not left to a parent class unless the parents API is identical.
      Specified by:
      accept in interface Expression
      Parameters:
      visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);
    • setLenient

      public void setLenient(boolean lenient)
      Sets lenient property.
    • isLenient

      public boolean isLenient()
      Gets lenient property
      Returns:
      lenient