org.geotools.filter
Class AttributeExpressionImpl

Object
  extended by ExpressionAbstract
      extended by DefaultExpression
          extended by AttributeExpressionImpl
All Implemented Interfaces:
AttributeExpression, ExpressionType, Expression, PropertyName
Direct Known Subclasses:
JoinPropertyName, NestedAttributeExpression

public class AttributeExpressionImpl
extends DefaultExpression
implements AttributeExpression

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
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).
protected  SimpleFeatureType schema
          Used to validate attribute references to ensure they match the provided schema
 
Fields inherited from class DefaultExpression
expressionType, permissiveConstruction
 
Fields inherited from interface ExpressionType
ATTRIBUTE, ATTRIBUTE_DOUBLE, ATTRIBUTE_GEOMETRY, ATTRIBUTE_INTEGER, ATTRIBUTE_STRING, ATTRIBUTE_UNDECLARED, FUNCTION, LITERAL_DOUBLE, LITERAL_GEOMETRY, LITERAL_INTEGER, LITERAL_LONG, LITERAL_STRING, LITERAL_UNDECLARED, MATH_ADD, MATH_DIVIDE, MATH_MULTIPLY, MATH_SUBTRACT
 
Fields inherited from interface Expression
NIL
 
Constructor Summary
  AttributeExpressionImpl(Name name)
          Constructor with full attribute name.
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(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.
 
Method Summary
 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.
 Object evaluate(Object obj, Class target)
          Gets the value of this attribute from the passed object.
 Object evaluate(SimpleFeature feature)
          Gets the value of this attribute from the passed feature.
 String getAttributePath()
          Deprecated. use getPropertyName()
 NamespaceSupport getNamespaceContext()
          Returns namespace context information, or null if unavailable/inapplicable
 String getPropertyName()
          Gets the path to the attribute to be evaluated by this expression.
 int hashCode()
          Override of hashCode method.
 boolean isLenient()
          Gets lenient property
 void setAttributePath(String attPath)
          Deprecated. use setPropertyName(String)
 void setLenient(boolean lenient)
          Sets lenient property.
 void setPropertyName(String attPath)
           
 String toString()
          Return this expression as a string.
 
Methods inherited from class DefaultExpression
accept, getType, getValue, isAttributeExpression, isExpression, isFunctionExpression, isGeometryExpression, isLiteralExpression, isMathExpression, isMathExpression
 
Methods inherited from class ExpressionAbstract
eval, eval
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface AttributeExpression
getValue
 
Methods inherited from interface Expression
accept, getType
 

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


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 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 Detail

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

setAttributePath

public final void setAttributePath(String attPath)
                            throws IllegalFilterException
Deprecated. use setPropertyName(String)

Constructor with minimum dataset for a valid expression.

Specified by:
setAttributePath in interface AttributeExpression
Parameters:
attPath - The initial (required) sub filter.
Throws:
IllegalFilterException - If the attribute path is not in the schema.

getAttributePath

public final String getAttributePath()
Deprecated. use getPropertyName()

This method calls getPropertyName().

Specified by:
getAttributePath in interface AttributeExpression
Returns:
the attribute to be queried.

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(SimpleFeature feature)
Gets the value of this attribute from the passed feature.

Overrides:
evaluate in class DefaultExpression
Parameters:
feature - Feature from which to extract attribute value.
Returns:
The value of this expression based on the feature.

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 DefaultExpression
Parameters:
obj - Object from which we need to extract a property value.

evaluate

public Object evaluate(Object obj,
                       Class target)
Gets the value of this attribute from the passed object.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class ExpressionAbstract
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.

Parameters:
lenient -

isLenient

public boolean isLenient()
Gets lenient property

Returns:
lenient


Copyright © 1996-2014 Geotools. All Rights Reserved.