Class DataFeatureCollection
- All Implemented Interfaces:
SimpleFeatureCollection
,FeatureCollection<SimpleFeatureType,
SimpleFeature>
- Direct Known Subclasses:
CompositeFeatureCollection
,DefaultFeatureResults
,EmptyFeatureCollection
,IndexedFeatureResults
This implementation requires you to implement the following:
- getSchema() - this should match reader.getSchema()
- reader() features() - override one of these two method to access content
- getBounds()
- getCount()
- collection()
This class will implement the 'extra' methods required by FeatureCollection for you (in simple terms based on the FeatureResults API). Anything that is often customised is available to you as a constructor parameters.
Enjoy.
- Since:
- 2.1.RC0
- Author:
- jgarnett
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
id used when serialized to gmlprotected List<CollectionListener>
listenersprotected SimpleFeatureType
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Collection based on a generic collectionprotected
Collection based on a generic collectionprotected
DataFeatureCollection
(String id, SimpleFeatureType memberType) Subclass must think about what consitructors it needs. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accepts
(FeatureVisitor visitor, ProgressListener progress) Visit the contents of a feature collection.boolean
add
(SimpleFeature arg0) boolean
addAll
(Collection collection) Optimized implementation of addAll that recognizes the use of collections obtained with subCollection( filter ).boolean
addAll
(FeatureCollection resource) final void
addListener
(CollectionListener listener) void
clear()
final void
close
(Iterator<SimpleFeature> close) void
close
(FeatureIterator<SimpleFeature> iterator) protected void
closeIterator
(Iterator<SimpleFeature> close) boolean
boolean
containsAll
(Collection<?> collection) features()
SimpleFeatureIterator is entirely based on iterator().protected void
fireChange
(Collection coll, int type) protected void
fireChange
(SimpleFeature[] features, int type) To let listeners know that something has changed.protected void
fireChange
(SimpleFeature feature, int type) abstract ReferencedEnvelope
Get the total bounds of this collection which is calculated by doing a union of the bounds of each feature inside of itabstract int
getCount()
getID()
ID used when serializing to GMLThe schema for the child feature members of this collection.boolean
isEmpty()
Default implementation based on creating an reader, testing hasNext, and closing.final Iterator<SimpleFeature>
iterator()
Iterator may (or may) not support modification.protected Iterator<SimpleFeature>
Returns a FeatureWriterIterator, or FeatureReaderIterator over content.void
purge()
reader()
boolean
boolean
removeAll
(Collection arg0) final void
removeListener
(CollectionListener listener) boolean
retainAll
(Collection arg0) int
size()
Default implementation based on getCount() - this may be expensiveConstruct a sorted view of this content.subCollection
(Filter filter) Will return an optimized subCollection based on access to the origional FeatureSource.Object[]
toArray()
<T> T[]
toArray
(T[] array) protected FeatureWriter<SimpleFeatureType,
SimpleFeature> writer()
Subclass may provide an implementation of this method to indicate that read/write support is provided.
-
Field Details
-
listeners
listeners -
id
id used when serialized to gml -
schema
-
-
Constructor Details
-
DataFeatureCollection
protected DataFeatureCollection()Collection based on a generic collection -
DataFeatureCollection
Collection based on a generic collection -
DataFeatureCollection
Subclass must think about what consitructors it needs.
-
-
Method Details
-
fireChange
To let listeners know that something has changed. -
fireChange
-
fireChange
-
reader
- Throws:
IOException
-
getBounds
Description copied from interface:FeatureCollection
Get the total bounds of this collection which is calculated by doing a union of the bounds of each feature inside of it- Specified by:
getBounds
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Returns:
- An Envelope containing the total bounds of this collection.
-
getCount
- Throws:
IOException
-
writer
Subclass may provide an implementation of this method to indicate that read/write support is provided.All operations that attempt to modify the "data" will use this method, allowing them to throw an "UnsupportedOperationException" in the same manner as Collections.unmodifiableCollection(Collection c), or just return null.
- Returns:
- the writer, or null if write support is not available
- Throws:
UnsupportedOperationException
- To indicate that write support is not avaiableIOException
-
features
SimpleFeatureIterator is entirely based on iterator().So when we implement FeatureCollection.iterator() this will work out of the box.
- Specified by:
features
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Specified by:
features
in interfaceSimpleFeatureCollection
- Returns:
- A FeatureIterator.
-
iterator
Iterator may (or may) not support modification. -
openIterator
Returns a FeatureWriterIterator, or FeatureReaderIterator over content.If you have a way to tell that you are readonly please subclass with a less hardcore check - this implementations catches a UnsupportedOpperationsException from wrtier()!
- Returns:
- Iterator, should be closed closeIterator
- Throws:
IOException
-
close
-
closeIterator
- Throws:
IOException
-
close
-
size
public int size()Default implementation based on getCount() - this may be expensive- Specified by:
size
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - See Also:
-
purge
public void purge() -
isEmpty
public boolean isEmpty()Default implementation based on creating an reader, testing hasNext, and closing.For once the Collections API does not give us an escape route, we *have* to check the data.
- Specified by:
isEmpty
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Returns:
- true if this collection contains no features
-
contains
- Specified by:
contains
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - See Also:
-
toArray
- Specified by:
toArray
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - See Also:
-
toArray
public <T> T[] toArray(T[] array) - Specified by:
toArray
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - See Also:
-
add
-
remove
-
containsAll
- Specified by:
containsAll
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - See Also:
-
addAll
Optimized implementation of addAll that recognizes the use of collections obtained with subCollection( filter ).This method is constructed by either:
- Filter OR
- Removing an extact match of Filter AND
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear() -
accepts
Description copied from interface:FeatureCollection
Visit the contents of a feature collection.The order of traversal is dependent on the FeatureCollection implementation; some collections are able to make efficient use of an internal index in order to quickly visit features located in the same region.
- Specified by:
accepts
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Parameters:
visitor
- Closure applied to each feature in turn.progress
- Used to report progress, may be used to interrupt the operation- Throws:
IOException
-
subCollection
Will return an optimized subCollection based on access to the origional FeatureSource.The subCollection is constructed by using an AND Filter. For the converse of this opperation please see collection.addAll( Collection ), it has been optimized to be aware of these filter based SubCollections.
This method is intended in a manner similar to subList, example use:
collection.subCollection( myFilter ).clear()
- Specified by:
subCollection
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Specified by:
subCollection
in interfaceSimpleFeatureCollection
- Parameters:
filter
- Filter used to determine sub collection.- Returns:
- SimpleFeatureCollection identified as subset.
- Since:
- GeoTools 2.2, Filter 1.1
- See Also:
-
FeatureList
-
sort
Construct a sorted view of this content.Sorts may be combined togther in a stable fashion, in congruence with the Filter 1.1 specification. This method should also be able to handle GeoTools specific sorting through detecting order as a SortBy2 instance.
- Specified by:
sort
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Specified by:
sort
in interfaceSimpleFeatureCollection
- Parameters:
order
- Sort order- Returns:
- FeatureList sorted according to provided order
- Since:
- GeoTools 2.2, Filter 1.1
-
getID
Description copied from interface:FeatureCollection
ID used when serializing to GML- Specified by:
getID
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature>
-
addListener
- Throws:
NullPointerException
-
removeListener
- Throws:
NullPointerException
-
getSchema
Description copied from interface:FeatureCollection
The schema for the child feature members of this collection.Represents the most general FeatureType in common to all the features in this collection.
- For a collection backed by a shapefiles (or database tables) the FeatureType returned by getSchema() will complete describe each and every child in the collection.
- For mixed content FeatureCollections you will need to check the FeatureType of each Feature as it is retrived from the collection
- The degenerate case returns the "_Feature" FeatureType, where the only thing known is that the contents are Features.
- Specified by:
getSchema
in interfaceFeatureCollection<SimpleFeatureType,
SimpleFeature> - Returns:
- FeatureType describing the "common" schema to all child features of this collection
-