Package org.geotools.filter
Class AttributeExpressionImpl
- Object
-
- ExpressionAbstract
-
- DefaultExpression
-
- 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 Summary
Fields Modifier and Type Field Description protected String
attPath
Holds all sub filters of this filter.protected boolean
lenient
Configures whether evaluate should return null if it cannot find a working property accessor, rather than throwing an exception (default behaviour).NamespaceSupport
namespaceSupport
NamespaceSupport used to defining the prefix information for the xpath expressionprotected SimpleFeatureType
schema
Used to validate attribute references to ensure they match the provided schema-
Fields inherited from interface Expression
NIL
-
-
Constructor Summary
Constructors Modifier Constructor Description AttributeExpressionImpl(String xpath)
Constructor with schema and path to the attribute.AttributeExpressionImpl(String xpath, Hints hints)
AttributeExpressionImpl(String xpath, NamespaceSupport namespaceContext)
Constructor with schema and path to the attribute.protected
AttributeExpressionImpl(SimpleFeatureType schema)
Constructor with the schema for this attribute.protected
AttributeExpressionImpl(SimpleFeatureType schema, String attPath)
Constructor with schema and path to the attribute.AttributeExpressionImpl(Name name)
Constructor with full attribute name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
accept(ExpressionVisitor visitor, Object extraData)
Used by FilterVisitors to perform some action on this filter instance.boolean
equals(Object obj)
Compares this filter to the specified object.Object
evaluate(Object obj)
Gets the value of this property from the passed object.<T> T
evaluate(Object obj, Class<T> target)
Gets the value of this attribute from the passed object.NamespaceSupport
getNamespaceContext()
Returns namespace context information, or null if unavailable/inapplicableString
getPropertyName()
Gets the path to the attribute to be evaluated by this expression.int
hashCode()
Override of hashCode method.boolean
isLenient()
Gets lenient propertyvoid
setLenient(boolean lenient)
Sets lenient property.void
setPropertyName(String attPath)
String
toString()
Return this expression as a string.-
Methods inherited from class DefaultExpression
isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression
-
-
-
-
Field Detail
-
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 Detail
-
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 expressionhints
- 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 Detail
-
getNamespaceContext
public NamespaceSupport getNamespaceContext()
Description copied from interface:PropertyName
Returns namespace context information, or null if unavailable/inapplicable- Specified by:
getNamespaceContext
in interfacePropertyName
- 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.- Specified by:
getPropertyName
in interfacePropertyName
-
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 interfaceExpression
- Overrides:
evaluate
in classExpressionAbstract
- 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 interfaceExpression
- Overrides:
evaluate
in classExpressionAbstract
- 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.
-
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.
-
hashCode
public int hashCode()
Override of hashCode method.
-
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 interfaceExpression
- 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
-
-