## org.opengis.feature
Interface FeatureCollection

All Superinterfaces:
  Attribute, ComplexAttribute, Feature, Property

All Known Subinterfaces:
  DataFeatureCollection, SimpleFeatureCollection

    @XmlElement(value="FeatureCollection")
    public interface FeatureCollection

extends Feature

Represents a FeatureCollection (explicitly a Collection<Feature>.

Note the "attributes" available in a FeatureCollection are to be considered a derrived quality based on the contents (or members) of the collection. An "empty" FeatureCollection should not exist.

Implementations and client code should adhere to the rules set forth by `Collection`. That is, some methods are optional to implement, and may throw an `UnsupportedOperationException`.

Since:
  GeoAPI 2.0
Version:
  GeoAPI 2.1
See Also:
  `Collection`

Method Summary
`void` `accepts(FeatureVisitor visitor, ProgressListener progress)` Will visit the contents of the feature collection.
`void` `close(Iterator<Feature> iterator)` You are required to close iterators after use.
`FeatureCollectionType` `getType()` Restricted to return a FeatureCollectionType.
`Iterator<Feature>` `iterator()` Access contents of this collection, you are required to close iterators after use.
`Collection<FeatureType>` `memberTypes()` Convenience method for obtaining the collection of member types in which members of this collection may implement.
`FeatureCollection` `sort(SortBy order)` A sorted "view" of this collection in the order indicated.
`FeatureCollection` `subCollection(Filter filter)` FeatureCollection "view" indicated by provided filter.

Methods inherited from interface Feature
`getBounds, getCRS, getDefaultGeometry, getID, getUserData, putUserData, setCRS, setDefaultGeometry`

Methods inherited from interface ComplexAttribute
`associations, attributes, get, getDescriptor, getValue, setValue`

Methods inherited from interface Attribute
`nillable, operation, setValue`

Methods inherited from interface Property
`descriptor, name`

Method Detail

### getType

    FeatureCollectionType getType()

  Restricted to return a FeatureCollectionType.

  Specified by:
    `getType` in interface `Attribute`
  Specified by:
    `getType` in interface `ComplexAttribute`
  Specified by:
    `getType` in interface `Feature`
  Specified by:
    `getType` in interface `Property`
  Returns:
    AttributeType information describing allowable content

### iterator

    Iterator<Feature> iterator()

  Access contents of this collection, you are required to close iterators after use.

  Two points to using iterator successfully:

  - FeatureCollections are often backed by resource use and the iterators must be passed to FeatureCollection.close( Iterator ) after use. This is a requirement over an beyond that imposed by the Java Collections API, it does represent a common solution seen in other Java libraries. <lil>The Feature returned by `next()` is only "valid" until the call to `next()` is made.

  ### Common Problems The first common mistake is trying to store Features obtained from an iterator. This is a mistake as you may get the same instance returned each time with different content and fid). The solution is to store the IDs in a Set and and use a Feature ID Filter to produce the needed collection.

  Please note you will be limited to a single worker thread to access an iterator, this is a consequence of a feature only being valid until next is called. For an alternative please use visitor. Conversly plit you request into sections with one for each worker thread.

  ### XPath Conventions Conventions for XPath Access: the contents of a GML collection are represented by either featureMember or featureMembers. When interpretting an XPath expression, you should consider this function to visit both elements for you.

  XPath Mapping:

  - Preferred:`featureMember/*`
  - Legal:`featureMembers`

  Returns:
    Iterator over the contents of this feature collection.

### close

    void close(Iterator<Feature> iterator)

  You are required to close iterators after use.

  Many FeatureCollections are backed by IO resources that need to be returned to the opperating system after use.

### subCollection

    FeatureCollection subCollection(Filter filter)

  FeatureCollection "view" indicated by provided filter.

  The contents of the returned FeatureCollection are determined by applying the provider Fitler to the entire contents of this FeatureCollection. The result is "live" aqnd 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 ).removeAll();

  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

  Parameters:
    `filter` -
  Returns:
    FeatureCollection identified as subset.
  See Also:
    `FeatureList`

### sort

    FeatureCollection sort(SortBy order)

  A sorted "view" of this collection in the order indicated.

  Parameters:
    `order` -
  Returns:
    FeatureList in requested order

### memberTypes

    Collection<FeatureType> memberTypes()

  Convenience method for obtaining the collection of member types in which members of this collection may implement.

  Equivalent to calling the following:

                      getType().getMemberTypes()

### accepts

    void accepts(FeatureVisitor visitor,
                 ProgressListener progress)

  Will visit the contents of the feature collection.

  Parameters:
    `visitor` -
  Throws:
    `IOException`
  See Also:
    `For more comparison with iterator based access`

Copyright © 1994-2008 Open Geospatial Consortium. All Rights Reserved.