org.geotools.feature.collection
Class SubFeatureCollection

Object
  extended by BaseFeatureCollection<SimpleFeatureType,SimpleFeature>
      extended by BaseSimpleFeatureCollection
          extended by SubFeatureCollection
All Implemented Interfaces:
SimpleFeatureCollection, FeatureCollection<SimpleFeatureType,SimpleFeature>
Direct Known Subclasses:
SubFeatureList

public class SubFeatureCollection
extends BaseSimpleFeatureCollection

Reasonable default implementation for subCollection making use of parent SimpleFeatureCollection.features() and provided Filter.

This is only a reasonable implementation and is not optimal. It is recommended that implementors construct a new Query and use SimpleFeatureSource.getFeatures(Query).

Author:
Jody Garnett, Refractions Research, Inc.

Field Summary
protected  SimpleFeatureCollection collection
          Original Collection
protected  FilterFactory ff
           
protected  Filter filter
          Filter
 
Fields inherited from class BaseFeatureCollection
id, schema
 
Constructor Summary
SubFeatureCollection(SimpleFeatureCollection collection)
           
SubFeatureCollection(SimpleFeatureCollection collection, Filter subfilter)
           
 
Method Summary
protected  Filter createFilter()
          Override to implement subsetting
 SimpleFeatureIterator features()
          Subclasses required to implement this method to traverse FeatureCollection contents.
protected  Filter filter()
          Generate filter to use for content, makes use of createFilter() if needed.
 ReferencedEnvelope getBounds()
          Calculates the bounds of the features without caching.
 String getID()
          ID used when serializing to GML
 int size()
          Returns the number of elements in this collection.
 SimpleFeatureCollection sort(SortBy order)
          Obtained sorted contents, only implemented for SimpleFeature at present.
 SimpleFeatureCollection subCollection(Filter filter)
          Convenience implementation that just wraps this collection into a FilteringFeatureCollection.
 
Methods inherited from class BaseFeatureCollection
accepts, contains, containsAll, getSchema, isEmpty, toArray, toArray
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FeatureCollection
accepts, contains, containsAll, getSchema, isEmpty, toArray, toArray
 

Field Detail

filter

protected Filter filter
Filter


collection

protected SimpleFeatureCollection collection
Original Collection


ff

protected FilterFactory ff
Constructor Detail

SubFeatureCollection

public SubFeatureCollection(SimpleFeatureCollection collection)

SubFeatureCollection

public SubFeatureCollection(SimpleFeatureCollection collection,
                            Filter subfilter)
Parameters:
collection - Collection or AbstractFeatureCollection
subfilter -
Method Detail

features

public SimpleFeatureIterator features()
Description copied from class: BaseSimpleFeatureCollection
Subclasses required to implement this method to traverse FeatureCollection contents.

Note that FeatureIterator.close() is available to clean up after any resource use required during traversal.

Specified by:
features in interface SimpleFeatureCollection
Specified by:
features in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Specified by:
features in class BaseSimpleFeatureCollection
Returns:
A FeatureIterator.

size

public int size()
Description copied from class: BaseFeatureCollection
Returns the number of elements in this collection.

Specified by:
size in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
size in class BaseFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
Number of items, or Interger.MAX_VALUE
See Also:
Collection.size()

filter

protected Filter filter()
Generate filter to use for content, makes use of createFilter() if needed.

Returns:
Filter to use for content

createFilter

protected Filter createFilter()
Override to implement subsetting


subCollection

public SimpleFeatureCollection subCollection(Filter filter)
Description copied from class: BaseFeatureCollection
Convenience implementation that just wraps this collection into a FilteringFeatureCollection. Subclasses might want to override this in case the filter can be cascaded to their data sources.

Specified by:
subCollection in interface SimpleFeatureCollection
Specified by:
subCollection in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
subCollection in class BaseSimpleFeatureCollection
Returns:
SimpleFeatureCollection identified as subset.
See Also:
FeatureList

sort

public SimpleFeatureCollection sort(SortBy order)
Description copied from class: BaseFeatureCollection
Obtained sorted contents, only implemented for SimpleFeature at present.

This method only supports SimpleFeature at present, consider use of FeatureSource.features( Query ).

Specified by:
sort in interface SimpleFeatureCollection
Specified by:
sort in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
sort in class BaseSimpleFeatureCollection
Parameters:
order - Sort order
Returns:
FeatureCollection sorted in the indicated order

getID

public String getID()
Description copied from interface: FeatureCollection
ID used when serializing to GML

Specified by:
getID in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
getID in class BaseFeatureCollection<SimpleFeatureType,SimpleFeature>

getBounds

public ReferencedEnvelope getBounds()
Calculates the bounds of the features without caching.

Specified by:
getBounds in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
getBounds in class BaseFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
An Envelope containing the total bounds of this collection.


Copyright © 1996-2014 Geotools. All Rights Reserved.