com.mapinfo.midev.feature.impl

## Class FeatureCollection

- java.lang.Object
- - com.mapinfo.midev.feature.impl.FeatureCollection

All Implemented Interfaces:
  IFeatureCollection, Serializable

    public class FeatureCollection
    extends Object
    implements IFeatureCollection

Feature collection implementation that stores and manages features in memory.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`FeatureCollection(IFeatureMetadata featureMetadata)` Constructs a feature collection with the supplied data.
`FeatureCollection(String description, IFeatureMetadata featureMetadata)` Constructs a feature collection with the supplied data.
`FeatureCollection(String description, IFeatureMetadata featureMetadata, Collection names, Metadata metadata)` Constructs a feature collection with the supplied data.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `add(IFeature feature)` Adds the specified feature to this feature collection or throws an UnsupportedOperationException if this feature collection does not support adding a feature.
`void` `clear()` Removes all features from this feature collection.
`IFeature` `get(int index)` Returns the feature at the specified index.
`long` `getCount()` Returns the number of features in this collection.
`Metadata` `getCustomMetadata()` Contains additional metadata associated with the feature collection.
`String` `getDescription()` Contains a textual description of the feature collection.
`IFeatureCollectionMetadata` `getMetadata()` Accesses the metadata that describes this feature collection.
`Collection` `getNames()` A collection of names used to identify the feature collection.
`boolean` `isReadOnly()` Indicates if the feature collection is read only.
`boolean` `isTransient()` Indicates if this `IFeatureCollection` is transient.
`IFeatureIterator` `iterator()` Returns an iterator for accessing each of the `IFeature` instances contained within this feature collection.
`void` `remove(IFeature feature)` Removes the specified feature from this collection.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface com.mapinfo.midev.feature.IFeatureCollection

`addAll, removeAll`

### Constructor Detail

#### FeatureCollection

    public FeatureCollection(String description,
                             IFeatureMetadata featureMetadata,
                             Collection names,
                             Metadata metadata)

Constructs a feature collection with the supplied data.

Parameters:
  `description` - Description for the IFeatureCollectionMetadata.
  `featureMetadata` - Feature metadata for features in this collection.
  `names` - Names collection for the IFeatureCollectionMetadata.
  `metadata` - Additional metadata associated with IFeatureCollectionMetadata.

#### FeatureCollection

    public FeatureCollection(String description,
                             IFeatureMetadata featureMetadata)

Constructs a feature collection with the supplied data.

Parameters:
  `description` - Description for the IFeatureCollectionMetadata.
  `featureMetadata` - Feature metadata for features in this collection.

#### FeatureCollection

    public FeatureCollection(IFeatureMetadata featureMetadata)

Constructs a feature collection with the supplied data.

Parameters:
  `featureMetadata` - Feature metadata for features in this collection.

### Method Detail

#### getNames

    public Collection getNames()

A collection of names used to identify the feature collection. A feature may have several names, typically assigned by different authorities. The interface places no restrictions on the structure, meaning or uniqueness of names associated with a feature collection.

Returns:
  a collection of `String`s containing the names. The value may be an empty collection if no names are defined but will not return null.

#### getDescription

    public String getDescription()

Contains a textual description of the feature collection. This property may be null if no description is available.

Returns:
  a textual description of the feature collection.

#### getCustomMetadata

    public Metadata getCustomMetadata()

Contains additional metadata associated with the feature collection. This metadata may be used by the implementation for various purposes or may be used to identify/tag the feature collection for other purposes.

Returns:
  the metadata collection associated with this feature collection. This property should not return null. If no metadata is defined, the collection should be empty.

#### getCount

    public long getCount()

Returns the number of features in this collection.

Returns:
  the number of features in this collection.

#### get

    public IFeature get(int index)

Returns the feature at the specified index.

Parameters:
  `index` - The index of the feature to be returned.
Returns:
  the feature at the specified index.

#### isReadOnly

    public boolean isReadOnly()

Description copied from interface: `IFeatureCollection`
Indicates if the feature collection is read only.

Refer to the Read Only Properties and Determination section of the package summary for more comprehensive coverage.

Specified by:
  `isReadOnly` in interface `IFeatureCollection`
Returns:
  `true` if this feature collection denies edits; `false` otherwise.

#### iterator

    public IFeatureIterator iterator()

Description copied from interface: `IFeatureCollection`
Returns an iterator for accessing each of the `IFeature` instances contained within this feature collection.

Feature collections that are backed by database management system or other data access technology may have to build and execute a SQL statement such as "Select * From ..." to provide access to the features. If this is the case, it is important to always dispose of the IFeatureIterator. Refer to the `IFeatureIterator.dispose()` documentation for more details.

Specified by:
  `iterator` in interface `IFeatureCollection`
Returns:
  an iterator for accessing the features in this feature collection.

#### isTransient

    public boolean isTransient()

Description copied from interface: `IFeatureCollection`
Indicates if this `IFeatureCollection` is transient. An instance of `IFeatureCollection` may have a lifetime that is controlled by an iterator, cursor, or other entity. A typical occurrence of transient features occurs when searching a database table. The feature iterator used to return the data in the result set returns `IFeatureCollection` instances whose data is connected to the memory of the cursor. When the next feature is accessed, the same memory is reused, thus making the previous feature invalid. These features are said to be transient.

There is no guarantee that repositioning a cursor returns the same feature each time, however, even if different feature instances are returned, the previous feature instance should be assumed to be invalid and cannot be accessed.

Transient does not have any relationship to the editability of the data. Features, feature collections, and tables may be edited even if they are designated as transient. Transient simply refers to the lifetime of the `IFeatureCollection` and whether or not its memory may be reclaimed or reused as the result of some other action such as advancing an iterator or cursor.

Specified by:
  `isTransient` in interface `IFeatureCollection`
Returns:
  `true` if this feature is transient; false otherwise.

#### getMetadata

    public IFeatureCollectionMetadata getMetadata()

Accesses the metadata that describes this feature collection. This implementation of IFeatureCollectionMetadata re-calculates the envelope on each call to getEnvelope().

Specified by:
  `getMetadata` in interface `IFeatureCollection`
Returns:
  An instance of `IFeatureCollectionMetadata`.
See Also:
  `IFeatureCollectionMetadata.getEnvelope(String)`

#### add

    public void add(IFeature feature)

Description copied from interface: `IFeatureCollection`
Adds the specified feature to this feature collection or throws an UnsupportedOperationException if this feature collection does not support adding a feature.

The default implementation throws an UnsupportedOperationException.

Specified by:
  `add` in interface `IFeatureCollection`
Parameters:
  `feature` - the feature to add to this feature collection.

#### remove

    public void remove(IFeature feature)

Description copied from interface: `IFeatureCollection`
Removes the specified feature from this collection. Membership in a feature collection is implementation specific. Therefore, removing a feature from a collection may also have implementation specific behavior, particularly as it relates to identifying the feature to remove. Some feature collection implementations may locate the feature using a reference comparison while other implementations may simply build a database DELETE statement using the feature's identifier as a key.

The default implementation throws an UnsupportedOperationException.

Specified by:
  `remove` in interface `IFeatureCollection`
Parameters:
  `feature` - the feature to remove from the collection.

#### clear

    public void clear()

Description copied from interface: `IFeatureCollection`
Removes all features from this feature collection. The semantics of this operation are implementation dependent. Some feature collection implementations hold onto references to feature objects while others, such as client-side representations of server-based tables, persist features to and from the data store.

Clearing a feature collection may physically remove all of the data in the collection. For feature collections that are client side representations of physical data stored in a server, file, web service, or other data store, this operation is similar to issuing a "DELETE FROM table" command with no where-clause.

The default implementation throws an UnsupportedOperationException.

Specified by:
  `clear` in interface `IFeatureCollection`