|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.geotools.feature.collection.AbstractResourceCollection
org.geotools.feature.collection.AbstractFeatureCollection
| Nested Class Summary |
| Nested classes inherited from class org.geotools.feature.Feature |
Feature.NULL |
| Field Summary |
| Fields inherited from class org.geotools.feature.collection.AbstractResourceCollection |
open |
| Constructor Summary | |
protected |
AbstractFeatureCollection(FeatureState state)
Feature methods will be delegated to provided state. |
|
AbstractFeatureCollection(FeatureType schema)
Creates an AbstractFeatureCollection delegating the FeatureState implementaion content to iterator() and close( iterator ). |
| Method Summary | |
void |
accepts(FeatureVisitor visitor,
ProgressListener progress)
Accepts a visitor, which then visits each feature in the collection. |
void |
addListener(CollectionListener listener)
Adds a listener for collection events. |
void |
close(FeatureIterator close)
Clean up any resources assocaited with this iterator in a manner similar to JDO collections. |
void |
closeIterator(FeatureIterator close)
|
FeatureCollection |
collection()
Convert this set of results to a FeatureCollection. |
FeatureIterator |
features()
Obtain a FeatureIterator of the Features within this collection. |
java.lang.Object |
getAttribute(int index)
Gets an attribute by the given zero-based index. |
java.lang.Object |
getAttribute(java.lang.String xPath)
Gets an attribute for this feature at the location specified by xPath. |
java.lang.Object[] |
getAttributes(java.lang.Object[] attributes)
Copy all the attributes of this Feature into the given array. |
com.vividsolutions.jts.geom.Envelope |
getBounds()
Returns the bounding box of this FeatureResults. |
int |
getCount()
Returns the number of Features in this FeatureResults. |
com.vividsolutions.jts.geom.Geometry |
getDefaultGeometry()
Gets the default geometry for this feature. |
FeatureType |
getFeatureType()
Gets a reference to the type of this feature collection. |
java.lang.String |
getID()
Gets the unique feature ID for this feature. |
int |
getNumberOfAttributes()
Get the number of attributes this feature has. |
FeatureCollection |
getParent()
Gets the feature collection this feature is stored in. |
FeatureType |
getSchema()
The schema for the child features of this collection. |
void |
purge()
Close any outstanding resources released by this resources. |
FeatureReader |
reader()
Provides access to the Features, please note that FeatureReader is a blocking api. |
void |
removeListener(CollectionListener listener)
Removes a listener for collection events. |
void |
setAttribute(int position,
java.lang.Object val)
Sets an attribute by the given zero-based index. |
void |
setAttribute(java.lang.String xPath,
java.lang.Object attribute)
Sets a single attribute for this feature, passed as a complex object. |
void |
setDefaultGeometry(com.vividsolutions.jts.geom.Geometry geometry)
Sets the default geometry for this feature. |
void |
setParent(FeatureCollection collection)
Sets the parent collection this feature is stored in, if it is not already set. |
FeatureList |
sort(SortBy order)
collection.subCollection( myFilter ).sort( {"foo","bar"} ); collection.subCollection( myFilter ).sort( "bar" ).sort("foo") |
FeatureCollection |
subCollection(Filter filter)
FeatureCollection "view" indicated by provided filter. |
FeatureList |
subList(Filter filter)
|
| Methods inherited from class org.geotools.feature.collection.AbstractResourceCollection |
add, addAll, clear, close, closeIterator, contains, containsAll, isEmpty, iterator, openIterator, remove, removeAll, retainAll, size, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.geotools.feature.FeatureCollection |
close |
| Methods inherited from interface org.geotools.data.collection.ResourceCollection |
iterator |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray |
| Constructor Detail |
protected AbstractFeatureCollection(FeatureState state)
You can use this implemenation with a choice of stratagy objects:
public AbstractFeatureCollection(FeatureType schema)
schema - | Method Detail |
public FeatureCollection getParent()
Feature
getParent in interface Featurepublic void setParent(FeatureCollection collection)
Feature
setParent in interface Featurecollection - the collection to be set as parent.public FeatureType getFeatureType()
FeatureCollectionThere are several limitations on the use of FeatureType with respect to a FeatureCollection.
GML 3.x: all FeatureCollections decend from gml:AbstractFeatureCollectionType:
GML 3.x: gml:AbstractFeatureCollectionType decends from gml:BoundedFeatureType:
There is a difference between getFeatureType() and getSchema(), getSchema is named for historical reasons and reprensets the LCD FeatureType that best represents the contents of this collection.
getFeatureType in interface FeatureCollectionpublic java.lang.String getID()
Feature
getID in interface Featurepublic java.lang.Object[] getAttributes(java.lang.Object[] attributes)
Feature
getAttributes in interface Featureattributes - An array to copy attributes into. May be null.
public java.lang.Object getAttribute(java.lang.String xPath)
Feature
getAttribute in interface FeaturexPath - XPath representation of attribute location.
public java.lang.Object getAttribute(int index)
Feature
getAttribute in interface Featureindex - The requested index. Must be 0 <= idx <
getNumberOfAttributes().
Feature.getAttribute(String)
public void setAttribute(int position,
java.lang.Object val)
throws IllegalAttributeException,
java.lang.ArrayIndexOutOfBoundsException
Feature
setAttribute in interface Featureposition - The requested index. Must be 0 <= idx <
getNumberOfAttributes()val - An object representing the attribute being set
java.lang.ArrayIndexOutOfBoundsException - if an invalid position is given
IllegalAttributeException - if the passed in val does not validate
against the AttributeType at that position.Feature.setAttribute(String, Object)public int getNumberOfAttributes()
Feature
getNumberOfAttributes in interface Feature
public void setAttribute(java.lang.String xPath,
java.lang.Object attribute)
throws IllegalAttributeException
Feature
setAttribute in interface FeaturexPath - XPath representation of attribute location.attribute - Feature attribute to set.
IllegalAttributeException - If the attribute is illegal for the
path specified.public com.vividsolutions.jts.geom.Geometry getDefaultGeometry()
Feature
This method will return null if no DefaultGeometry has been
defined by the schema.
getDefaultGeometry in interface Featurenull
public void setDefaultGeometry(com.vividsolutions.jts.geom.Geometry geometry)
throws IllegalAttributeException
Feature
setDefaultGeometry in interface Featuregeometry - The geometry to set.
IllegalAttributeException - If the AttributeType is not a
geometry, or is invalid for some other reason.public com.vividsolutions.jts.geom.Envelope getBounds()
FeatureResults
This opperation may be expensive. Consider
FeatureSource.getBounds( Query ) as an alternative.
public Envelope getBounds() throws IOException {
Envelope newBBox = new Envelope();
Envelope internal;
Feature feature;
for (FeatureReader r = reader(); r.hasNext();) {
feature = r.next();
internal = feature.getDefaultGeometry().getEnvelopeInternal();
newBBox.expandToInclude(internal);
}
return newBBox;
}
getBounds in interface FeatureResultspublic FeatureType getSchema()
FeatureCollectionThere 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 FeatureCollectionpublic void addListener(CollectionListener listener)
FeatureCollectionWhen this collection is backed by live data the event notification will follow the guidelines outlined by FeatureListner.
addListener in interface FeatureCollectionlistener - The listener to add
public void removeListener(CollectionListener listener)
throws java.lang.NullPointerException
FeatureCollection
removeListener in interface FeatureCollectionlistener - The listener to remove
java.lang.NullPointerException - If the listener is null.public FeatureIterator 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 FeatureCollectionpublic void close(FeatureIterator close)
FeatureCollectionYou must be sure to allow null values, this is because in a try/finally block client code may not be sure if they have actualy succeed in assign a value to an iterator they wish to ensure is closed. By permiting null as an api we prevent a null check in lots of finally statements.
Note: Because of FeatureReader using an interator internally, there is only one implementation of this method that makes any sense:
public void close( FeatureIterator iterator) {
if( iterator != null ) iterator.close();
}
close in interface FeatureCollectionpublic void closeIterator(FeatureIterator close)
public void purge()
ResourceCollectionThis 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 ResourceCollectionpurge in class AbstractResourceCollection
public void accepts(FeatureVisitor visitor,
ProgressListener progress)
throws java.io.IOException
accepts in interface FeatureCollectionvisitor -
java.io.IOExceptionpublic FeatureList subList(Filter filter)
public FeatureCollection subCollection(Filter filter)
FeatureCollectionThe contents of the returned FeatureCollection are determined by applying the provider Fitler 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 FeatureCollection construct. The FeatureCollections returned really should be considered as a temporary "view" used to control the range of a removeAll, or modify opperation.
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 FeatureCollectionfilter -
FeatureListpublic FeatureList sort(SortBy order)
FeatureCollection
sort in interface FeatureCollectionorder -
public FeatureReader reader()
throws java.io.IOException
FeatureResults
reader in interface FeatureResultsjava.io.IOException - DOCUMENT ME!
public int getCount()
throws java.io.IOException
FeatureResults
This opperation may be expensive. Consider FeatureSource.getCount(
Query ) as an alternative.
public int getCount() throws IOException {
int count = 0;
for (FeatureReader r = reader(); r.hasNext(); count++) {
r.next();
}
return count;
}
getCount in interface FeatureResultsjava.io.IOException - If there are problems getting the count
public FeatureCollection collection()
throws java.io.IOException
FeatureResultsThis method is logically the same as:
public FeatureCollection collection() throws IOException {
FeatureCollection collection = FeatureCollections.newCollection()
for (FeatureReader r = reader(); r.hasNext();) {
collection.add( r.next() );
}
return collection;
}
collection in interface FeatureResultsjava.io.IOException - If any problems occur aquiring Features
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||