Upgrade instructions are available: As part of this work Andrea provided an extensive review of the existing FeatureCollection implementations and a number of utility methods have been introduced to make working with features easier:
- DataUtilities.visit( FeatureCollection, FeatureVisitor, ProgerssListener )
- DataUtilities.bounds( FeatureCollection ) // Already existed
- DataUtilities.bounds( FeatureIterator )
- DataUtilities.count( FeatureCollection )
- DataUtilities.count( FeatureIterator )
- DataUtilities.close( Iterator )
- DataUtilities.first( SimpleFeatureCollection ): SimpleFeature
- DataUtilities.first( FeatureCollection ): F
- DataUtilities.list( FeatureCollection ): List // Already existed 
- DataUtilities.list( FeatureCollection, int ): List
- DataUtilities.iterator( FeatureIterator ): Iterator // also Closable
- DataUtilities.collectionCast( FeatureCollection ): Collection
If you cannot make the transition today:
- A milestone 9.0-M0 release has been deployed to maven.
- To switch your maven pom.xml over to 9.0-M0:
<properties> <geotools.version>9.0-M0</geotools.version> </properties> ... <dependency> <groupId>org.geotools</groupId> <artifactId>gt-main</artifactId> <version>${geotools.version}</version> </dependency>
- You can use this milestone release as a rest area until you have time to upgrade.
- The initial GeoTools 2.0 rewrite provided a clear FeatureResults API acting in a fashion similar to a JDBC ResultSet.
- GeoTools 2.1 introduced FeatureCollection as a superclass of FeatureResults, bringing in the java.util.Collection methods being removed today. This was motivated by an amusing Bring Back FeatureCollection rant from our founder James MacGill - well we tried James and it was a bad idea.
- The transition to Java 5 forced us to remove direct use of the java.util.Collection interface, however we kept the methods for backwards compatibility. It was too easy to introduce a resource leak with the Java 5 for-each syntax:
System.out.println( feature.getID() );
}
- With todays change GeoTools programs are ready for the Java 7 try-with-resource syntax as shown below:
while( iter.hasNext() ){
Feature feature = iter.next();
System.out.println( feature.getID() );
}
}