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 TypeMethodDescriptionbooleanadd(SimpleFeature o) booleanaddAll(Collection<? extends SimpleFeature> c) voidclear()Calculates the bounds of the features without caching.Access Feature content by feature id.MemoryFeatureCollection.MemoryIteratorFactory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()andAbstractFeatureCollection.features().booleanbooleanremoveAll(Collection<?> c) 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, toArrayMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArrayMethods inherited from interface FeatureCollection
accepts, contains, containsAll, getID, getSchema, isEmpty, toArray, toArrayMethods inherited from interface SimpleFeatureCollection
features, sort, subCollection
-
Constructor Details
-
MemoryFeatureCollection
-
-
Method Details
-
add
- 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:
-
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
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
Description copied from interface:RandomFeatureAccessOptional Method- Specified by:
removeFeatureMemberin interfaceRandomFeatureAccess
-
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
- Specified by:
removein interfaceCollection<SimpleFeature>
-
addAll
- Specified by:
addAllin interfaceCollection<SimpleFeature>
-
removeAll
- Specified by:
removeAllin interfaceCollection<SimpleFeature>
-
retainAll
- Specified by:
retainAllin interfaceCollection<SimpleFeature>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<SimpleFeature>
-