Class Bzip2BitReader
- java.lang.Object
-
- io.netty.handler.codec.compression.Bzip2BitReader
-
class Bzip2BitReader extends java.lang.ObjectAn bit reader that allows the reading of single bit booleans, bit strings of arbitrary length (up to 32 bits), and bit aligned 32-bit integers. A single byte at a time is read from theByteBufwhen more bits are required.
-
-
Field Summary
Fields Modifier and Type Field Description private longbitBufferA buffer of bits read from the input stream that have not yet been returned.private intbitCountThe number of bits currently buffered inbitBuffer.private ByteBufinTheByteBuffrom which to read data.private static intMAX_COUNT_OF_READABLE_BYTESMaximum count of possible readable bytes to check.
-
Constructor Summary
Constructors Constructor Description Bzip2BitReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleanhasReadableBits(int count)Checks that the specified number of bits available for reading.(package private) booleanhasReadableBytes(int count)Checks that the specified number of bytes available for reading.(package private) booleanisReadable()Checks that at least one bit is available for reading.(package private) intreadBits(int count)Reads up to 32 bits from theByteBuf.(package private) booleanreadBoolean()Reads a single bit from theByteBuf.(package private) intreadInt()Reads 32 bits of input as an integer.(package private) voidrefill()Refill theByteBufby one byte.(package private) voidsetByteBuf(ByteBuf in)Set theByteBuffrom which to read data.
-
-
-
Field Detail
-
MAX_COUNT_OF_READABLE_BYTES
private static final int MAX_COUNT_OF_READABLE_BYTES
Maximum count of possible readable bytes to check.- See Also:
- Constant Field Values
-
bitBuffer
private long bitBuffer
A buffer of bits read from the input stream that have not yet been returned.
-
bitCount
private int bitCount
The number of bits currently buffered inbitBuffer.
-
-
Method Detail
-
readBits
int readBits(int count)
Reads up to 32 bits from theByteBuf.- Parameters:
count- The number of bits to read (maximum32as a size ofint)- Returns:
- The bits requested, right-aligned within the integer
-
readBoolean
boolean readBoolean()
Reads a single bit from theByteBuf.- Returns:
trueif the bit read was1, otherwisefalse
-
readInt
int readInt()
Reads 32 bits of input as an integer.- Returns:
- The integer read
-
refill
void refill()
Refill theByteBufby one byte.
-
isReadable
boolean isReadable()
Checks that at least one bit is available for reading.- Returns:
trueif one bit is available for reading, otherwisefalse
-
hasReadableBits
boolean hasReadableBits(int count)
Checks that the specified number of bits available for reading.- Parameters:
count- The number of bits to check- Returns:
trueifcountbits are available for reading, otherwisefalse
-
hasReadableBytes
boolean hasReadableBytes(int count)
Checks that the specified number of bytes available for reading.- Parameters:
count- The number of bytes to check- Returns:
trueifcountbytes are available for reading, otherwisefalse
-
-