Package org.geotools.data.memory
Class MemoryFeatureCollection
- Object
-
- AbstractFeatureCollection
-
- MemoryFeatureCollection
-
- All Implemented Interfaces:
Iterable<SimpleFeature>,Collection<SimpleFeature>,SimpleFeatureCollection,RandomFeatureAccess,FeatureCollection<SimpleFeatureType,SimpleFeature>
public class MemoryFeatureCollection extends AbstractFeatureCollection implements RandomFeatureAccess, Collection<SimpleFeature>
Implement a SimpleFeatureCollection by burning memory!Contents are maintained in a sorted TreeMap by FID, this serves as a reference implementation when exploring the SimpleFeatureCollection 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
-
-
Field Summary
-
Fields inherited from class AbstractFeatureCollection
id, schema
-
-
Constructor Summary
Constructors Constructor Description MemoryFeatureCollection(SimpleFeatureType schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(SimpleFeature o)booleanaddAll(Collection<? extends SimpleFeature> c)voidclear()ReferencedEnvelopegetBounds()Calculates the bounds of the features without caching.SimpleFeaturegetFeatureMember(String id)Access Feature content by feature id.MemoryFeatureCollection.MemoryIteratoropenIterator()Factory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()andAbstractFeatureCollection.features().booleanremove(Object o)booleanremoveAll(Collection<?> c)SimpleFeatureremoveFeatureMember(String id)Optional MethodbooleanretainAll(Collection<?> c)intsize()Returns the number of elements in this collection.-
Methods inherited from class AbstractFeatureCollection
accepts, contains, containsAll, features, getID, getSchema, isEmpty, iterator, sort, subCollection, toArray, toArray
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Methods inherited from interface FeatureCollection
accepts, contains, containsAll, getID, getSchema, isEmpty, toArray, toArray
-
Methods inherited from interface SimpleFeatureCollection
features, sort, subCollection
-
-
-
-
Constructor Detail
-
MemoryFeatureCollection
public MemoryFeatureCollection(SimpleFeatureType schema)
-
-
Method Detail
-
add
public boolean add(SimpleFeature o)
- Specified by:
addin interfaceCollection<SimpleFeature>
-
size
public int size()
Description copied from class:AbstractFeatureCollectionReturns the number of elements in this collection.- Specified by:
sizein interfaceCollection<SimpleFeature>- Specified by:
sizein interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>- Specified by:
sizein classAbstractFeatureCollection- Returns:
- Number of items, or Interger.MAX_VALUE
- See Also:
Collection.size()
-
openIterator
public MemoryFeatureCollection.MemoryIterator openIterator()
Description copied from class:AbstractFeatureCollectionFactory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()andAbstractFeatureCollection.features().If you return an instance of FeatureIterator some effort is taken to call the
FeatureIterator.close()internally, however we cannot offer any assurance that client code usingAbstractFeatureCollection.iterator()will perform the same check.- Specified by:
openIteratorin classAbstractFeatureCollection- Returns:
- Iterator over collection contents
-
getFeatureMember
public SimpleFeature getFeatureMember(String id) throws NoSuchElementException
Description copied from interface:RandomFeatureAccessAccess Feature content by feature id.- Specified by:
getFeatureMemberin interfaceRandomFeatureAccess- 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:RandomFeatureAccessOptional Method- Specified by:
removeFeatureMemberin interfaceRandomFeatureAccess
-
getBounds
public ReferencedEnvelope getBounds()
Calculates the bounds of the features without caching.- Specified by:
getBoundsin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>- Specified by:
getBoundsin classAbstractFeatureCollection- Returns:
- An Envelope containing the total bounds of this collection.
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<SimpleFeature>
-
addAll
public boolean addAll(Collection<? extends SimpleFeature> c)
- Specified by:
addAllin interfaceCollection<SimpleFeature>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<SimpleFeature>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<SimpleFeature>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<SimpleFeature>
-
-