org.geotools.data.collection
Interface ResourceCollection

All Superinterfaces:
java.util.Collection
All Known Subinterfaces:
FeatureCollection, FeatureDocument, FeatureList, IndexedFeatureCollection, RandomFeatureAccess, ResourceList
All Known Implementing Classes:
AbstractFeatureCollection, AbstractFeatureCollection, AbstractFeatureList, AbstractResourceCollection, AbstractResourceList, DataFeatureCollection, DefaultFeatureCollection, MemoryFeatureCollection, SubFeatureCollection, SubFeatureList, SubResourceList

public interface ResourceCollection
extends java.util.Collection

Collection supporting close( Iterator ), used to grok resources.

This implementation is a port of java.util.Collection with support for the use of close( Iterator ). This will allow subclasses that make use of resources during iterator() to be uses safely.

Since:
GeoTools 2.2
Author:
Jody Garnett, Refractions Research, Inc.

Method Summary
 void close(java.util.Iterator close)
          Clean up after any resources assocaited with this itterator in a manner similar to JDO collections.
 java.util.Iterator iterator()
          An iterator over this collection, which must be closeed after use.
 void purge()
          Close any outstanding resources released by this resources.
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

iterator

public java.util.Iterator iterator()
An iterator over this collection, which must be closeed after use.

Collection is not guarneteed to be ordered in any manner.

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.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     while( iterator.hasNext();){
          Feature feature = (Feature) iterator.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
iterator in interface java.util.Collection
Returns:
Iterator

close

public void close(java.util.Iterator close)
Clean up after any resources assocaited with this itterator in a manner similar to JDO collections.

Example (safe) use:

 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 );
 }
 

Parameters:
close -

purge

public void purge()
Close any outstanding resources released by this resources.

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(); 
 



Copyright © GeoTools. All Rights Reserved.