org.geotools.data.memory
Class MemoryFeatureCollection
java.lang.Object
org.geotools.feature.collection.AbstractFeatureCollection
org.geotools.data.memory.MemoryFeatureCollection
- All Implemented Interfaces:
- RandomFeatureAccess, FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.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
Method Summary |
boolean |
add(org.opengis.feature.simple.SimpleFeature o)
Implement to support modification. |
void |
closeIterator(java.util.Iterator close)
Please override to cleanup after your own iterators, and
any used resources. |
ReferencedEnvelope |
getBounds()
Calculates the bounds of the features without caching. |
org.opengis.feature.simple.SimpleFeature |
getFeatureMember(java.lang.String id)
Access Feature content by feature id. |
java.util.Iterator |
openIterator()
Open a resource based Iterator, we will call close( iterator ). |
org.opengis.feature.simple.SimpleFeature |
removeFeatureMember(java.lang.String id)
Optional Method |
int |
size()
Returns the number of elements in this collection. |
Methods inherited from class org.geotools.feature.collection.AbstractFeatureCollection |
accepts, accepts, addAll, addAll, addListener, clear, close, close, contains, containsAll, features, getID, getOpenIterators, getSchema, isEmpty, iterator, purge, remove, removeAll, removeListener, retainAll, sort, subCollection, subList, toArray, toArray |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.geotools.feature.FeatureCollection |
accepts, addAll, addAll, addListener, clear, close, close, contains, containsAll, features, getID, getSchema, isEmpty, iterator, purge, remove, removeAll, removeListener, retainAll, sort, subCollection, toArray, toArray |
MemoryFeatureCollection
public MemoryFeatureCollection(org.opengis.feature.simple.SimpleFeatureType schema)
add
public boolean add(org.opengis.feature.simple.SimpleFeature o)
- Description copied from class:
AbstractFeatureCollection
- Implement to support modification.
- Specified by:
add
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
- Specified by:
size
in class AbstractFeatureCollection
- Returns:
- Number of items, or Interger.MAX_VALUE
- See Also:
Collection.size()
openIterator
public java.util.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(java.util.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 org.opengis.feature.simple.SimpleFeature getFeatureMember(java.lang.String id)
throws java.util.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:
java.util.NoSuchElementException
- if a Feature with the indicated id is not present
removeFeatureMember
public org.opengis.feature.simple.SimpleFeature removeFeatureMember(java.lang.String id)
- Description copied from interface:
RandomFeatureAccess
- Optional Method
- Specified by:
removeFeatureMember
in interface RandomFeatureAccess
getBounds
public ReferencedEnvelope getBounds()
- Calculates the bounds of the features without caching.
- Specified by:
getBounds
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
- Overrides:
getBounds
in class AbstractFeatureCollection
- Returns:
- An Envelope containing the total bounds of this collection.
Copyright © 1996-2010 Geotools. All Rights Reserved.