Class ListFeatureCollection
- All Implemented Interfaces:
Iterable<SimpleFeature>,Collection<SimpleFeature>,SimpleFeatureCollection,FeatureCollection<SimpleFeatureType,SimpleFeature>
This implementation wraps around a java.util.List and is suitable for quickly getting something on screen.
Usage notes:
- This implementation does not use a spatial index, please do not expect spatial operations to be fast.
- FeatureCollections are not allowed to have duplicates
This implementation is intended to quickly wrap up a list of features and get them on screen; as such it respects various hints about the copying of internal content as provided by the renderer.
- Author:
- Oliver Gottwald, Jody
- See Also:
-
Hints#FEATURE_DETACHED
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ReferencedEnvelopeCached boundsprotected List<SimpleFeature>wrapped list of features containing the contentsFields inherited from class AbstractFeatureCollection
id, schema -
Constructor Summary
ConstructorsConstructorDescriptionCreate a ListFeatureCollection for the provided schema An ArrayList is used internally.ListFeatureCollection(SimpleFeatureType schema, List<SimpleFeature> list) Create a ListFeatureCollection around the provided list.ListFeatureCollection(SimpleFeatureType schema, SimpleFeature... array) Create a ListFeatureCollection around the provided array.Create a ListFeatureCollection around the provided list. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(SimpleFeature f) booleanaddAll(Collection<? extends SimpleFeature> c) protected ReferencedEnvelopeCalculate bounds from featuresvoidclear()features()Obtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.Subclasses need to override this.booleanisEmpty()Returns true if this feature collection contains no features.protected Iterator<SimpleFeature>Factory method used to open an iterator over collection contents for use byAbstractFeatureCollection.iterator()andAbstractFeatureCollection.features().booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Returns the number of elements in this collection.Obtained sorted contents.subCollection(Filter filter) SimpleFeatureCollection "view" indicated by provided filter.Methods inherited from class AbstractFeatureCollection
accepts, contains, containsAll, getID, getSchema, iterator, 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, iterator, parallelStream, removeIf, spliterator, stream, toArray, toArray, toArray
-
Field Details
-
list
wrapped list of features containing the contents -
bounds
Cached bounds
-
-
Constructor Details
-
ListFeatureCollection
Create a ListFeatureCollection for the provided schema An ArrayList is used internally. -
ListFeatureCollection
Create a ListFeatureCollection around the provided list. The contents of the list should all be of the provided schema for this to make sense. Please keep in mind the feature collection constraints, no two Features in the list should have the same feature id, and you should not insert the same feature more then once.The provided list is directly used for storage, most feature collection operations just use a simple iterator so there is no performance advantaged to be gained over using an ArrayList vs a LinkedList (other then for the size() method of course).
-
ListFeatureCollection
Create a ListFeatureCollection around the provided array. The contents of the array should all be of the provided schema for this to make sense. Please keep in mind the feature collection constraints, no two Features in the list should have the same feature id, and you should not insert the same feature more then once.The provided array is directly used with a
CopyOnWriteArrayListfor storage. -
ListFeatureCollection
Create a ListFeatureCollection around the provided list. The contents of the list should all be of the provided schema for this to make sense. Please keep in mind the feature collection control, no two Features in the list should have the same feature id, and you should not insert the same feature more then once.The provided list is directly used for storage, most feature collection operations just use a simple iterator so there is no performance advantaged to be gained over using an ArrayList vs a LinkedList (other then for the size() method of course).
- Throws:
IOException
-
-
Method Details
-
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
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
-
add
- Specified by:
addin interfaceCollection<SimpleFeature>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<SimpleFeature>
-
features
Description copied from interface:SimpleFeatureCollectionObtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.The implementation of FeatureIterator must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections) the
SimpleFeatureIterator.close()method must be called.Example use:
SimpleFeatureIterator iterator=collection.features(); try { while( iterator.hasNext() ){ SimpleFeature feature = iterator.next(); System.out.println( feature.getID() ); } } finally { iterator.close(); }- Specified by:
featuresin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature> - Specified by:
featuresin interfaceSimpleFeatureCollection- Overrides:
featuresin classAbstractFeatureCollection- Returns:
- A FeatureIterator.
-
getBounds
Description copied from class:AbstractFeatureCollectionSubclasses need to override this.- Specified by:
getBoundsin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature> - Specified by:
getBoundsin classAbstractFeatureCollection- Returns:
- An Envelope containing the total bounds of this collection.
-
calculateBounds
Calculate bounds from features -
isEmpty
public boolean isEmpty()Description copied from interface:FeatureCollectionReturns true if this feature collection contains no features.- Specified by:
isEmptyin interfaceCollection<SimpleFeature>- Specified by:
isEmptyin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature> - Overrides:
isEmptyin classAbstractFeatureCollection- Returns:
- true if this collection contains no elements.
-
subCollection
Description copied from interface:FeatureCollectionSimpleFeatureCollection "view" indicated by provided filter.The contents of the returned SimpleFeatureCollection are determined by applying the provider Filter to the entire contents of this FeatureCollection. The result is "live" and modifications will be shared.
This method is used cut down on the number of filter based methods required for a useful SimpleFeatureCollection construct. The FeatureCollections returned really should be considered as a temporary "view" used to control the range of a removeAll, or modify operation.
Example Use:
The above recommended use is agreement with the Collections API precident of List.subList( start, end ).collection.subCollection( filter ).clear();The results of subCollection:
- are to be considered unordered
- may be an ordered FeatureList if requested when sortBy is indicated
- Specified by:
subCollectionin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature> - Specified by:
subCollectionin interfaceSimpleFeatureCollection- Overrides:
subCollectionin classAbstractFeatureCollection- Returns:
- SimpleFeatureCollection identified as subset.
- See Also:
-
FeatureList
-
sort
Description copied from interface:FeatureCollectionObtained sorted contents.This method may not be supported by all implementations, consider the use of FeatureSource.features( Query ).
- Specified by:
sortin interfaceFeatureCollection<SimpleFeatureType,SimpleFeature> - Specified by:
sortin interfaceSimpleFeatureCollection- Overrides:
sortin classAbstractFeatureCollection- Parameters:
order- Sort order- Returns:
- FeatureCollection sorted in the indicated order
-
remove
- Specified by:
removein interfaceCollection<SimpleFeature>
-
addAll
- Specified by:
addAllin interfaceCollection<SimpleFeature>
-
removeAll
- Specified by:
removeAllin interfaceCollection<SimpleFeature>
-
retainAll
- Specified by:
retainAllin interfaceCollection<SimpleFeature>
-