|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectAbstractFeatureCollection
SubFeatureCollection
public class SubFeatureCollection
Used as a reasonable default implementation for subCollection.
Note: to implementors, this is not optimal, please do your own thing - your users will thank you.
modules/library/main (gt-main.jar)
Field Summary | |
---|---|
protected FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection
Original Collection |
protected FilterFactory |
ff
|
protected Filter |
filter
Filter |
Fields inherited from class AbstractFeatureCollection |
---|
id, listeners, open, schema |
Constructor Summary | |
---|---|
SubFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
|
|
SubFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> collection,
Filter subfilter)
|
Method Summary | |
---|---|
void |
accepts(FeatureVisitor visitor,
ProgressListener progress)
Visit the contents of a feature collection. |
boolean |
add(SimpleFeature o)
Implement to support modification. |
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 |
closeIterator(Iterator iterator)
Please override to cleanup after your own iterators, and any used resources. |
FeatureCollection<SimpleFeatureType,SimpleFeature> |
collection()
|
protected Filter |
createFilter()
Override to implement subsetting |
FeatureIterator<SimpleFeature> |
features()
Obtain a FeatureIterator |
protected Filter |
filter()
|
ReferencedEnvelope |
getBounds()
Calculates the bounds of the features without caching. |
int |
getCount()
|
String |
getID()
ID used when serializing to GML |
boolean |
isEmpty()
|
Iterator |
openIterator()
Open a resource based Iterator, we will call close( iterator ). |
FeatureReader<SimpleFeatureType,SimpleFeature> |
reader()
|
boolean |
remove(Object o)
Removes a single instance of the specified element from this collection, if it is present (optional operation). |
int |
size()
Returns the number of elements in this collection. |
FeatureCollection<SimpleFeatureType,SimpleFeature> |
sort(SortBy order)
collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo") |
FeatureCollection<SimpleFeatureType,SimpleFeature> |
subCollection(Filter filter)
FeatureCollection |
Methods inherited from class AbstractFeatureCollection |
---|
accepts, addAll, addAll, addListener, close, contains, containsAll, getOpenIterators, getSchema, iterator, purge, removeAll, removeListener, retainAll, subList, toArray, toArray |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Filter filter
protected FeatureCollection<SimpleFeatureType,SimpleFeature> collection
protected FilterFactory ff
Constructor Detail |
---|
public SubFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
public SubFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> collection, Filter subfilter)
Method Detail |
---|
public Iterator openIterator()
AbstractFeatureCollection
Please subclass to provide your own iterator for the the ResourceCollection,
note iterator()
is implemented to call open()
and track the results in for later purge()
.
openIterator
in class AbstractFeatureCollection
public void closeIterator(Iterator iterator)
AbstractFeatureCollection
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.
closeIterator
in class AbstractFeatureCollection
iterator
- Iterator, will not be null
public int size()
AbstractFeatureCollection
size
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
size
in class AbstractFeatureCollection
Collection.size()
protected Filter filter()
protected Filter createFilter()
public FeatureIterator<SimpleFeature> 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 FeatureCollection<SimpleFeatureType,SimpleFeature>
features
in class AbstractFeatureCollection
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>
close
in class AbstractFeatureCollection
public FeatureCollection<SimpleFeatureType,SimpleFeature> subCollection(Filter filter)
FeatureCollection
The contents of the returned FeatureCollection
This method is used cut down on the number of filter based methods
required for a useful FeatureCollection
Example Use:
The results of subCollection:
The above recommended use is agreement with the Collections API precident of
List.subList( start, end ).
collection.subCollection( filter ).clear();
subCollection
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
subCollection
in class AbstractFeatureCollection
FeatureList
public boolean isEmpty()
isEmpty
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
isEmpty
in class AbstractFeatureCollection
Collection.isEmpty()
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>
accepts
in class AbstractFeatureCollection
visitor
- Closure applied to each feature in turn.progress
- Used to report progress, may be used to interrupt the operationpublic FeatureCollection<SimpleFeatureType,SimpleFeature> sort(SortBy order)
FeatureCollection
sort
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
sort
in class AbstractFeatureCollection
public boolean add(SimpleFeature o)
AbstractFeatureCollection
add
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
add
in class AbstractFeatureCollection
o
- element whose presence in this collection is to be ensured.
Collection.add(Object)
public void clear()
AbstractFeatureCollection
clear
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
clear
in class AbstractFeatureCollection
Collection.clear()
public boolean remove(Object o)
AbstractFeatureCollection
remove
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
remove
in class AbstractFeatureCollection
o
- element to be removed from this collection, if present.
Collection.remove(Object)
public String getID()
FeatureCollection
getID
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
getID
in class AbstractFeatureCollection
public FeatureReader<SimpleFeatureType,SimpleFeature> reader() throws IOException
IOException
public int getCount() throws IOException
IOException
public FeatureCollection<SimpleFeatureType,SimpleFeature> collection() throws IOException
IOException
public ReferencedEnvelope getBounds()
getBounds
in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
getBounds
in class AbstractFeatureCollection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |