Interface FeatureReader<T extends FeatureType,F extends Feature>

All Superinterfaces:
AutoCloseable, Closeable
All Known Subinterfaces:
DelegatingFeatureReader<T,F>, SimpleFeatureReader
All Known Implementing Classes:
AssetsMappingReader, CollectionFeatureReader, CollectionReader, CSVFeatureReader, DefaultFeatureReader, DelegateFeatureReader, DelegateSimpleFeatureReader, DiffFeatureReader, EmptyFeatureReader, EmptySimpleFeatureReader, FCBuffer, FIDFeatureReader, FilteringFeatureReader, FilteringSimpleFeatureReader, ForceCoordinateSystemFeatureReader, GeoJSONFeatureReader, GraticuleFeatureReader, JDBCClosingFeatureReader, JDBCFeatureReader, JDBCInsertFeatureWriter, JDBCJoiningFeatureReader, JDBCJoiningFilteringFeatureReader, JDBCUpdateFeatureWriter, JDBCUpdateInsertFeatureWriter, MaxFeatureReader, MemoryFeatureReader, MongoFeatureReader, PreGeneralizedFeatureReader, PropertyFeatureReader, ReprojectFeatureReader, ReTypeFeatureReader, SortedFeatureReader, VPFFeatureReader, VPFFileFeatureReader

public interface FeatureReader<T extends FeatureType,F extends Feature> extends Closeable
The low-level interface for reading Features. Will use the underlying AttributeReader and the given FeatureType to create new Features.

Typical use is as follows:


   FeatureReader reader = null;
   try{
      for( reader = data.getFeatureReader( filter ); reader.hasNext(); ){
          f = reader.next();
          ...
      }
   }
   catch (IOException problem){
      ...
   }
   finally {
      if( reader != null ){
          try {
             reader.close();
          }
          catch( IOException eek){
          }
      }
   }
 

Questions and Suggestions

  • Q: Should FeatureReader provide access to the AttributeReaders it uses?
    A: No, it looks like we will make a lazy Feature in order to cleanly allow for lazy parsing of attribtues.
  • Q:FeatureReader has a close method, but no open method?
    A: This is by design allowing FeatureReader to encapsulate its InputStream or Rowset). Please assume that FeatureReaders are a single use proposition.
  • Q: All that exception handling is a pain! A: Yes it is, we have constructed semi-normal Java iterators to cut down on the pain. But you *do* still have to close 'em - this is IO after all.
  • Q: Can we include skip(int) - SeanG A: The order of the contents is not "known" or predicatable to the end user, so skip( int ) would be useless. For random access (a higher order of abstraction then FeatureReader) please look at FeatureList.
Author:
Ian Schneider, Sean Geoghegan, Defence Science and Technology Organisation.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Release the underlying resources associated with this stream.
    Return the FeatureType this reader has been configured to create.
    boolean
    Query whether this FeatureReader has another Feature.
    Reads the next Feature in the FeatureReader.
  • Method Details

    • getFeatureType

      T getFeatureType()
      Return the FeatureType this reader has been configured to create.
      Returns:
      the FeatureType of the Features this FeatureReader will create.
    • next

      Reads the next Feature in the FeatureReader.
      Returns:
      The next feature in the reader.
      Throws:
      IOException - If an error occurs reading the Feature.
      IllegalAttributeException - If the attributes read do not comply with the FeatureType.
      NoSuchElementException - If there are no more Features in the Reader.
      IllegalArgumentException
    • hasNext

      boolean hasNext() throws IOException
      Query whether this FeatureReader has another Feature.
      Returns:
      True if there are more Features to be read. In other words, true if calls to next would return a feature rather than throwing an exception.
      Throws:
      IOException - If an error occurs determining if there are more Features.
    • close

      void close() throws IOException
      Release the underlying resources associated with this stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an I/O error occurs