Class VPFFile


  • public class VPFFile
    extends Object
    This class encapsulates VPF files, serving as a factory for VPFColumns. Instances of this class should be created by VPFFileFactory.
    Author:
    Jeff Yutzler
    • Constructor Summary

      Constructors 
      Constructor Description
      VPFFile​(String cPathName)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the input stream pointed to by the object
      int getAttributeCount()  
      char getByteOrder()
      Gets the value of byteOrder variable.
      VPFColumn getColumn​(int index)  
      VPFColumn getColumn​(String name)  
      int getColumnCount()  
      AttributeDescriptor getDescriptor​(String name)  
      String getDirectoryName()
      Returns the directory name for this file by chopping off the file name and the separator.
      SimpleFeatureType getFeatureType()  
      String getFileName()
      Returns the file name (without path) for the file
      String getNarrativeTable()
      Gets the value of narrativeTable variable file name.
      String getPathName()
      Gets the full path name for this file
      protected int getRecordSize()
      Method getRecordSize is used to return size in bytes of records stored in this table.
      SimpleFeature getRowFromId​(String idName, int id)
      Returns a row with a matching value for the provided column
      SimpleFeature getRowFromId0​(String idName, int id)  
      String getTypeName()  
      boolean hasNext()
      Determines if the stream contains storage for another object.
      boolean isAbstract()  
      AbstractList<SimpleFeature> readAllRows()
      Generates a list containing all of the features in the file
      protected char readChar()
      Reads a single byte as a character value
      protected double readDouble()
      Retrieves a double from the file
      SimpleFeature readFeature()
      Retrieves a feature from the file
      protected Object readFixedSizeData​(char dataType, int instancesCount)
      Retrieves a fixed amount of data from the file
      protected float readFloat()
      Retrieves a floating point number from the file.
      protected Object readGeometry​(int instancesCount, int dimensionality, boolean readDoubles)
      Constructs an object which is an instance of Geometry by reading values from the file.
      protected void readHeader()
      Retrieves a number of attributes from the file header
      protected int readInteger()
      Retrieves an integer value from the file
      protected byte[] readNumber​(int cnt)
      Reads some byte data from the file
      protected short readShort()
      Retrieves a short value from the file
      protected String readString​(String terminators)
      Reads a string value from the file
      protected TripletId readTripletId()
      Retrieves a triplet object from the file
      protected Object readVariableSizeData​(char dataType)
      Retrieves variable sized data from the file by first reading an integer which indicates how many instances of the data type to retrieve
      void reset()
      Resets the file stream by setting its pointer to the first position after the header.
      protected void setPosition​(long pos)
      Sets the position in the stream
      String toString()  
      protected void unread​(long bytes)
      Back up a specified number of bytes in the file stream
      • Methods inherited from class Object

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

      • VPFFile

        public VPFFile​(String cPathName)
                throws IOException,
                       SchemaException
        Constructor.
        Parameters:
        cPathName - The path to this file
        Throws:
        IOException - if the path or the file are invalid
        SchemaException - if the contained feature type can not be constructed
    • Method Detail

      • getAttributeCount

        public int getAttributeCount()
      • getByteOrder

        public char getByteOrder()
        Gets the value of byteOrder variable. Byte order in which table is written:
        • L - least-significant-first
        • M - most-significant-first
        Returns:
        the value of byteOrder
      • getDirectoryName

        public String getDirectoryName()
        Returns the directory name for this file by chopping off the file name and the separator.
        Returns:
        the directory name for this file
      • getFileName

        public String getFileName()
        Returns the file name (without path) for the file
        Returns:
        the file name for this file
      • getNarrativeTable

        public String getNarrativeTable()
        Gets the value of narrativeTable variable file name.
        Returns:
        the value of narrativeTable
      • getPathName

        public String getPathName()
        Gets the full path name for this file
        Returns:
        the path name for this file
      • getRecordSize

        protected int getRecordSize()
        Method getRecordSize is used to return size in bytes of records stored in this table. If table keeps variable length records -1 should be returned.
        Returns:
        an int value
      • getRowFromId

        public SimpleFeature getRowFromId​(String idName,
                                          int id)
        Returns a row with a matching value for the provided column
        Parameters:
        idName - The name of the column to look for, such as "id"
        id - An identifier for the requested row
        Returns:
        The first row which matches the ID
        Throws:
        IllegalAttributeException - The feature can not be created due to illegal attributes in the source file
      • getRowFromId0

        public SimpleFeature getRowFromId0​(String idName,
                                           int id)
      • getTypeName

        public String getTypeName()
      • hasNext

        public boolean hasNext()
        Determines if the stream contains storage for another object. Who knows how well this will work on variable length objects?
        Returns:
        a boolean
      • isAbstract

        public boolean isAbstract()
      • readAllRows

        public AbstractList<SimpleFeature> readAllRows()
                                                throws IOException
        Generates a list containing all of the features in the file
        Returns:
        a List value containing Feature objects
        Throws:
        IOException - if an error occurs
      • readChar

        protected char readChar()
                         throws IOException
        Reads a single byte as a character value
        Returns:
        a char value
        Throws:
        IOException - if an error occurs
      • readGeometry

        protected Object readGeometry​(int instancesCount,
                                      int dimensionality,
                                      boolean readDoubles)
                               throws IOException
        Constructs an object which is an instance of Geometry by reading values from the file.
        Parameters:
        instancesCount - number of coordinates to read
        dimensionality - either 2 or 3
        readDoubles - true: read a double value; false: read a float value
        Returns:
        the constructed object
        Throws:
        IOException - on any file IO errors
      • readDouble

        protected double readDouble()
                             throws IOException
        Retrieves a double from the file
        Returns:
        a double value
        Throws:
        IOException - if an error occurs
      • readFixedSizeData

        protected Object readFixedSizeData​(char dataType,
                                           int instancesCount)
                                    throws IOException
        Retrieves a fixed amount of data from the file
        Parameters:
        dataType - a char value indicating the data type
        instancesCount - an int value indicating the number of instances to retrieve.
        Returns:
        an Object value
        Throws:
        IOException - if an error occurs
      • readFloat

        protected float readFloat()
                           throws IOException
        Retrieves a floating point number from the file.
        Returns:
        a float value
        Throws:
        IOException - if an error occurs
      • readInteger

        protected int readInteger()
                           throws IOException
        Retrieves an integer value from the file
        Returns:
        an int value
        Throws:
        IOException - if an error occurs
      • readNumber

        protected byte[] readNumber​(int cnt)
                             throws IOException
        Reads some byte data from the file
        Parameters:
        cnt - an int value indicating the number of bytes to retrieve
        Returns:
        a byte[] value
        Throws:
        IOException - if an error occurs
      • readShort

        protected short readShort()
                           throws IOException
        Retrieves a short value from the file
        Returns:
        a short value
        Throws:
        IOException - if an error occurs
      • readString

        protected String readString​(String terminators)
                             throws IOException
        Reads a string value from the file
        Parameters:
        terminators - a String value indicating the terminators to look for
        Returns:
        a String value
        Throws:
        IOException - if an error occurs
      • readTripletId

        protected TripletId readTripletId()
                                   throws IOException
        Retrieves a triplet object from the file
        Returns:
        a TripletId value
        Throws:
        IOException - on any IO errors
      • readVariableSizeData

        protected Object readVariableSizeData​(char dataType)
                                       throws IOException
        Retrieves variable sized data from the file by first reading an integer which indicates how many instances of the data type to retrieve
        Parameters:
        dataType - a char value indicating the data type
        Returns:
        an Object value
        Throws:
        IOException - if an error occurs
      • reset

        public void reset()
        Resets the file stream by setting its pointer to the first position after the header.
      • close

        public void close()
                   throws IOException
        Close the input stream pointed to by the object
        Throws:
        IOException - in some unlikely situation
      • setPosition

        protected void setPosition​(long pos)
                            throws IOException
        Sets the position in the stream
        Parameters:
        pos - A 1-indexed position
        Throws:
        IOException - on any IO failures
      • toString

        public String toString()
        Overrides:
        toString in class Object
      • unread

        protected void unread​(long bytes)
                       throws IOException
        Back up a specified number of bytes in the file stream
        Parameters:
        bytes - a long value
        Throws:
        IOException - if an error occurs
      • getColumn

        public VPFColumn getColumn​(int index)
      • getColumnCount

        public int getColumnCount()
      • getColumn

        public VPFColumn getColumn​(String name)