public class ByteArrayBitStreamReader extends java.lang.Object implements BitStreamReader
| Modifier and Type | Field and Description |
|---|---|
protected int |
bitOffset
The current bit offset.
|
protected static byte |
BYTE_MOD_MASK
Byte value used for modulus calculations.
|
protected int |
bytePosition
The current byte position.
|
protected static java.lang.String |
DEFAULT_CHARSET_NAME
The default character set.
|
| Constructor and Description |
|---|
ByteArrayBitStreamReader(BitBuffer bitBuffer)
Constructs object using given bit buffer.
|
ByteArrayBitStreamReader(byte[] bytes)
Constructs object containing given bytes with a given byte order.
|
ByteArrayBitStreamReader(byte[] bytes,
long bitSize)
Constructs object containing given bytes with a given byte order with exact bit size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
alignTo(int alignVal)
Aligns the bit position according to the aligning value.
|
protected static void |
checkRange(int numBits)
Checks if the given numBits value is situated in the range 0 to 64.
|
protected static void |
checkUnsignedRange(int numBits)
Checks if the given numBits value is situated in the range 0 to 63.
|
void |
close() |
int |
getBitOffset()
Gets the current bit offset.
|
long |
getBitPosition()
Gets the current bit position.
|
protected byte[] |
getBuffer()
Gets the underlying buffer.
|
long |
getBufferBitSize()
Gets size of the underlying buffer in bits.
|
int |
getBytePosition()
Gets the current byte position.
|
java.math.BigInteger |
readBigInteger(int numBits)
Reads the next unsigned Big Integer value with containing numBits bits.
|
BitBuffer |
readBitBuffer()
Reads a bit buffer from the bit stream.
|
long |
readBits(int numBits)
Reads the next numBits of the bit stream as long value.
|
boolean |
readBool()
Reads a Boolean value from the bit stream.
|
byte |
readByte()
Reads the next signed byte (8 bits).
|
byte[] |
readBytes()
Reads a Zserio bytes from the bit stream.
|
float |
readFloat16()
Reads the a float16 value from the bit stream.
|
float |
readFloat32()
Reads the a float32 value from the bit stream.
|
double |
readFloat64()
Reads the a float64 value from the bit stream.
|
int |
readInt()
Reads the next signed integer (32 bits).
|
long |
readLong()
Reads the next signed long (64 bits).
|
short |
readShort()
Reads the next signed short (16 bits).
|
java.math.BigInteger |
readSignedBigInteger(int numBits)
Reads the next signed big Integer value with containing numBits bits.
|
long |
readSignedBits(int numBits)
Reads the next numBits as signed bit value.
|
java.lang.String |
readString()
Reads a Zserio string from the bit stream assuming it is encoded in UTF-8.
|
short |
readUnsignedByte()
Reads the next unsigned byte (8 bits) as short value.
|
long |
readUnsignedInt()
Reads the next unsigned integer (32 bits) as long value.
|
int |
readUnsignedShort()
Read the next unsigned short (16 bits) as int value.
|
long |
readVarInt()
Reads a signed variable integer from the bit stream.
|
short |
readVarInt16()
Reads a variable 16 bit integer from the bit stream.
|
int |
readVarInt32()
Reads a variable 32 bit integer from the bit stream.
|
long |
readVarInt64()
Reads a variable 64 bit integer from the bit stream.
|
int |
readVarSize()
Reads a variable size integer from the bit stream.
|
java.math.BigInteger |
readVarUInt()
Reads an unsigned variable integer from the bit stream.
|
short |
readVarUInt16()
Reads an unsigned variable 16 bit integer from the bit stream.
|
int |
readVarUInt32()
Reads an unsigned variable 32 bit integer from the bit stream.
|
long |
readVarUInt64()
Reads an unsigned variable 64 bit integer from the bit stream.
|
void |
setBitPosition(long bitPosition)
Sets the bit position to the given value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBitPosition, getBytePosition, setBitPositionprotected int bytePosition
protected int bitOffset
protected static final java.lang.String DEFAULT_CHARSET_NAME
protected static final byte BYTE_MOD_MASK
public ByteArrayBitStreamReader(byte[] bytes)
bytes - Array of bytes to construct from.public ByteArrayBitStreamReader(BitBuffer bitBuffer)
bitBuffer - Bit buffer to construct from.public ByteArrayBitStreamReader(byte[] bytes,
long bitSize)
bytes - Array of bytes to construct from.bitSize - Size of the buffer in bits.public long readSignedBits(int numBits)
throws java.io.IOException
BitStreamReaderreadSignedBits in interface BitStreamReadernumBits - Number of bits to read.java.io.IOException - If reading failed.public long readBits(int numBits)
throws java.io.IOException
BitStreamReaderreadBits in interface BitStreamReadernumBits - Number of bits to read.java.io.IOException - If reading failed.public byte readByte()
throws java.io.IOException
BitStreamReaderreadByte in interface BitStreamReaderjava.io.IOException - If reading failed.public short readUnsignedByte()
throws java.io.IOException
BitStreamReaderreadUnsignedByte in interface BitStreamReaderjava.io.IOException - If reading failed.public short readShort()
throws java.io.IOException
BitStreamReaderreadShort in interface BitStreamReaderjava.io.IOException - If reading failed.public int readUnsignedShort()
throws java.io.IOException
BitStreamReaderreadUnsignedShort in interface BitStreamReaderjava.io.IOException - If reading failed.public int readInt()
throws java.io.IOException
BitStreamReaderreadInt in interface BitStreamReaderjava.io.IOException - If reading failed.public long readUnsignedInt()
throws java.io.IOException
BitStreamReaderreadUnsignedInt in interface BitStreamReaderjava.io.IOException - If reading failed.public long readLong()
throws java.io.IOException
BitStreamReaderreadLong in interface BitStreamReaderjava.io.IOException - If reading failed.public java.math.BigInteger readBigInteger(int numBits)
throws java.io.IOException
BitStreamReaderreadBigInteger in interface BitStreamReadernumBits - Number of bits to read.java.io.IOException - If reading failed.public java.math.BigInteger readSignedBigInteger(int numBits)
throws java.io.IOException
BitStreamReaderreadSignedBigInteger in interface BitStreamReadernumBits - Number of bits to read.java.io.IOException - If reading failed.public float readFloat16()
throws java.io.IOException
BitStreamReaderreadFloat16 in interface BitStreamReaderjava.io.IOException - If reading failed.public float readFloat32()
throws java.io.IOException
BitStreamReaderreadFloat32 in interface BitStreamReaderjava.io.IOException - If reading failed.public double readFloat64()
throws java.io.IOException
BitStreamReaderreadFloat64 in interface BitStreamReaderjava.io.IOException - If reading failed.public byte[] readBytes()
throws java.io.IOException
BitStreamReaderreadBytes in interface BitStreamReaderjava.io.IOException - If reading failed.public java.lang.String readString()
throws java.io.IOException
BitStreamReaderreadString in interface BitStreamReaderjava.io.IOException - If reading failed.public boolean readBool()
throws java.io.IOException
BitStreamReaderreadBool in interface BitStreamReaderjava.io.IOException - If reading failed.public short readVarInt16()
throws java.io.IOException
BitStreamReaderreadVarInt16 in interface BitStreamReaderjava.io.IOException - If reading failed.public int readVarInt32()
throws java.io.IOException
BitStreamReaderreadVarInt32 in interface BitStreamReaderjava.io.IOException - If reading failed.public long readVarInt64()
throws java.io.IOException
BitStreamReaderreadVarInt64 in interface BitStreamReaderjava.io.IOException - If reading failed.public short readVarUInt16()
throws java.io.IOException
BitStreamReaderreadVarUInt16 in interface BitStreamReaderjava.io.IOException - If reading failed.public int readVarUInt32()
throws java.io.IOException
BitStreamReaderreadVarUInt32 in interface BitStreamReaderjava.io.IOException - If reading failed.public long readVarUInt64()
throws java.io.IOException
BitStreamReaderreadVarUInt64 in interface BitStreamReaderjava.io.IOException - If reading failed.public long readVarInt()
throws java.io.IOException
BitStreamReaderreadVarInt in interface BitStreamReaderjava.io.IOException - If reading failed.public java.math.BigInteger readVarUInt()
throws java.io.IOException
BitStreamReaderreadVarUInt in interface BitStreamReaderjava.io.IOException - If reading failed.public int readVarSize()
throws java.io.IOException
BitStreamReaderreadVarSize in interface BitStreamReaderjava.io.IOException - If reading failed.public BitBuffer readBitBuffer() throws java.io.IOException
BitStreamReaderreadBitBuffer in interface BitStreamReaderjava.io.IOException - If reading failed.public void alignTo(int alignVal)
throws java.io.IOException
BitStreamReaderalignTo in interface BitStreamReaderalignVal - An aligning value to use.java.io.IOException - If the alignment failed.public long getBufferBitSize()
BitStreamReadergetBufferBitSize in interface BitStreamReaderpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionprotected byte[] getBuffer()
public long getBitPosition()
public int getBytePosition()
public void setBitPosition(long bitPosition)
throws java.io.IOException
bitPosition - Bit position to set.java.io.IOException - Throws in case of any error.public int getBitOffset()
protected static void checkRange(int numBits)
throws java.lang.IllegalArgumentException
numBits - Number of bits to check.java.lang.IllegalArgumentException - If the numBits value is smaller than zero or greater than 64.protected static void checkUnsignedRange(int numBits)
throws java.lang.IllegalArgumentException
numBits - Number of bits to check.java.lang.IllegalArgumentException - If the numBits value is smaller than zero or greater than 63.Last updated 2025-10-02 14:26:25