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 boolean
add(SimpleFeature o)
boolean
addAll(Collection<? extends SimpleFeature> c)
void
clear()
ReferencedEnvelope
getBounds()
Calculates the bounds of the features without caching.SimpleFeature
getFeatureMember(String id)
Access Feature content by feature id.MemoryFeatureCollection.MemoryIterator
openIterator()
Factory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()
andAbstractFeatureCollection.features()
.boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
SimpleFeature
removeFeatureMember(String id)
Optional Methodboolean
retainAll(Collection<?> c)
int
size()
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:
add
in interfaceCollection<SimpleFeature>
-
size
public int size()
Description copied from class:AbstractFeatureCollection
Returns the number of elements in this collection.- Specified by:
size
in interfaceCollection<SimpleFeature>
- Specified by:
size
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Specified by:
size
in classAbstractFeatureCollection
- Returns:
- Number of items, or Interger.MAX_VALUE
- See Also:
Collection.size()
-
openIterator
public MemoryFeatureCollection.MemoryIterator openIterator()
Description copied from class:AbstractFeatureCollection
Factory 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:
openIterator
in classAbstractFeatureCollection
- Returns:
- Iterator over collection contents
-
getFeatureMember
public SimpleFeature getFeatureMember(String id) throws NoSuchElementException
Description copied from interface:RandomFeatureAccess
Access Feature content by feature id.- Specified by:
getFeatureMember
in 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:RandomFeatureAccess
Optional Method- Specified by:
removeFeatureMember
in interfaceRandomFeatureAccess
-
getBounds
public ReferencedEnvelope getBounds()
Calculates the bounds of the features without caching.- Specified by:
getBounds
in interfaceFeatureCollection<SimpleFeatureType,SimpleFeature>
- Specified by:
getBounds
in classAbstractFeatureCollection
- Returns:
- An Envelope containing the total bounds of this collection.
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<SimpleFeature>
-
addAll
public boolean addAll(Collection<? extends SimpleFeature> c)
- Specified by:
addAll
in interfaceCollection<SimpleFeature>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<SimpleFeature>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<SimpleFeature>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<SimpleFeature>
-
-