Class AbstractCommonShapeFileWriter<E>

    • Field Detail

      • BLOCK_SIZE

        protected static final int BLOCK_SIZE
        Size of a block of data in the buffer, when the seek feature was disable.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractCommonShapeFileWriter

        public AbstractCommonShapeFileWriter​(File shapeName,
                                             ShapeElementType elementType)
                                      throws IOException
        Constructor.
        Parameters:
        shapeName - is the file to write
        elementType - is the type of the elements to write.
        Throws:
        IOException - in case of error.
      • AbstractCommonShapeFileWriter

        public AbstractCommonShapeFileWriter​(URL shapeName,
                                             ShapeElementType elementType)
                                      throws IOException
        Constructor.
        Parameters:
        shapeName - is the file to write
        elementType - is the type of the elements to write.
        Throws:
        IOException - in case of error.
      • AbstractCommonShapeFileWriter

        public AbstractCommonShapeFileWriter​(OutputStream stream,
                                             ShapeElementType elementType)
                                      throws IOException
        Constructor.
        Parameters:
        stream - is the file to write
        elementType - is the type of the elements to write.
        Throws:
        IOException - in case of error.
      • AbstractCommonShapeFileWriter

        public AbstractCommonShapeFileWriter​(WritableByteChannel channel,
                                             ShapeElementType elementType)
                                      throws IOException
        Constructor.
        Parameters:
        channel - is the file to write
        elementType - is the type of the elements to write.
        Throws:
        IOException - in case of error.
    • Method Detail

      • getElementType

        public ShapeElementType getElementType()
        Replies the type of the elements which will be written into the output stream.
        Returns:
        the type of the written elements.
      • getTaskProgression

        public Progression getTaskProgression()
        Replies the task progression.
        Returns:
        the task progression object associated to this writer, or null
      • setTaskProgression

        public void setTaskProgression​(Progression progressBar)
        Set the task progression associated to this writer.
        Parameters:
        progressBar - is the task progression object associated to this writer, or null
      • isHeaderWritten

        protected boolean isHeaderWritten()
        Replies if the header was red.
        Returns:
        true if the header was red, otherwise false
      • flush

        protected void flush()
                      throws IOException
        Force this writer to write the memory buffer inside the temporary file.
        Throws:
        IOException - in case of error.
      • ensureAvailableBytes

        protected void ensureAvailableBytes​(int amount)
                                     throws IOException
        Ensure that the reading buffer is containing enoug bytes to read.
        Parameters:
        amount - is the count of expected bytes
        Throws:
        IOException - in case of error.
      • writeBEInt

        protected final void writeBEInt​(int v)
                                 throws IOException
        Write a big endian 4-byte integer.
        Parameters:
        v - is a big endian 4-byte integer.
        Throws:
        IOException - in case of error.
      • writeBEDouble

        protected final void writeBEDouble​(double v)
                                    throws IOException
        Write a big endian 8-byte floating point number.
        Parameters:
        v - is a big endian 8-byte floating point number.
        Throws:
        IOException - in case of error.
      • writeLEInt

        protected final void writeLEInt​(int v)
                                 throws IOException
        Write a little endian 4-byte integer.
        Parameters:
        v - is a little endian 4-byte integer.
        Throws:
        IOException - in case of error.
      • writeLEDouble

        protected final void writeLEDouble​(double v)
                                    throws IOException
        Write a little endian 8-byte floating point number.
        Parameters:
        v - is a little endian 8-byte floating point number.
        Throws:
        IOException - in case of error.
      • onHeaderWritten

        protected void onHeaderWritten​(ESRIBounds box,
                                       ShapeElementType type,
                                       Collection<? extends E> elements)
                                throws IOException
        Invoked after the header was written.
        Parameters:
        box - is the bouding box of the file
        type - is the type of the elements in the file.
        elements - are the elements which are caused the header to be written.
        Throws:
        IOException - in case of error.
      • close

        public void close()
                   throws IOException
        Flush temp buffers, write down final information in file header (file size...), and close the streams.
        Specified by:
        close in interface AutoCloseable
        Throws:
        IOException - in case of error.
      • write

        public final void write​(E element)
                         throws IOException
        Write the Shape file and its associated files.
        Parameters:
        element - is the elements to write down
        Throws:
        IOException - in case of error.
      • write

        public void write​(Collection<? extends E> elements)
                   throws IOException
        Write the Shape file and its associated files.
        Parameters:
        elements - are the elements to write down
        Throws:
        IOException - in case of error.
      • writeElement

        protected abstract void writeElement​(int recIndex,
                                             E element,
                                             ShapeElementType type)
                                      throws IOException
        Write an element inside the output stream.
        Parameters:
        recIndex - is the index of the element in the file.
        element - is the element to write.
        type - is the expected type for the element.
        Throws:
        IOException - in case of error.
      • getFileBounds

        protected abstract ESRIBounds getFileBounds()
        Invoked to retrieve the bounds of the world.
        Returns:
        the bounds.