|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.feature.DefaultFeatureCollection
public class DefaultFeatureCollection
A basic implementation of FeatureCollection
This should be considered a MemoryFeatureCollection.
Opportunistic reuse is encouraged, but only for the purposes
of testing or other specialized uses. Normal creation should
occur through
Collections that support this operation may place limitations on what
elements may be added to this collection. In particular, some
collections will refuse to add null elements, and others will
impose restrictions on the type of elements that may be added.
Collection classes should clearly specify in their documentation any
restrictions on what elements may be added.
If a collection refuses to add a particular element for any reason other
than that it already contains the element, it must throw an
exception (rather than returning false). This preserves the
invariant that a collection always contains the specified element after
this call returns.
The returned array will be "safe" in that no references to it are
maintained by this collection. (In other words, this method must
allocate a new array even if this collection is backed by an array).
The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based
APIs.
If this collection fits in the specified array with room to spare (i.e.,
the array has more elements than this collection), the element in the
array immediately following the end of the collection is set to
null. This is useful in determining the length of this
collection only if the caller knows that this collection does
not contain any null elements.)
If this collection makes any guarantees as to what order its elements
are returned by its iterator, this method must return the elements in
the same order.
Like the toArray method, this method acts as bridge between
array-based and collection-based APIs. Further, this method allows
precise control over the runtime type of the output array, and may,
under certain circumstances, be used to save allocation costs
Suppose l is a List known to contain only strings. The
following code can be used to dump the list into a newly allocated
array of String:
TreeMap
for
its internal storage.
Field Summary
protected java.lang.String
id
id used when serialized to gml
protected java.util.List
listeners
listeners
protected static java.util.logging.Logger
LOGGER
protected org.opengis.feature.simple.SimpleFeatureType
schema
Constructor Summary
DefaultFeatureCollection(FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection)
This constructor should not be used by client code.
DefaultFeatureCollection(java.lang.String id,
org.opengis.feature.simple.SimpleFeatureType memberType)
This constructor should not be used by client code.
Method Summary
void
accepts(org.opengis.feature.FeatureVisitor visitor,
org.opengis.util.ProgressListener progress)
Visit the contents of a feature collection.
void
accepts(FeatureVisitor visitor,
ProgressListener progress)
boolean
add(org.opengis.feature.simple.SimpleFeature o)
Ensures that this collection contains the specified element (optional
operation).
protected boolean
add(org.opengis.feature.simple.SimpleFeature feature,
boolean fire)
boolean
addAll(java.util.Collection collection)
Adds all of the elements in the specified collection to this collection
(optional operation).
boolean
addAll(FeatureCollection collection)
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<org.opengis.feature.simple.SimpleFeature> close)
Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.
void
close(java.util.Iterator close)
Clean up after any resources associated with this itterator in a manner similar to JDO collections.
FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
collection()
boolean
contains(java.lang.Object o)
Returns true if this collection contains the specified element.
boolean
containsAll(java.util.Collection collection)
Test for collection membership.
FeatureIterator<org.opengis.feature.simple.SimpleFeature>
features()
Gets a FeatureIterator
java.util.Set
fids()
Optimization time ...
protected void
fireChange(java.util.Collection coll,
int type)
protected void
fireChange(org.opengis.feature.simple.SimpleFeature[] features,
int type)
To let listeners know that something has changed.
protected void
fireChange(org.opengis.feature.simple.SimpleFeature feature,
int type)
ReferencedEnvelope
getBounds()
Gets the bounding box for the features in this feature collection.
int
getCount()
java.lang.String
getID()
ID used when serializing to GML
org.opengis.feature.simple.SimpleFeatureType
getSchema()
The schema for the child features of this collection.
boolean
isEmpty()
Returns true if this collection contains no elements.
java.util.Iterator
iterator()
Returns an iterator over the elements in this collection.
void
purge()
Close any outstanding resources released by this resources.
FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
reader()
boolean
remove(java.lang.Object o)
Removes a single instance of the specified element from this collection,
if it is present (optional operation).
boolean
removeAll(java.util.Collection collection)
Removes all this collection's elements that are also contained in the
specified collection (optional operation).
void
removeListener(CollectionListener listener)
Removes a listener for collection events.
boolean
retainAll(java.util.Collection collection)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
int
size()
Returns the number of elements in this collection.
FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
sort(org.opengis.filter.sort.SortBy order)
Construct a sorted view of this content.
FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
sort(SortBy2 order)
Allows for "Advanced" sort capabilities specific to the
GeoTools platform!
FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
subCollection(org.opengis.filter.Filter filter)
Will return an optimized subCollection based on access
to the origional MemoryFeatureCollection.
java.lang.Object[]
toArray()
Returns an array containing all of the elements in this collection.
java.lang.Object[]
toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this collection; the
runtime type of the returned array is that of the specified array.
void
validate()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
LOGGER
protected static java.util.logging.Logger LOGGER
listeners
protected java.util.List listeners
id
protected java.lang.String id
schema
protected org.opengis.feature.simple.SimpleFeatureType schema
Constructor Detail
DefaultFeatureCollection
public DefaultFeatureCollection(FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection)
collection
- FeatureCollection
DefaultFeatureCollection
public DefaultFeatureCollection(java.lang.String id,
org.opengis.feature.simple.SimpleFeatureType memberType)
org.geotools.core.FeatureCollections.newCollection()
allowing applications to customize any generated collections.
id
- may be null ... feature idfeatureType
- optional, may be null
Method Detail
getBounds
public ReferencedEnvelope getBounds()
getBounds
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
fireChange
protected void fireChange(org.opengis.feature.simple.SimpleFeature[] features,
int type)
fireChange
protected void fireChange(org.opengis.feature.simple.SimpleFeature feature,
int type)
fireChange
protected void fireChange(java.util.Collection coll,
int type)
add
public boolean add(org.opengis.feature.simple.SimpleFeature o)
add
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
o
- element whose presence in this collection is to be ensured.
Collection.add(Object)
add
protected boolean add(org.opengis.feature.simple.SimpleFeature feature,
boolean fire)
addAll
public boolean addAll(java.util.Collection collection)
addAll
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
collection
- elements to be inserted into this collection.
#add(Object)
addAll
public boolean addAll(FeatureCollection collection)
addAll
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
FeatureCollection.addAll(Collection)
clear
public void clear()
clear
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Collection.clear()
contains
public boolean contains(java.lang.Object o)
contains
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
o
- element whose presence in this collection is to be tested.
Collection.contains(Object)
containsAll
public boolean containsAll(java.util.Collection collection)
containsAll
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
collection
-
Collection.containsAll(Collection)
isEmpty
public boolean isEmpty()
isEmpty
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Collection.isEmpty()
iterator
public java.util.Iterator iterator()
iterator
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
features
public FeatureIterator<org.opengis.feature.simple.SimpleFeature> features()
features
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
remove
public boolean remove(java.lang.Object o)
remove
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
o
- element to be removed from this collection, if present.
Collection.remove(Object)
removeAll
public boolean removeAll(java.util.Collection collection)
removeAll
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
collection
- elements to be removed from this collection.
remove(Object)
,
contains(Object)
retainAll
public boolean retainAll(java.util.Collection collection)
retainAll
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
collection
- elements to be retained in this collection.
remove(Object)
,
contains(Object)
size
public int size()
size
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Collection.size()
toArray
public java.lang.Object[] toArray()
toArray
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
Collection.toArray()
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
String[] x = (String[]) v.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
toArray
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
a
- the array into which the elements of this collection are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose.
Collection.toArray(Object[])
public void close(FeatureIterator<org.opengis.feature.simple.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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
public void close(java.util.Iterator 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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
public FeatureReader<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> reader() throws java.io.IOException
java.io.IOException
public int getCount() throws java.io.IOException
java.io.IOException
public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> collection() throws java.io.IOException
java.io.IOException
public java.util.Set fids()
public void accepts(org.opengis.feature.FeatureVisitor visitor, org.opengis.util.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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
visitor
- Closure applied to each feature in turn.progress
- Used to report progress, may be used to interrupt the operationpublic FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> subCollection(org.opengis.filter.Filter filter)
This method is intended in a manner similar to subList,
example use:
collection.subCollection( myFilter ).clear()
subCollection
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
filter
- Filter used to determine sub collection.
FeatureList
public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature> sort(org.opengis.filter.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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
order
- Filter 1.1 SortBy Construction of a Sort
public FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.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 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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
public void validate()
public java.lang.String getID()
FeatureCollection
getID
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
public final void addListener(CollectionListener listener) throws java.lang.NullPointerException
FeatureCollection
When this collection is backed by live data the event notification will follow the guidelines outlined by FeatureListner.
addListener
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
listener
- The listener to add
java.lang.NullPointerException
- If the listener is null.public final void removeListener(CollectionListener listener) throws java.lang.NullPointerException
FeatureCollection
removeListener
in interface FeatureCollection<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
listener
- The listener to remove
java.lang.NullPointerException
- If the listener is null.public final void accepts(FeatureVisitor visitor, ProgressListener progress) throws java.io.IOException
java.io.IOException
public org.opengis.feature.simple.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<org.opengis.feature.simple.SimpleFeatureType,org.opengis.feature.simple.SimpleFeature>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |