org.geotools.data.simple
Interface SimpleFeatureCollection

All Superinterfaces:
FeatureCollection<SimpleFeatureType,SimpleFeature>
All Known Subinterfaces:
RandomFeatureAccess, XmlFeatureCollection
All Known Implementing Classes:
AbstractFeatureCollection, AdaptorFeatureCollection, ArcSdeFeatureCollection, CollectionFeatureSource.SubCollection, CompositeFeatureCollection, ContentFeatureCollection, DataFeatureCollection, DecoratingSimpleFeatureCollection, DefaultFeatureCollection, DefaultFeatureResults, EmptyFeatureCollection, FilteringSimpleFeatureCollection, ForceCoordinateSystemFeatureResults, GMLFeatureCollection, IndexedFeatureResults, ListFeatureCollection, MaxSimpleFeatureCollection, MemoryFeatureCollection, PreGeneralizedFeatureCollection, ReprojectFeatureResults, ReprojectingFeatureCollection, ReTypingFeatureCollection, SortedSimpleFeatureCollection, SpatialIndexFeatureCollection, SubFeatureCollection, SubFeatureList, TreeSetFeatureCollection, WFSFeatureSource.WFSFeatureResults

public interface SimpleFeatureCollection
extends FeatureCollection<SimpleFeatureType,SimpleFeature>

Access to "simple" Feature content where each feature has the same SimpleFeatureType.

Please keep in mind that a FeatureCollection is similar to a result set; and may not necessarily load everything in to memory. Treat each iterator as a forward only cursor in the JDBC sense; and take care to close iterators when not in use.


Method Summary
 SimpleFeatureIterator features()
          Obtain a FeatureIterator of the Features within this collection.
 SimpleFeatureCollection sort(SortBy order)
          Obtained sorted contents.
 SimpleFeatureCollection subCollection(Filter filter)
          SimpleFeatureCollection "view" indicated by provided filter.
 
Methods inherited from interface FeatureCollection
accepts, add, addAll, addAll, addListener, clear, close, close, contains, containsAll, getBounds, getID, getSchema, isEmpty, iterator, purge, remove, removeAll, removeListener, retainAll, size, toArray, toArray
 

Method Detail

features

SimpleFeatureIterator 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<SimpleFeatureType,SimpleFeature>
Returns:
A FeatureIterator.

subCollection

SimpleFeatureCollection subCollection(Filter filter)
Description copied from interface: FeatureCollection
SimpleFeatureCollection "view" indicated by provided filter.

The contents of the returned SimpleFeatureCollection 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 SimpleFeatureCollection 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:

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

sort

SimpleFeatureCollection sort(SortBy order)
Description copied from interface: FeatureCollection
Obtained sorted contents.

This method may not be supported by all implementations, consider the use of FeatureSource.features( Query ).

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


Copyright © 1996-2013 Geotools. All Rights Reserved.