org.geotools.data.store
Class FilteringFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>

java.lang.Object
  extended by org.geotools.feature.collection.DecoratingFeatureCollection<T,F>
      extended by org.geotools.data.store.FilteringFeatureCollection<T,F>
All Implemented Interfaces:
FeatureCollection<T,F>

public class FilteringFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
extends DecoratingFeatureCollection<T,F>

Decorates a feature collection with one that filters content.

Author:
Justin Deoliveira, The Open Planning Project

Constructor Summary
FilteringFeatureCollection(FeatureCollection<T,F> delegate, org.opengis.filter.Filter filter)
           
 
Method Summary
 boolean add(F o)
          Add object to this collection.
 boolean addAll(java.util.Collection c)
          Add all the objects to the collection.
 void close(FeatureIterator<F> close)
          Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.
 void close(java.util.Iterator<F> close)
          Clean up after any resources associated with this itterator in a manner similar to JDO collections.
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 FeatureIterator<F> features()
          Obtain a FeatureIterator of the Features within this collection.
 ReferencedEnvelope getBounds()
          Get the total bounds of this collection which is calculated by doing a union of the bounds of each feature inside of it
 boolean isEmpty()
           
 java.util.Iterator<F> iterator()
          An iterator over this collection, which must be closed after use.
 FeatureReader<T,F> reader()
           
 int size()
           
 FeatureCollection<T,F> sort(org.opengis.filter.sort.SortBy order)
          collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo")
 FeatureCollection<T,F> subCollection(org.opengis.filter.Filter filter)
          FeatureCollection "view" indicated by provided filter.
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 
Methods inherited from class org.geotools.feature.collection.DecoratingFeatureCollection
accepts, accepts, addAll, addListener, clear, equals, getID, getSchema, hashCode, purge, remove, removeAll, removeListener, retainAll
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteringFeatureCollection

public FilteringFeatureCollection(FeatureCollection<T,F> delegate,
                                  org.opengis.filter.Filter filter)
Method Detail

features

public FeatureIterator<F> features()
Description copied from interface: FeatureCollection
Obtain a FeatureIterator of the Features within this collection.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

This is almost equivalent to:

  • a Type-Safe call to: getAttribute(getFeatureType().getAttributeType(0).getName()).iterator();.
  • A Java 5:Iterator<Feature>

Example (safe) use:

 FeatureIterator iterator=collection.features();
 try {
     while( iterator.hasNext()  ){
          Feature feature = iterator.next();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

GML Note: The contents of this iterator are considered to be defined by featureMember tags (and/or the single allowed FeatureMembers tag). Please see getFeatureType for more details.

Specified by:
features in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
features in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Returns:
A FeatureIterator.

close

public void close(FeatureIterator<F> close)
Description copied from interface: FeatureCollection
Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     for( Iterator i=collection.iterator(); i.hasNext();){
          Feature feature = i.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
close in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
close in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>

iterator

public java.util.Iterator<F> iterator()
Description copied from interface: FeatureCollection
An iterator over this collection, which must be closed after use.

Collection is not guaranteed to be ordered in any manner.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     while( iterator.hasNext();){
          Feature feature = (Feature) iterator.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
iterator in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
iterator in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Returns:
Iterator

close

public void close(java.util.Iterator<F> close)
Description copied from interface: FeatureCollection
Clean up after any resources associated with this itterator in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     for( Iterator i=collection.iterator(); i.hasNext();){
          Feature feature = (Feature) i.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
close in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
close in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>

subCollection

public FeatureCollection<T,F> subCollection(org.opengis.filter.Filter filter)
Description copied from interface: FeatureCollection
FeatureCollection "view" indicated by provided filter.

The contents of the returned FeatureCollection are determined by applying the provider Filter to the entire contents of this FeatureCollection. The result is "live" and modifications will be shared.

This method is used cut down on the number of filter based methods required for a useful FeatureCollection construct. The FeatureCollections returned really should be considered as a temporary "view" used to control the range of a removeAll, or modify operation.

Example Use:


 collection.subCollection( filter ).clear();
 
The above recommended use is agreement with the Collections API precident of List.subList( start, end ).

The results of subCollection:

  • are to be considered unordered
  • may be an ordered FeatureList if requested when sortBy is indicated

Specified by:
subCollection in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
subCollection in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Returns:
FeatureCollection identified as subset.
See Also:
FeatureList

sort

public FeatureCollection<T,F> sort(org.opengis.filter.sort.SortBy order)
Description copied from interface: FeatureCollection
collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo")

Specified by:
sort in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
sort in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Returns:
FeatureCollection sorted in the indicated order

size

public int size()
Specified by:
size in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
size in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.size()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
isEmpty in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.isEmpty()

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
toArray in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.toArray()

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Specified by:
toArray in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
toArray in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.toArray(Object[])

add

public boolean add(F o)
Description copied from interface: FeatureCollection
Add object to this collection.

This method is often not impelmented for collections produced as the result of a query.

Specified by:
add in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
add in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Returns:
true of the element was added
See Also:
Collection.add(Object)

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
contains in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.contains(Object)

addAll

public boolean addAll(java.util.Collection c)
Description copied from interface: FeatureCollection
Add all the objects to the collection.

This method is often not implemented for collections produced as the results of a query.

Specified by:
addAll in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
addAll in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.addAll(Collection)

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
containsAll in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
See Also:
Collection.containsAll(Collection)

reader

public FeatureReader<T,F> reader()
                                                                                                           throws java.io.IOException
Throws:
java.io.IOException

getBounds

public ReferencedEnvelope getBounds()
Description copied from interface: FeatureCollection
Get the total bounds of this collection which is calculated by doing a union of the bounds of each feature inside of it

Specified by:
getBounds in interface FeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Overrides:
getBounds in class DecoratingFeatureCollection<T extends org.opengis.feature.type.FeatureType,F extends org.opengis.feature.Feature>
Returns:
An Envelope containing the total bounds of this collection.


Copyright © 1996-2010 Geotools. All Rights Reserved.