org.geotools.filter
Class LogicFilterImpl

java.lang.Object
  extended byorg.geotools.filter.AbstractFilter
      extended byorg.geotools.filter.AbstractFilterImpl
          extended byorg.geotools.filter.LogicFilterImpl
All Implemented Interfaces:
Filter, FilterType, LogicFilter

public class LogicFilterImpl
extends AbstractFilterImpl
implements LogicFilter

Defines a logic filter (the only filter type that contains other filters). This filter holds one or more filters together and relates them logically with an internally defined type (AND, OR, NOT).

Version:
$Id: LogicFilterImpl.java,v 1.8 2003/08/11 18:48:25 cholmesny Exp $
Author:
Rob Hranac, TOPP

Field Summary
 
Fields inherited from class org.geotools.filter.AbstractFilter
filterType, permissiveConstruction
 
Fields inherited from interface org.geotools.filter.Filter
ALL, NONE
 
Fields inherited from interface org.geotools.filter.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
 
Constructor Summary
protected LogicFilterImpl(Filter filter1, Filter filter2, short filterType)
          Convenience constructor to create an AND/OR logic filter.
protected LogicFilterImpl(Filter filter, short filterType)
          Convenience constructor to create a NOT logic filter.
protected LogicFilterImpl(short filterType)
          Constructor with type (must be valid).
 
Method Summary
 void accept(FilterVisitor visitor)
          Used by FilterVisitors to perform some action on this filter instance.
 void addFilter(Filter filter)
          Adds a sub filter to this filter.
 Filter and(Filter filter)
          Implements a logical AND with this filter and returns the merged filter.
 boolean contains(Feature feature)
          Determines whether or not a given feature is 'inside' this filter.
 boolean equals(java.lang.Object obj)
          Compares this filter to the specified object.
 java.util.Iterator getFilterIterator()
          Gets an iterator for the filters held by this logic filter.
 int hashCode()
          Override of hashCode method.
 Filter not()
          Implements a logical NOT with this filter and returns the merged filter.
 Filter or(Filter filter)
          Implements a logical OR with this filter and returns the merged filter.
 java.lang.String toString()
          Returns a string representation of this filter.
 
Methods inherited from class org.geotools.filter.AbstractFilter
getFilterType, isCompareFilter, isGeometryDistanceFilter, isGeometryFilter, isLogicFilter, isMathFilter, isSimpleFilter
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.geotools.filter.Filter
getFilterType
 

Constructor Detail

LogicFilterImpl

protected LogicFilterImpl(short filterType)
                   throws IllegalFilterException
Constructor with type (must be valid).

Parameters:
filterType - The final relation between all sub filters.
Throws:
IllegalFilterException - If the filtertype is not a logic type.

LogicFilterImpl

protected LogicFilterImpl(Filter filter,
                          short filterType)
                   throws IllegalFilterException
Convenience constructor to create a NOT logic filter.

Parameters:
filter - The initial sub filter.
filterType - The final relation between all sub filters.
Throws:
IllegalFilterException - Does not conform to logic filter structure

LogicFilterImpl

protected LogicFilterImpl(Filter filter1,
                          Filter filter2,
                          short filterType)
                   throws IllegalFilterException
Convenience constructor to create an AND/OR logic filter.

Parameters:
filter1 - An initial sub filter.
filter2 - An initial sub filter.
filterType - The final relation between all sub filters.
Throws:
IllegalFilterException - Does not conform to logic filter structure
Method Detail

addFilter

public final void addFilter(Filter filter)
                     throws IllegalFilterException
Adds a sub filter to this filter.

Specified by:
addFilter in interface LogicFilter
Parameters:
filter - Specified filter to add to the sub filter list.
Throws:
IllegalFilterException - Does not conform to logic filter structure
Task:
REVISIT: make all filters immutable. This should return a new filter.

getFilterIterator

public java.util.Iterator getFilterIterator()
Gets an iterator for the filters held by this logic filter.

Specified by:
getFilterIterator in interface LogicFilter
Returns:
the iterator of the filters.

contains

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

Specified by:
contains in interface LogicFilter
Specified by:
contains in class AbstractFilter
Parameters:
feature - Specified feature to examine.
Returns:
Flag confirming whether or not this feature is inside the filter.

or

public Filter or(Filter filter)
Implements a logical OR with this filter and returns the merged filter.

Specified by:
or in interface LogicFilter
Overrides:
or in class AbstractFilterImpl
Parameters:
filter - Parent of the filter: must implement GMLHandlerGeometry.
Returns:
ORed filter.
Task:
REVISIT: make immutable, should not modify the subfilters of the filter being ored.

and

public Filter and(Filter filter)
Implements a logical AND with this filter and returns the merged filter.

Specified by:
and in interface LogicFilter
Overrides:
and in class AbstractFilterImpl
Parameters:
filter - Parent of the filter: must implement GMLHandlerGeometry.
Returns:
ANDed filter.
Task:
REVISIT: make immutable, should not modify the subfilters of the filter being anded.

not

public Filter not()
Implements a logical NOT with this filter and returns the merged filter.

Specified by:
not in interface LogicFilter
Overrides:
not in class AbstractFilterImpl
Returns:
NOTed filter.

toString

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

Returns:
String representation of the logic filter.

equals

public boolean equals(java.lang.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, and then checks that the subFilters lists are the same size and that one list contains the other. This means that logic filters with different internal orders of subfilters are equal.

Parameters:
obj - - the object to compare this LogicFilter against.
Returns:
true if specified object is equal to this filter; false otherwise.

hashCode

public int hashCode()
Override of hashCode method.

Returns:
a code to hash this object by.

accept

public void accept(FilterVisitor visitor)
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
Specified by:
accept in class AbstractFilter
Parameters:
visitor - The visitor which requires access to this filter, the method must call visitor.visit(this);


Copyright © GeoTools. All Rights Reserved.