I mentioned this a couple weeks ago; but after reading into the Java 7 pipeline
and Juno support for try-with-resource I am even more convinced that this is a
necissary change for GeoTools 9.x.
Reading:
-
http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
-
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FwhatsNew%2FJava7news%2Fwhats-new-java-7.html
I will prepare a change request; it amounts to:
interface FeatureIterator< F extends Feature> implements Closable {
public void close() throws IOException;
}
It allows the following:
Java 7: try-with-resource
try (FeatureIterator iterator = feastureSource.getFeatures()){
while( iterator.hasNext() ){
Feature f = iterator.next();
System.out.println( f.getIdentifier() );
}
}
This would finally let us recover for the darn for-each loop. FeatureReader and
FeatureWriter should also implement closable.
Java 6: close() would throw IOException
FeatureIterator iterator = featureSource.getFeatures();
try {
while( iterator.hasNext() ){
Feature f = iterator.next();
System.out.println( f.getIdentifier() );
}
}
finally {
if( iterator != null ) iteator.close();
}
// note IOException can be thrown from iterator.close or
featureSource.getFeatures()
--
Jody Garnett
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel