org.geotools.data.memory
Class MemoryFeatureCollection

Object
  extended by AbstractFeatureCollection
      extended by MemoryFeatureCollection
All Implemented Interfaces:
RandomFeatureAccess, FeatureCollection<SimpleFeatureType,SimpleFeature>

public class MemoryFeatureCollection
extends AbstractFeatureCollection
implements RandomFeatureAccess

Implement a FeatureCollection by burning memory!

Contents are maintained in a sorted TreeMap by FID, this serves as a reference implementation when exploring the FeatureCollection api.

This is similar to DefaultFeatureCollection, although additional methods are supported and test cases have been written. Unlike DefaultFeatureCollection the type information must be known at construction time.

Author:
Jody Garnett, Refractions Research
Module:

Field Summary
 
Fields inherited from class AbstractFeatureCollection
id, listeners, open, schema
 
Constructor Summary
MemoryFeatureCollection(SimpleFeatureType schema)
           
 
Method Summary
 boolean add(SimpleFeature o)
          Implement to support modification.
 void closeIterator(Iterator close)
          Please override to cleanup after your own iterators, and any used resources.
 SimpleFeature getFeatureMember(String id)
          Access Feature content by feature id.
 Iterator openIterator()
          Open a resource based Iterator, we will call close( iterator ).
 SimpleFeature removeFeatureMember(String id)
          Optional Method
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class AbstractFeatureCollection
accepts, accepts, addAll, addAll, addListener, clear, close, close, contains, containsAll, features, getBounds, getID, getOpenIterators, getSchema, isEmpty, iterator, purge, remove, removeAll, removeListener, retainAll, sort, subCollection, subList, toArray, toArray
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FeatureCollection
accepts, addAll, addAll, addListener, clear, close, close, contains, containsAll, features, getBounds, getID, getSchema, isEmpty, iterator, purge, remove, removeAll, removeListener, retainAll, sort, subCollection, toArray, toArray
 

Constructor Detail

MemoryFeatureCollection

public MemoryFeatureCollection(SimpleFeatureType schema)
Method Detail

add

public boolean add(SimpleFeature o)
Description copied from class: AbstractFeatureCollection
Implement to support modification.

Specified by:
add in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
add in class AbstractFeatureCollection
Parameters:
o - element whose presence in this collection is to be ensured.
Returns:
true if the collection changed as a result of the call.
See Also:
Collection.add(Object)

size

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

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

openIterator

public Iterator openIterator()
Description copied from class: AbstractFeatureCollection
Open a resource based Iterator, we will call close( iterator ).

Please subclass to provide your own iterator for the the ResourceCollection, note iterator() is implemented to call open() and track the results in for later purge().

Specified by:
openIterator in class AbstractFeatureCollection
Returns:
Iterator based on resource use

closeIterator

public void closeIterator(Iterator close)
Description copied from class: AbstractFeatureCollection
Please override to cleanup after your own iterators, and any used resources.

As an example if the iterator was working off a File then the inputstream should be closed.

Subclass must call super.close( close ) to allow the list of open iterators to be adjusted.

Specified by:
closeIterator in class AbstractFeatureCollection
Parameters:
close - Iterator, will not be null

getFeatureMember

public SimpleFeature getFeatureMember(String id)
                               throws NoSuchElementException
Description copied from interface: RandomFeatureAccess
Access Feature content by feature id.

Specified by:
getFeatureMember in interface RandomFeatureAccess
Returns:
Feature with the indicated or id
Throws:
NoSuchElementException - if a Feature with the indicated id is not present

removeFeatureMember

public SimpleFeature removeFeatureMember(String id)
Description copied from interface: RandomFeatureAccess
Optional Method

Specified by:
removeFeatureMember in interface RandomFeatureAccess


Copyright © 1996-2009 Geotools. All Rights Reserved.