public class ListFeatureCollection extends AbstractFeatureCollection implements Collection<SimpleFeature>
This implementation wraps around a java.util.List and is suitable for quickly getting something on screen.
Usage notes:
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.
Hints#FEATURE_DETACHED
Modifier and Type | Field and Description |
---|---|
protected ReferencedEnvelope |
bounds
Cached bounds
|
protected List<SimpleFeature> |
list
wrapped list of features containing the contents
|
id, schema
Constructor and Description |
---|
ListFeatureCollection(SimpleFeatureCollection copy)
Create a ListFeatureCollection around the provided list.
|
ListFeatureCollection(SimpleFeatureType schema)
Create 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(SimpleFeature f) |
boolean |
addAll(Collection<? extends SimpleFeature> c) |
protected ReferencedEnvelope |
calculateBounds()
Calculate bounds from features
|
void |
clear() |
SimpleFeatureIterator |
features()
Obtain a SimpleFeatureIterator of the Features within this SimpleFeatureCollection.
|
ReferencedEnvelope |
getBounds()
Subclasses need to override this.
|
boolean |
isEmpty()
Returns true if this feature collection contains no features.
|
protected Iterator<SimpleFeature> |
openIterator()
Factory method used to open an iterator over collection contents for use by
AbstractFeatureCollection.iterator() and AbstractFeatureCollection.features() . |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size()
Returns the number of elements in this collection.
|
SimpleFeatureCollection |
sort(SortBy order)
Obtained sorted contents.
|
SimpleFeatureCollection |
subCollection(Filter filter)
SimpleFeatureCollection "view" indicated by provided filter.
|
accepts, contains, containsAll, getID, getSchema, iterator, toArray, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contains, containsAll, equals, hashCode, iterator, parallelStream, removeIf, spliterator, stream, toArray, toArray
protected List<SimpleFeature> list
protected ReferencedEnvelope bounds
public ListFeatureCollection(SimpleFeatureType schema)
schema
- public ListFeatureCollection(SimpleFeatureType schema, List<SimpleFeature> list)
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).
schema
- list
- public ListFeatureCollection(SimpleFeatureType schema, SimpleFeature[] array)
The provided array is directly used with a CopyOnWriteArrayList
for storage.
schema
- list
- public ListFeatureCollection(SimpleFeatureCollection copy) throws IOException
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).
schema
- list
- IOException
public int size()
AbstractFeatureCollection
size
in interface Collection<SimpleFeature>
size
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
size
in class AbstractFeatureCollection
Collection.size()
protected Iterator<SimpleFeature> openIterator()
AbstractFeatureCollection
AbstractFeatureCollection.iterator()
and AbstractFeatureCollection.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
using AbstractFeatureCollection.iterator()
will perform the same check.
openIterator
in class AbstractFeatureCollection
public boolean add(SimpleFeature f)
add
in interface Collection<SimpleFeature>
public void clear()
clear
in interface Collection<SimpleFeature>
public SimpleFeatureIterator features()
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();
}
features
in interface SimpleFeatureCollection
features
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
features
in class AbstractFeatureCollection
public ReferencedEnvelope getBounds()
AbstractFeatureCollection
getBounds
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
getBounds
in class AbstractFeatureCollection
protected ReferencedEnvelope calculateBounds()
public boolean isEmpty()
FeatureCollection
isEmpty
in interface Collection<SimpleFeature>
isEmpty
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
isEmpty
in class AbstractFeatureCollection
public SimpleFeatureCollection subCollection(Filter filter)
FeatureCollection
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:
collection.subCollection( filter ).clear();
The above recommended use is agreement with the Collections API precident of List.subList(
start, end ).
The results of subCollection:
subCollection
in interface SimpleFeatureCollection
subCollection
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
subCollection
in class AbstractFeatureCollection
FeatureList
public SimpleFeatureCollection sort(SortBy order)
FeatureCollection
This method may not be supported by all implementations, consider the use of FeatureSource.features( Query ).
sort
in interface SimpleFeatureCollection
sort
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
sort
in class AbstractFeatureCollection
order
- Sort orderpublic boolean remove(Object o)
remove
in interface Collection<SimpleFeature>
public boolean addAll(Collection<? extends SimpleFeature> c)
addAll
in interface Collection<SimpleFeature>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<SimpleFeature>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<SimpleFeature>
Copyright © 1996–2019 Geotools. All rights reserved.