|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectDataFeatureCollection
public abstract class DataFeatureCollection
A starting point for implementing FeatureCollection's backed onto a FeatureReader.
This implementation requires you to implement the following:
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.
Field Summary | |
---|---|
protected String |
id
id used when serialized to gml |
protected List |
listeners
listeners |
protected SimpleFeatureType |
schema
|
Constructor Summary | |
---|---|
protected |
DataFeatureCollection()
Collection based on a generic collection |
protected |
DataFeatureCollection(String id)
Collection based on a generic collection |
protected |
DataFeatureCollection(String id,
SimpleFeatureType memberType)
Subclass must think about what consitructors it needs. |
Method Summary | |
---|---|
void |
accepts(FeatureVisitor visitor,
ProgressListener progress)
Visit the contents of a feature collection. |
void |
accepts(FeatureVisitor visitor,
ProgressListener progress)
|
boolean |
add(SimpleFeature arg0)
Add object to this collection. |
boolean |
addAll(Collection collection)
Optimized implementation of addAll that recognizes the use of collections obtained with subCollection( filter ). |
boolean |
addAll(FeatureCollection resource)
|
void |
addListener(CollectionListener listener)
Adds a listener for collection events. |
void |
clear()
|
void |
close(FeatureIterator<SimpleFeature> iterator)
Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections. |
void |
close(Iterator<SimpleFeature> close)
Clean up after any resources associated with this itterator in a manner similar to JDO collections. |
protected void |
closeIterator(Iterator<SimpleFeature> close)
|
boolean |
contains(Object o)
|
boolean |
containsAll(Collection<?> collection)
|
FeatureIterator<SimpleFeature> |
features()
FeatureIterator |
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 |
getBounds()
Get the total bounds of this collection which is calculated by doing a union of the bounds of each feature inside of it |
abstract int |
getCount()
|
String |
getID()
ID used when serializing to GML |
SimpleFeatureType |
getSchema()
The schema for the child features of this collection. |
boolean |
isEmpty()
Default implementation based on creating an reader, testing hasNext, and closing. |
Iterator<SimpleFeature> |
iterator()
Iterator may (or may) not support modification. |
protected Iterator<SimpleFeature> |
openIterator()
Returns a FeatureWriterIterator, or FeatureReaderIterator over content. |
void |
purge()
Close any outstanding resources released by this resources. |
FeatureReader<SimpleFeatureType,SimpleFeature> |
reader()
|
boolean |
remove(Object arg0)
|
boolean |
removeAll(Collection arg0)
|
void |
removeListener(CollectionListener listener)
Removes a listener for collection events. |
boolean |
retainAll(Collection arg0)
|
int |
size()
Default implementation based on getCount() - this may be expensive |
FeatureCollection<SimpleFeatureType,SimpleFeature> |
sort(SortBy order)
Construct a sorted view of this content. |
FeatureCollection<SimpleFeatureType,SimpleFeature> |
sort(SortBy2 order)
Allows for "Advanced" sort capabilities specific to the GeoTools platform! |
FeatureCollection<SimpleFeatureType,SimpleFeature> |
subCollection(Filter filter)
Will return an optimized subCollection based on access to the origional FeatureSource. |
Object[] |
toArray()
|
Object[] |
toArray(Object[] array)
|
protected FeatureWriter<SimpleFeatureType,SimpleFeature> |
writer()
Subclass may provide an implementation of this method to indicate that read/write support is provided. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected List listeners
protected String id
protected SimpleFeatureType schema
Constructor Detail |
---|
protected DataFeatureCollection()
protected DataFeatureCollection(String id)
protected DataFeatureCollection(String id, SimpleFeatureType memberType)
Method Detail |
---|
protected void fireChange(SimpleFeature[] features, int type)
protected void fireChange(SimpleFeature feature, int type)
protected void fireChange(Collection coll, int type)
public FeatureReader<SimpleFeatureType,SimpleFeature> reader() throws IOException
IOException
public abstract ReferencedEnvelope getBounds()
FeatureCollection
getBounds
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
public abstract int getCount() throws IOException
IOException
protected FeatureWriter<SimpleFeatureType,SimpleFeature> writer() throws IOException
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)
UnsupportedOperationException
- To indicate that write support is not avaiable
IOException
public FeatureIterator<SimpleFeature> features()
So when we implement FeatureCollection.iterator() this will work out of the box.
features
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
public final Iterator<SimpleFeature> iterator()
iterator
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
protected Iterator<SimpleFeature> openIterator() throws IOException
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()!
IOException
public final void close(Iterator<SimpleFeature> close)
FeatureCollection
Iterator iterator = collection.iterator();
try {
for( Iterator i=collection.iterator(); i.hasNext();){
Feature feature = (Feature) i.hasNext();
System.out.println( feature.getID() );
}
}
finally {
collection.close( iterator );
}
close
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
protected void closeIterator(Iterator<SimpleFeature> close) throws IOException
IOException
public void close(FeatureIterator<SimpleFeature> iterator)
FeatureCollection
Iterator iterator = collection.iterator();
try {
for( Iterator i=collection.iterator(); i.hasNext();){
Feature feature = i.hasNext();
System.out.println( feature.getID() );
}
}
finally {
collection.close( iterator );
}
close
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
public int size()
size
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.size()
public void purge()
FeatureCollection
This method should be used with great caution, it is however available to allow the use of the ResourceCollection with algorthims that are unaware of the need to close iterators after use.
Example of using a normal Collections utility method:
Collections.sort( collection );
collection.purge();
purge
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
public boolean isEmpty()
For once the Collections API does not give us an escape route, we *have* to check the data.
isEmpty
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.isEmpty()
public boolean contains(Object o)
contains
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.contains(Object)
public Object[] toArray()
toArray
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.toArray()
public Object[] toArray(Object[] array)
toArray
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.toArray(Object[])
public boolean add(SimpleFeature arg0)
FeatureCollection
This method is often not impelmented for collections produced as the result of a query.
add
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.add(Object)
public boolean remove(Object arg0)
remove
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.remove(Object)
public boolean containsAll(Collection<?> collection)
containsAll
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.containsAll(Collection)
public boolean addAll(Collection collection)
This method is constructed by either:
addAll
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.addAll(Collection)
public boolean addAll(FeatureCollection resource)
addAll
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
FeatureCollection.addAll(Collection)
public boolean removeAll(Collection arg0)
removeAll
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.removeAll(Collection)
public boolean retainAll(Collection arg0)
retainAll
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.retainAll(Collection)
public void clear()
clear
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Collection.clear()
public void accepts(FeatureVisitor visitor, ProgressListener progress)
FeatureCollection
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.
accepts
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
visitor
- Closure applied to each feature in turn.progress
- Used to report progress, may be used to interrupt the operationpublic FeatureCollection<SimpleFeatureType,SimpleFeature> subCollection(Filter filter)
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()
subCollection
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
filter
- Filter used to determine sub collection.
FeatureList
public FeatureCollection<SimpleFeatureType,SimpleFeature> sort(SortBy order)
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.
sort
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
order
-
public FeatureCollection<SimpleFeatureType,SimpleFeature> sort(SortBy2 order)
Advanced in this case really means making use of a generic Expression, rather then being limited to PropertyName.
order
- GeoTools SortBy
public String getID()
FeatureCollection
getID
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
public final void addListener(CollectionListener listener) throws NullPointerException
FeatureCollection
When this collection is backed by live data the event notification will follow the guidelines outlined by FeatureListner.
addListener
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
listener
- The listener to add
NullPointerException
- If the listener is null.public final void removeListener(CollectionListener listener) throws NullPointerException
FeatureCollection
removeListener
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
listener
- The listener to remove
NullPointerException
- If the listener is null.public final void accepts(FeatureVisitor visitor, ProgressListener progress) throws IOException
IOException
public SimpleFeatureType getSchema()
FeatureCollection
There is a difference between getFeatureType() and getSchema()represents the LCD FeatureType that best represents the contents of this collection.
The method getSchema() is named for compatability with the geotools 2.0 API. In the Geotools 2.2 time frame we should be able to replace this method with a careful check of getFeatureType() and its attributes.
getSchema
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |