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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(SimpleFeature o) boolean
addAll
(Collection<? extends SimpleFeature> c) void
clear()
Calculates the bounds of the features without caching.Access Feature content by feature id.MemoryFeatureCollection.MemoryIterator
Factory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()
andAbstractFeatureCollection.features()
.boolean
boolean
removeAll
(Collection<?> c) 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 Details
-
MemoryFeatureCollection
-
-
Method Details
-
add
- 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:
-
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
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
Description copied from interface:RandomFeatureAccess
Optional Method- Specified by:
removeFeatureMember
in interfaceRandomFeatureAccess
-
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
- Specified by:
remove
in interfaceCollection<SimpleFeature>
-
addAll
- Specified by:
addAll
in interfaceCollection<SimpleFeature>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<SimpleFeature>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<SimpleFeature>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<SimpleFeature>
-