All Implemented Interfaces:
Closeable, AutoCloseable, Channel, ReadableByteChannel

final class ZIP extends CompressionChannel
Inflater for values encoded with the "Deflate" compression.
Since:
1.1
Version:
1.3
  • Field Details

    • inflater

      private final Inflater inflater
      Access to the ZLIB compression library. Must be released by call to Inflater.end() after decompression is completed.
  • Constructor Details

    • ZIP

      public ZIP(ChannelDataInput input, StoreListeners listeners)
      Creates a new channel which will decompress data from the given input. The setInputRegion(long, long) method must be invoked after construction before a reading process can start.
      Parameters:
      input - the source of data to decompress.
      listeners - object where to report warnings.
      start - stream position where to start reading.
      byteCount - number of bytes to read from the input.
      Throws:
      IOException - if the stream cannot be seek to the given start position.
  • Method Details

    • setInputRegion

      public void setInputRegion(long start, long byteCount) throws IOException
      Prepares this inflater for reading a new tile or a new band of a tile.
      Overrides:
      setInputRegion in class CompressionChannel
      Parameters:
      start - stream position where to start reading.
      byteCount - number of bytes to read from the input.
      Throws:
      IOException - if the stream cannot be seek to the given start position.
    • read

      public int read(ByteBuffer target) throws IOException
      Decompresses some bytes from the input into the given destination buffer.
      Parameters:
      target - the buffer into which bytes are to be transferred.
      Returns:
      the number of bytes read, or -1 if end-of-stream.
      Throws:
      IOException - if some other I/O error occurs.
    • inflate

      private int inflate(ByteBuffer target) throws DataFormatException
      Placeholder for Inflater.inflate(ByteBuffer).
      Throws:
      DataFormatException
    • setInput

      private void setInput(ByteBuffer target) throws DataFormatException
      Placeholder for Inflater.setInput(ByteBuffer).
      Throws:
      DataFormatException
    • close

      public void close()
      Releases resources used by the inflater.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Overrides:
      close in class CompressionChannel