public class GZIPContentDecoder extends Object implements Destroyable
A decoder that inflates gzip compressed data that has been optimized for async usage with minimal data copies.
Constructor and Description |
---|
GZIPContentDecoder() |
GZIPContentDecoder(ByteBufferPool pool,
int bufferSize) |
GZIPContentDecoder(int bufferSize) |
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
acquire(int capacity) |
ByteBuffer |
decode(ByteBuffer compressed)
Inflate compressed data from a buffer.
|
protected void |
decodeChunks(ByteBuffer compressed)
Inflate compressed data.
|
protected boolean |
decodedChunk(ByteBuffer chunk)
Called when a chunk of data is inflated.
|
void |
destroy() |
boolean |
isFinished() |
void |
release(ByteBuffer buffer)
Release an allocated buffer.
|
public GZIPContentDecoder()
public GZIPContentDecoder(int bufferSize)
public GZIPContentDecoder(ByteBufferPool pool, int bufferSize)
public ByteBuffer decode(ByteBuffer compressed)
compressed
- Buffer containing compressed data.protected boolean decodedChunk(ByteBuffer chunk)
The default implementation aggregates all the chunks
into a single buffer returned from decode(ByteBuffer)
.
Derived implementations may choose to consume chunks individually
and return false to prevent further inflation until a subsequent
call to decode(ByteBuffer)
or decodeChunks(ByteBuffer)
.
chunk
- The inflated chunk of datadecodeChunks(ByteBuffer)
or decode(ByteBuffer)
should return, allowing back pressure of compressed data.protected void decodeChunks(ByteBuffer compressed)
Inflation continues until the compressed block end is reached, there is no
more compressed data or a call to decodedChunk(ByteBuffer)
returns true.
compressed
- Buffer of compressed data to inflatepublic void destroy()
destroy
in interface Destroyable
public boolean isFinished()
public ByteBuffer acquire(int capacity)
public void release(ByteBuffer buffer)
This method will called ByteBufferPool.release(ByteBuffer)
if a buffer pool has
been configured. This method should be called once for all buffers returned from decode(ByteBuffer)
or passed to decodedChunk(ByteBuffer)
.
buffer
- The buffer to release.Copyright © 1995–2017 Webtide. All rights reserved.