Package com.ning.compress.gzip
Class OptimizedGZIPInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.ning.compress.gzip.OptimizedGZIPInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class OptimizedGZIPInputStream extends java.io.InputStream
Optimized variant ofGZIPInputStream
that reuses underlyingDeflater
instance}.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
OptimizedGZIPInputStream.State
Enumeration used for keeping track of decoding state within stream
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
_buffer
protected int
_bufferEnd
protected int
_bufferPtr
protected BufferRecycler
_bufferRecycler
Object that handles details of buffer recyclingprotected java.util.zip.CRC32
_crc
protected GZIPRecycler
_gzipRecycler
protected java.util.zip.Inflater
_inflater
protected java.io.InputStream
_rawInput
Underlying input stream from which compressed data is to be read from.protected OptimizedGZIPInputStream.State
_state
Flag set to true during handling of header processingprotected byte[]
_tmpBuffer
Temporary buffer used for single-byte reads, skipping.private static int
INPUT_BUFFER_SIZE
What kinds of chunks do we feed underlyingInflater
?
-
Constructor Summary
Constructors Constructor Description OptimizedGZIPInputStream(java.io.InputStream in)
OptimizedGZIPInputStream(java.io.InputStream in, BufferRecycler bufferRecycler, GZIPRecycler gzipRecycler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
_getTmpBuffer()
private void
_loadMore()
private void
_loadMore(int max)
private int
_readByte()
protected void
_readHeader()
private int
_readInt()
private int
_readShort()
protected void
_readTrailer()
private void
_skipBytes(int count)
int
available()
void
close()
void
mark(int limit)
boolean
markSupported()
int
read()
int
read(byte[] buf)
int
read(byte[] buf, int offset, int len)
void
reset()
long
skip(long n)
-
-
-
Field Detail
-
INPUT_BUFFER_SIZE
private static final int INPUT_BUFFER_SIZE
What kinds of chunks do we feed underlyingInflater
?- See Also:
- Constant Field Values
-
_inflater
protected java.util.zip.Inflater _inflater
-
_crc
protected final java.util.zip.CRC32 _crc
-
_bufferRecycler
protected final BufferRecycler _bufferRecycler
Object that handles details of buffer recycling
-
_gzipRecycler
protected final GZIPRecycler _gzipRecycler
-
_buffer
protected byte[] _buffer
-
_bufferPtr
protected int _bufferPtr
-
_bufferEnd
protected int _bufferEnd
-
_tmpBuffer
protected byte[] _tmpBuffer
Temporary buffer used for single-byte reads, skipping.
-
_rawInput
protected java.io.InputStream _rawInput
Underlying input stream from which compressed data is to be read from.
-
_state
protected OptimizedGZIPInputStream.State _state
Flag set to true during handling of header processing
-
-
Constructor Detail
-
OptimizedGZIPInputStream
public OptimizedGZIPInputStream(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
OptimizedGZIPInputStream
public OptimizedGZIPInputStream(java.io.InputStream in, BufferRecycler bufferRecycler, GZIPRecycler gzipRecycler) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
available
public int available()
- Overrides:
available
in classjava.io.InputStream
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
mark
public void mark(int limit)
- Overrides:
mark
in classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.InputStream
-
read
public final int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public final int read(byte[] buf) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public final int read(byte[] buf, int offset, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
_getTmpBuffer
protected byte[] _getTmpBuffer()
-
_readHeader
protected final void _readHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
_readTrailer
protected final void _readTrailer() throws java.io.IOException
- Throws:
java.io.IOException
-
_skipBytes
private final void _skipBytes(int count) throws java.io.IOException
- Throws:
java.io.IOException
-
_readByte
private final int _readByte() throws java.io.IOException
- Throws:
java.io.IOException
-
_readShort
private final int _readShort() throws java.io.IOException
- Throws:
java.io.IOException
-
_readInt
private final int _readInt() throws java.io.IOException
- Throws:
java.io.IOException
-
_loadMore
private final void _loadMore() throws java.io.IOException
- Throws:
java.io.IOException
-
_loadMore
private final void _loadMore(int max) throws java.io.IOException
- Throws:
java.io.IOException
-
-