org.deegree.feature.stream
Interface FeatureInputStream

All Superinterfaces:
Iterable<Feature>
All Known Implementing Classes:
CombinedFeatureInputStream, FilteredFeatureInputStream, IteratorFeatureInputStream, MemoryFeatureInputStream, StreamFeatureCollection, ThreadedFeatureInputStream

public interface FeatureInputStream
extends Iterable<Feature>

Provides streaming access to Feature objects provide by a source.

The primary means of accessing the individual result features is to use the Iterable.iterator() method and subsequently call it's Iterator.next() methods. Depending on the implementation (e.g. when backed by an SQL result set), this enables the processing of arbitrary large numbers of results without causing memory issues. Also, it's essential to ensure that the close() method is called afterwards, or resource leaks may occur (e.g. open SQL result sets).

A safe use of a FeatureInputStream looks like this:

   ...
   FeatureInputStream fis = null;
   try {
       // retrieve the FeatureInputStream
       fis = ...
       for ( Feature f : fis ) {
           // do something with the feature
           // ...
       }
   } finally {
       // make sure that the FeatureResultSet always gets closed
       if ( fis != null ) {
           rs.close();
       }
   }
   ...
 

Version:
$Revision: 32025 $, $Date: 2011-09-27 12:24:23 +0200 (Tue, 27 Sep 2011) $
Author:
Markus Schneider, last edited by: $Author: mschneider $

Method Summary
 void close()
          Must be invoked after using to close underlying resources, e.g.
 int count()
          Counts the remaining features in the stream (and consumes them) and closes it.
 FeatureCollection toCollection()
          Returns all members of the FeatureInputStream as a FeatureCollection.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

close

void close()
Must be invoked after using to close underlying resources, e.g. SQL ResultSets.


toCollection

FeatureCollection toCollection()
Returns all members of the FeatureInputStream as a FeatureCollection.

NOTE: This method should not be called for very large result sets, as it introduces the overhead of keeping all created feature instances in memory. The returned collection will contain all Features instances from the current position in the iteration sequence.

Returns:
members as feature collection, never null

count

int count()
Counts the remaining features in the stream (and consumes them) and closes it.

Returns:
number of remaining features


Copyright © 2011. All Rights Reserved.