Class AbstractLZ77CompressorInputStream

    • Method Detail

      • getSize

        public int getSize()
        Get the uncompressed size of the stream
        Returns:
        the uncompressed size
      • prefill

        public void prefill​(byte[] data)
        Adds some initial data to fill the window with.

        This is used if the stream has been cut into blocks and back-references of one block may refer to data of the previous block(s). One such example is the LZ4 frame format using block dependency.

        Parameters:
        data - the data to fill the window with.
        Throws:
        IllegalStateException - if the stream has already started to read data
      • startLiteral

        protected final void startLiteral​(long length)
        Used by subclasses to signal the next block contains the given amount of literal data.
        Parameters:
        length - the length of the block
        Throws:
        IllegalArgumentException - if length is negative
      • hasMoreDataInBlock

        protected final boolean hasMoreDataInBlock()
        Is there still data remaining inside the current block?
        Returns:
        true if there is still data remaining inside the current block.
      • readLiteral

        protected final int readLiteral​(byte[] b,
                                        int off,
                                        int len)
                                 throws IOException
        Reads data from the current literal block.
        Parameters:
        b - buffer to write data to
        off - offset to start writing to
        len - maximum amount of data to read
        Returns:
        number of bytes read, may be 0. Will never return -1 as EOF-detection is the responsibility of the subclass
        Throws:
        IOException - if the underlying stream throws or signals an EOF before the amount of data promised for the block have been read
        NullPointerException - if b is null
        IndexOutOfBoundsException - if off is negative, len is negative, or len is greater than b.length - off
      • startBackReference

        protected final void startBackReference​(int offset,
                                                long length)
        Used by subclasses to signal the next block contains a back-reference with the given coordinates.
        Parameters:
        offset - the offset of the back-reference
        length - the length of the back-reference
        Throws:
        IllegalArgumentException - if offset not bigger than 0 or bigger than the number of bytes available for back-references or if length is negative
      • readBackReference

        protected final int readBackReference​(byte[] b,
                                              int off,
                                              int len)
        Reads data from the current back-reference.
        Parameters:
        b - buffer to write data to
        off - offset to start writing to
        len - maximum amount of data to read
        Returns:
        number of bytes read, may be 0. Will never return -1 as EOF-detection is the responsibility of the subclass
        Throws:
        NullPointerException - if b is null
        IndexOutOfBoundsException - if off is negative, len is negative, or len is greater than b.length - off
      • readOneByte

        protected final int readOneByte()
                                 throws IOException
        Reads a single byte from the real input stream and ensures the data is accounted for.
        Returns:
        the byte read as value between 0 and 255 or -1 if EOF has been reached.
        Throws:
        IOException - if the underlying stream throws