org.geotools.filter
Class CompareFilterImpl

Object
  extended by FilterAbstract
      extended by AbstractFilter
          extended by BinaryComparisonAbstract
              extended by CompareFilterImpl
All Implemented Interfaces:
CompareFilter, FilterType, BinaryComparisonOperator, Filter
Direct Known Subclasses:
BetweenFilterImpl, IsBetweenImpl, IsEqualsToImpl, IsGreaterThanImpl, IsGreaterThanOrEqualToImpl, IsLessThenImpl, IsLessThenOrEqualToImpl, IsNotEqualToImpl, IsNullImpl

public abstract class CompareFilterImpl
extends BinaryComparisonAbstract
implements CompareFilter

Defines a comparison filter (can be a math comparison or generic equals). This filter implements a comparison - of some sort - between two expressions. The comparison may be a math comparison or a generic equals comparison. If it is a math comparison, only math expressions are allowed; if it is an equals comparison, any expression types are allowed. Note that this comparison does not attempt to restrict its expressions to be meaningful. This means that it considers itself a valid filter as long as the expression comparison returns a valid result. It does no checking to see whether or not the expression comparison is meaningful with regard to checking feature attributes. In other words, this is a valid filter: 52 = 92, even though it will always return the same result and could be simplified away. It is up the the filter creator, therefore, to attempt to simplify/make meaningful filter logic.

Author:
Rob Hranac, Vision for New York
Module:
modules/library/main (gt-main.jar)

Field Summary
 
Fields inherited from class BinaryComparisonAbstract
expression1, expression2
 
Fields inherited from class AbstractFilter
filterType, permissiveConstruction
 
Fields inherited from class FilterAbstract
factory
 
Fields inherited from interface Filter
ALL, NONE
 
Fields inherited from interface FilterType
BETWEEN, COMPARE_EQUALS, COMPARE_GREATER_THAN, COMPARE_GREATER_THAN_EQUAL, COMPARE_LESS_THAN, COMPARE_LESS_THAN_EQUAL, COMPARE_NOT_EQUALS, FID, GEOMETRY_BBOX, GEOMETRY_BEYOND, GEOMETRY_CONTAINS, GEOMETRY_CROSSES, GEOMETRY_DISJOINT, GEOMETRY_DWITHIN, GEOMETRY_EQUALS, GEOMETRY_INTERSECTS, GEOMETRY_OVERLAPS, GEOMETRY_TOUCHES, GEOMETRY_WITHIN, LIKE, LOGIC_AND, LOGIC_NOT, LOGIC_OR, NULL
 
Fields inherited from interface Filter
EXCLUDE, INCLUDE
 
Fields inherited from interface Filter
EXCLUDE, INCLUDE
 
Constructor Summary
protected CompareFilterImpl(FilterFactory factory, Expression e1, Expression e2)
           
protected CompareFilterImpl(FilterFactory factory, Expression e1, Expression e2, boolean matchCase)
           
protected CompareFilterImpl(short filterType)
          Deprecated. use CompareFilterImpl(org.opengis.filter.FilterFactory, org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)
 
Method Summary
abstract  Object accept(FilterVisitor visitor, Object extraData)
          Used by FilterVisitors to perform some action on this filter instance.
 void addLeftValue(Expression leftValue)
          Adds the 'left' value to this filter.
 void addRightValue(Expression rightValue)
          Adds the 'right' value to this filter.
protected  int compare(Comparable leftObj, Comparable rightObj)
          Subclass convenience method which compares to instances of comparables in a pretty lax way, converting types among String, Number, Double when appropriate.
 boolean equals(Object obj)
          Compares this filter to the specified object.
 boolean evaluate(SimpleFeature feature)
          Determines whether or not a given feature is 'inside' this filter.
 Expression getLeftValue()
          Gets the left expression.
 Expression getRightValue()
          Deprecated. use BinaryComparisonAbstract.getExpression2()
 int hashCode()
          Override of hashCode method.
 void setExpression1(Expression leftValue)
           
 void setExpression2(Expression rightValue)
           
 String toString()
          Returns a string representation of this filter.
 
Methods inherited from class BinaryComparisonAbstract
and, comparable, eval, getExpression1, getExpression2, isMatchingCase, not, or
 
Methods inherited from class AbstractFilter
accept, contains, getFilterType, isCompareFilter, isGeometryDistanceFilter, isGeometryFilter, isLogicFilter, isMathFilter, isSimpleFilter
 
Methods inherited from class FilterAbstract
accepts, eval, eval, eval
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface CompareFilter
contains
 
Methods inherited from interface Filter
accept, and, getFilterType, not, or
 
Methods inherited from interface Filter
evaluate
 
Methods inherited from interface BinaryComparisonOperator
getExpression1, getExpression2, isMatchingCase
 
Methods inherited from interface Filter
evaluate
 

Constructor Detail

CompareFilterImpl

protected CompareFilterImpl(short filterType)
                     throws IllegalFilterException
Deprecated. use CompareFilterImpl(org.opengis.filter.FilterFactory, org.opengis.filter.expression.Expression, org.opengis.filter.expression.Expression)

Constructor with filter type.

Parameters:
filterType - The type of comparison.
Throws:
IllegalFilterException - Non-compare type.

CompareFilterImpl

protected CompareFilterImpl(FilterFactory factory,
                            Expression e1,
                            Expression e2)

CompareFilterImpl

protected CompareFilterImpl(FilterFactory factory,
                            Expression e1,
                            Expression e2,
                            boolean matchCase)
Method Detail

addLeftValue

public final void addLeftValue(Expression leftValue)
                        throws IllegalFilterException
Adds the 'left' value to this filter.

Specified by:
addLeftValue in interface CompareFilter
Parameters:
leftValue - Expression for 'left' value.
Throws:
IllegalFilterException - Filter is not internally consistent.
TODO:
REVISIT: immutability?

setExpression1

public void setExpression1(Expression leftValue)
Overrides:
setExpression1 in class BinaryComparisonAbstract

addRightValue

public final void addRightValue(Expression rightValue)
                         throws IllegalFilterException
Adds the 'right' value to this filter.

Specified by:
addRightValue in interface CompareFilter
Parameters:
rightValue - Expression for 'right' value.
Throws:
IllegalFilterException - Filter is not internally consistent.
TODO:
REVISIT: make immutable.

setExpression2

public void setExpression2(Expression rightValue)
Overrides:
setExpression2 in class BinaryComparisonAbstract

getLeftValue

public final Expression getLeftValue()
Gets the left expression.

Specified by:
getLeftValue in interface CompareFilter
Returns:
The expression on the left of the comparison. * @deprecated use BinaryComparisonAbstract.getExpression1()

getRightValue

public final Expression getRightValue()
Deprecated. use BinaryComparisonAbstract.getExpression2()

Gets the right expression.

Specified by:
getRightValue in interface CompareFilter
Returns:
The expression on the right of the comparison.

evaluate

public boolean evaluate(SimpleFeature feature)
Determines whether or not a given feature is 'inside' this filter.

Overrides:
evaluate in class FilterAbstract
Parameters:
feature - Specified feature to examine.
Returns:
Flag confirming whether or not this feature is inside the filter.

compare

protected int compare(Comparable leftObj,
                      Comparable rightObj)
Subclass convenience method which compares to instances of comparables in a pretty lax way, converting types among String, Number, Double when appropriate.

Returns:
same contract as Comparable.compareTo(java.lang.Object).

toString

public String toString()
Returns a string representation of this filter.

Overrides:
toString in class Object
Returns:
String representation of the compare filter.

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 filter. Checks to make sure the filter types are the same as well as both of the values.

Overrides:
equals in class Object
Parameters:
obj - - the object to compare this CompareFilter against.
Returns:
true if specified object is equal to this filter; false otherwise.

hashCode

public int hashCode()
Override of hashCode method.

Overrides:
hashCode in class Object
Returns:
a code to hash this object by.

accept

public abstract Object accept(FilterVisitor 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 Filter
Overrides:
accept in class FilterAbstract
Parameters:
visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);


Copyright © 1996-2010 Geotools. All Rights Reserved.