Class FlateFilterDecoderStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class FlateFilterDecoderStream
    extends java.io.FilterInputStream
    Stream based decoder for the flate filter which uses zlib/deflate compression. Use Inflater instead of InflateInputStream to avoid an EOFException due to a probably missing Z_STREAM_END, see PDFBOX-1232 for details.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] buffer  
      private int bytesDecoded  
      private int currentDataIndex  
      private byte[] decodedData  
      private java.util.zip.Inflater inflater  
      private boolean isEOF  
      private static org.apache.commons.logging.Log LOG  
      • Fields inherited from class java.io.FilterInputStream

        in
    • Constructor Summary

      Constructors 
      Constructor Description
      FlateFilterDecoderStream​(java.io.InputStream inputStream)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Unsupported.
      void close()
      This will close the underlying stream and release any resources.
      private boolean fetch()  
      void mark​(int readlimit)
      Unsupported.
      boolean markSupported()
      mark/reset isn't supported.
      int read()
      This will read the next byte from the stream.
      int read​(byte[] data, int offset, int length)
      This will read a chunk of data.
      void reset()
      Unsupported.
      long skip​(long n)
      Unsupported.
      • Methods inherited from class java.io.FilterInputStream

        read
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • isEOF

        private boolean isEOF
      • currentDataIndex

        private int currentDataIndex
      • bytesDecoded

        private int bytesDecoded
      • buffer

        private byte[] buffer
      • decodedData

        private byte[] decodedData
      • inflater

        private final java.util.zip.Inflater inflater
    • Constructor Detail

      • FlateFilterDecoderStream

        public FlateFilterDecoderStream​(java.io.InputStream inputStream)
                                 throws java.io.IOException
        Constructor.
        Parameters:
        inputStream - The input stream to actually read from.
        Throws:
        java.io.IOException
    • Method Detail

      • fetch

        private boolean fetch()
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        This will read the next byte from the stream.
        Overrides:
        read in class java.io.FilterInputStream
        Returns:
        The next byte read from the stream.
        Throws:
        java.io.IOException - If there is an error reading from the wrapped stream.
      • read

        public int read​(byte[] data,
                        int offset,
                        int length)
                 throws java.io.IOException
        This will read a chunk of data.
        Overrides:
        read in class java.io.FilterInputStream
        Parameters:
        data - The buffer to write data to.
        offset - The offset into the data stream.
        length - The number of byte to attempt to read.
        Returns:
        The number of bytes actually read.
        Throws:
        java.io.IOException - If there is an error reading data from the underlying stream.
      • close

        public void close()
                   throws java.io.IOException
        This will close the underlying stream and release any resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterInputStream
        Throws:
        java.io.IOException - If there is an error closing the underlying stream.
      • markSupported

        public boolean markSupported()
        mark/reset isn't supported.
        Overrides:
        markSupported in class java.io.FilterInputStream
        Returns:
        always false.
      • skip

        public long skip​(long n)
        Unsupported.
        Overrides:
        skip in class java.io.FilterInputStream
        Parameters:
        n - ignored.
        Returns:
        always zero.
      • available

        public int available()
        Unsupported.
        Overrides:
        available in class java.io.FilterInputStream
        Returns:
        always zero.
      • mark

        public void mark​(int readlimit)
        Unsupported.
        Overrides:
        mark in class java.io.FilterInputStream
        Parameters:
        readlimit - ignored.
      • reset

        public void reset()
                   throws java.io.IOException
        Unsupported.
        Overrides:
        reset in class java.io.FilterInputStream
        Throws:
        java.io.IOException - always throw as reset is an unsupported feature.