|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAdaptorFeatureCollection
public abstract class AdaptorFeatureCollection
Implement a feature collection just based on provision of iterator.
You will need to implement the following methods:
| Field Summary | |
|---|---|
protected String |
id
id used when serialized to gml |
protected List |
listeners
listeners |
protected Set |
open
Set of open resource iterators |
protected SimpleFeatureType |
schema
|
| Constructor Summary | |
|---|---|
AdaptorFeatureCollection(String id,
SimpleFeatureType memberType)
|
|
| Method Summary | |
|---|---|
void |
accepts(FeatureVisitor visitor,
ProgressListener progress)
Accepts a visitor, which then visits each feature in the collection. |
boolean |
add(SimpleFeature o)
Implement to support modification. |
boolean |
addAll(Collection c)
Adds all of the elements in the specified collection to this collection (optional operation). |
boolean |
addAll(FeatureCollection c)
|
void |
addListener(CollectionListener listener)
Adds a listener for collection events. |
void |
clear()
Removes all of the elements from this collection (optional operation). |
void |
close(FeatureIterator<SimpleFeature> close)
Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections. |
void |
close(Iterator close)
Clean up after any resources assocaited with this iteartor in a manner similar to JDO collections. |
void |
close(SimpleFeatureIterator close)
|
protected abstract void |
closeIterator(Iterator<SimpleFeature> close)
Please override to cleanup after your own iterators, and any used resources. |
void |
closeIterator(SimpleFeatureIterator close)
|
boolean |
contains(Object o)
Returns true if this collection contains the specified element. |
boolean |
containsAll(Collection c)
Returns true if this collection contains all of the elements in the specified collection. |
SimpleFeatureIterator |
features()
Obtain a FeatureIterator |
ReferencedEnvelope |
getBounds()
Subclasses need to override this. |
String |
getID()
ID used when serializing to GML |
Set |
getOpenIterators()
Returns the set of open iterators. |
SimpleFeatureType |
getSchema()
The schema for the child feature members of this collection. |
boolean |
isEmpty()
|
Iterator<SimpleFeature> |
iterator()
Please implement! |
protected abstract Iterator<SimpleFeature> |
openIterator()
Open an Iterator, we will call close( iterator ). |
void |
purge()
Close any outstanding resources released by this resources. |
boolean |
remove(Object o)
Removes a single instance of the specified element from this collection, if it is present (optional operation). |
boolean |
removeAll(Collection c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation). |
void |
removeListener(CollectionListener listener)
Removes a listener for collection events. |
boolean |
retainAll(Collection c)
Retains only the elements in this collection that are contained in the specified collection (optional operation). |
abstract 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. |
SimpleFeatureCollection |
subList(Filter filter)
|
Object[] |
toArray()
Array of all the elements. |
Object[] |
toArray(Object[] a)
|
String |
toString()
Returns a string representation of this collection. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Set open
protected List listeners
protected String id
protected SimpleFeatureType schema
| Constructor Detail |
|---|
public AdaptorFeatureCollection(String id,
SimpleFeatureType memberType)
| Method Detail |
|---|
public SimpleFeatureIterator features()
FeatureCollection
The implementation of Collection must adhere to the rules of
fail-fast concurrent modification. In addition (to allow for
resource backed collections, the close( Iterator )
method must be called.
This is almost equivalent to:
getAttribute(getFeatureType().getAttributeType(0).getName()).iterator();.
Iterator<Feature>
FeatureIterator iterator=collection.features();
try {
while( iterator.hasNext() ){
Feature feature = iterator.next();
System.out.println( feature.getID() );
}
}
finally {
collection.close( iterator );
}
GML Note: The contents of this iterator are considered to be defined by featureMember tags (and/or the single allowed FeatureMembers tag). Please see getFeatureType for more details.
features in interface SimpleFeatureCollectionfeatures in interface FeatureCollection<SimpleFeatureType,SimpleFeature>public void close(FeatureIterator<SimpleFeature> close)
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 void close(SimpleFeatureIterator close)
public void closeIterator(SimpleFeatureIterator close)
public void accepts(FeatureVisitor visitor,
ProgressListener progress)
throws IOException
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 operation
IOExceptionpublic SimpleFeatureCollection subList(Filter filter)
public SimpleFeatureCollection subCollection(Filter filter)
FeatureCollectionThe 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 SimpleFeatureCollectionsubCollection in interface FeatureCollection<SimpleFeatureType,SimpleFeature>FeatureListpublic SimpleFeatureCollection sort(SortBy order)
FeatureCollectionThis method may not be supported by all implementations, consider the use of FeatureSource.features( Query ).
sort in interface SimpleFeatureCollectionsort in interface FeatureCollection<SimpleFeatureType,SimpleFeature>order - Sort order
public boolean isEmpty()
isEmpty in interface FeatureCollection<SimpleFeatureType,SimpleFeature>Collection.isEmpty()public boolean contains(Object o)
This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
contains in interface FeatureCollection<SimpleFeatureType,SimpleFeature>o - object to be checked for containment in this collection.
Collection.contains(Object)public Object[] toArray()
toArray in interface FeatureCollection<SimpleFeatureType,SimpleFeature>Collection.toArray()public Object[] toArray(Object[] a)
toArray in interface FeatureCollection<SimpleFeatureType,SimpleFeature>Collection.toArray(Object[])public boolean add(SimpleFeature o)
add in interface FeatureCollection<SimpleFeatureType,SimpleFeature>o - element whose presence in this collection is to be ensured.
UnsupportedOperationException - if the add method is not
supported by this collection.
NullPointerException - if this collection does not permit
null elements, and the specified element is
null.
ClassCastException - if the class of the specified element
prevents it from being added to this collection.
IllegalArgumentException - if some aspect of this element
prevents it from being added to this collection.Collection.add(Object)public boolean remove(Object o)
remove in interface FeatureCollection<SimpleFeatureType,SimpleFeature>o - element to be removed from this collection, if present.
UnsupportedOperationException - if the remove method is
not supported by this collection.Collection.remove(Object)public boolean containsAll(Collection c)
containsAll in interface FeatureCollection<SimpleFeatureType,SimpleFeature>c - collection to be checked for containment in this collection.
NullPointerException - if the specified collection is null.contains(Object)public boolean addAll(Collection c)
addAll in interface FeatureCollection<SimpleFeatureType,SimpleFeature>c - collection whose elements are to be added to this collection.
UnsupportedOperationException - if this collection does not
support the addAll method.
NullPointerException - if the specified collection is null.#add(Object)public boolean addAll(FeatureCollection c)
addAll in interface FeatureCollection<SimpleFeatureType,SimpleFeature>FeatureCollection.addAll(Collection)public boolean removeAll(Collection c)
removeAll in interface FeatureCollection<SimpleFeatureType,SimpleFeature>c - elements to be removed from this collection.
UnsupportedOperationException - if the removeAll method
is not supported by this collection.
NullPointerException - if the specified collection is null.remove(Object),
contains(Object)public boolean retainAll(Collection c)
retainAll in interface FeatureCollection<SimpleFeatureType,SimpleFeature>c - elements to be retained in this collection.
UnsupportedOperationException - if the retainAll method
is not supported by this Collection.
NullPointerException - if the specified collection is null.remove(Object),
contains(Object)public void clear()
clear in interface FeatureCollection<SimpleFeatureType,SimpleFeature>UnsupportedOperationException - if the clear method is
not supported by this collection.Collection.clear()public String toString()
toString in class Objectpublic final Set getOpenIterators()
public final Iterator<SimpleFeature> iterator()
Note: If you return a ResourceIterator, the default implemntation of close( Iterator ) will know what to do.
iterator in interface FeatureCollection<SimpleFeatureType,SimpleFeature>public abstract int size()
size in interface FeatureCollection<SimpleFeatureType,SimpleFeature>Collection.size()public final void close(Iterator close)
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>close - protected abstract Iterator<SimpleFeature> openIterator()
Please subclass to provide your own iterator - note iterator() is
implemented to call open() and track the results in for
later purge().
protected abstract void closeIterator(Iterator<SimpleFeature> close)
As an example if the iterator was working off a File then the inputstream should be closed.
Subclass must call super.close( close ) to allow the list of open iterators to be adjusted.
close - Iterator, will not be nullpublic void purge()
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 String getID()
FeatureCollection
getID in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
public final void addListener(CollectionListener listener)
throws NullPointerException
FeatureCollectionWhen 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 SimpleFeatureType getSchema()
FeatureCollectionRepresents the most general FeatureType in common to all the features in this collection.
getSchema in interface FeatureCollection<SimpleFeatureType,SimpleFeature>public ReferencedEnvelope getBounds()
getBounds in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||