|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
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 |
public java.util.Iterator iterator()
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 );
}
iterator
in interface java.util.Collection
public void close(java.util.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
- public 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();
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |