Class PropertyFeatureReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, FeatureReader<SimpleFeatureType,​SimpleFeature>

    public class PropertyFeatureReader
    extends Object
    implements FeatureReader<SimpleFeatureType,​SimpleFeature>
    Read a property file directly.

    This implementation does not perform any filtering or processing; it leaves that up to wrappers to manipulate the content into the format or projection requested by the user.

    The content of this file should start with a the property "_" with the value being the typeSpec describing the featureType. Thereafter each line will should have a FeatureID as the property and the attributes as the value separated by | characters.

     
     _=id:Integer|name:String|geom:Geometry
     fid1=1|Jody|well known text
     fid2=2|Brent|well known text
     fid3=3|Dave|well known text
     
     

    Many values may be represented by a special tag: . An empty element: || is interpreted as the empty string:

      
      fid4=4|| -> Feature( id=2, name="", geom=null )
      
     
    Since:
    8.0
    Author:
    Jody Garnett (LISAsoft), Torben Barsballe (Boundless)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Be sure to call close when you are finished with this reader; as it must close the file it has open.
      SimpleFeatureType getFeatureType()
      Return the FeatureType this reader has been configured to create.
      boolean hasNext()
      Check if additional content is available.
      SimpleFeature next()
      Grab the next feature from the property file.
      Object read​(int index)
      Read attribute in position marked by index.
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PropertyFeatureReader

        public PropertyFeatureReader​(String namespace,
                                     File file)
                              throws IOException
        Throws:
        IOException
      • PropertyFeatureReader

        public PropertyFeatureReader​(String namespace,
                                     File file,
                                     GeometryFactory geometryFactory)
                              throws IOException
        Throws:
        IOException
    • Method Detail

      • next

        public SimpleFeature next()
                           throws IOException,
                                  NoSuchElementException
        Grab the next feature from the property file.
        Specified by:
        next in interface FeatureReader<SimpleFeatureType,​SimpleFeature>
        Returns:
        feature
        Throws:
        NoSuchElementException - Check hasNext() to avoid reading off the end of the file
        IOException - If an error occurs reading the Feature.
      • read

        public Object read​(int index)
                    throws IOException,
                           ArrayIndexOutOfBoundsException
        Read attribute in position marked by index.
        Parameters:
        index - Attribute position to read
        Returns:
        Value for the attribtue in position index
        Throws:
        IOException
        ArrayIndexOutOfBoundsException
      • hasNext

        public boolean hasNext()
                        throws IOException
        Check if additional content is available.
        Specified by:
        hasNext in interface FeatureReader<SimpleFeatureType,​SimpleFeature>
        Returns:
        true if additional content is available
        Throws:
        IOException - If an error occurs determining if there are more Features.
      • close

        public void close()
                   throws IOException
        Be sure to call close when you are finished with this reader; as it must close the file it has open.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface FeatureReader<SimpleFeatureType,​SimpleFeature>
        Throws:
        IOException - if an I/O error occurs