I am sorry we cannot do that ... the reason is that we need someone to *close*
the input stream (since it represents a live database connection sometimes).
As a result of this confusion (brought around in Java 5) we had to stop
extending Collection<Feature>.
Personally I recommend the use of visitor.
featureCollection.visit( new FeatureVisitor(){
public void accepts( Feature feature ){
... do stuff
}
}, progress );
Now in cases where the feature collection actually is in memory - you are
welcome to make use of whatever interfaces are available to you.
Jody
On 10/09/2010, at 11:49 PM, Balint Persics wrote:
> Hi,
>
> While browsing the FeatureCollection API, I saw the following:
> FeatureCollection defines the Iterator<F>iterator() method, which MAY
> seem to clients as if this interface is a sub-interface of
> java.lang.Iterable<F>. If it were, it would be possible to use every
> FeatureCollection with the Java 5 enhanced for loop (aka for-each
> loop).
> java.lang.Iterable is available since Java 5.
>
> Instead of writing:
> Iterator<Feature> i = fc.iterator();
> while(i.hasNext()) {
> Feture f = i.next();
> // to sg with f
> }
>
> one could simply write:
> for(Feature f:fc) {
> // do sg with f
> }
>
> It produces cleaner code and it would make the API more simpler to use
> for inexperienced users.
>
> So the FeatureCollection interface should be:
> public interface FeatureCollection<T extends FeatureType, F extends
> Feature> extends Iterable<F> {
> // API methods containing Iterator<F> iterator()
> }
>
> Thanks,
> Balint
>
>
> --
> Persics Balint
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Geotools-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel