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, wait
getBitPosition, getBytePosition, setBitPosition
protected 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
BitStreamReader
readSignedBits
in interface BitStreamReader
numBits
- Number of bits to read.java.io.IOException
- If reading failed.public long readBits(int numBits) throws java.io.IOException
BitStreamReader
readBits
in interface BitStreamReader
numBits
- Number of bits to read.java.io.IOException
- If reading failed.public byte readByte() throws java.io.IOException
BitStreamReader
readByte
in interface BitStreamReader
java.io.IOException
- If reading failed.public short readUnsignedByte() throws java.io.IOException
BitStreamReader
readUnsignedByte
in interface BitStreamReader
java.io.IOException
- If reading failed.public short readShort() throws java.io.IOException
BitStreamReader
readShort
in interface BitStreamReader
java.io.IOException
- If reading failed.public int readUnsignedShort() throws java.io.IOException
BitStreamReader
readUnsignedShort
in interface BitStreamReader
java.io.IOException
- If reading failed.public int readInt() throws java.io.IOException
BitStreamReader
readInt
in interface BitStreamReader
java.io.IOException
- If reading failed.public long readUnsignedInt() throws java.io.IOException
BitStreamReader
readUnsignedInt
in interface BitStreamReader
java.io.IOException
- If reading failed.public long readLong() throws java.io.IOException
BitStreamReader
readLong
in interface BitStreamReader
java.io.IOException
- If reading failed.public java.math.BigInteger readBigInteger(int numBits) throws java.io.IOException
BitStreamReader
readBigInteger
in interface BitStreamReader
numBits
- Number of bits to read.java.io.IOException
- If reading failed.public java.math.BigInteger readSignedBigInteger(int numBits) throws java.io.IOException
BitStreamReader
readSignedBigInteger
in interface BitStreamReader
numBits
- Number of bits to read.java.io.IOException
- If reading failed.public float readFloat16() throws java.io.IOException
BitStreamReader
readFloat16
in interface BitStreamReader
java.io.IOException
- If reading failed.public float readFloat32() throws java.io.IOException
BitStreamReader
readFloat32
in interface BitStreamReader
java.io.IOException
- If reading failed.public double readFloat64() throws java.io.IOException
BitStreamReader
readFloat64
in interface BitStreamReader
java.io.IOException
- If reading failed.public byte[] readBytes() throws java.io.IOException
BitStreamReader
readBytes
in interface BitStreamReader
java.io.IOException
- If reading failed.public java.lang.String readString() throws java.io.IOException
BitStreamReader
readString
in interface BitStreamReader
java.io.IOException
- If reading failed.public boolean readBool() throws java.io.IOException
BitStreamReader
readBool
in interface BitStreamReader
java.io.IOException
- If reading failed.public short readVarInt16() throws java.io.IOException
BitStreamReader
readVarInt16
in interface BitStreamReader
java.io.IOException
- If reading failed.public int readVarInt32() throws java.io.IOException
BitStreamReader
readVarInt32
in interface BitStreamReader
java.io.IOException
- If reading failed.public long readVarInt64() throws java.io.IOException
BitStreamReader
readVarInt64
in interface BitStreamReader
java.io.IOException
- If reading failed.public short readVarUInt16() throws java.io.IOException
BitStreamReader
readVarUInt16
in interface BitStreamReader
java.io.IOException
- If reading failed.public int readVarUInt32() throws java.io.IOException
BitStreamReader
readVarUInt32
in interface BitStreamReader
java.io.IOException
- If reading failed.public long readVarUInt64() throws java.io.IOException
BitStreamReader
readVarUInt64
in interface BitStreamReader
java.io.IOException
- If reading failed.public long readVarInt() throws java.io.IOException
BitStreamReader
readVarInt
in interface BitStreamReader
java.io.IOException
- If reading failed.public java.math.BigInteger readVarUInt() throws java.io.IOException
BitStreamReader
readVarUInt
in interface BitStreamReader
java.io.IOException
- If reading failed.public int readVarSize() throws java.io.IOException
BitStreamReader
readVarSize
in interface BitStreamReader
java.io.IOException
- If reading failed.public BitBuffer readBitBuffer() throws java.io.IOException
BitStreamReader
readBitBuffer
in interface BitStreamReader
java.io.IOException
- If reading failed.public void alignTo(int alignVal) throws java.io.IOException
BitStreamReader
alignTo
in interface BitStreamReader
alignVal
- An aligning value to use.java.io.IOException
- If the alignment failed.public long getBufferBitSize()
BitStreamReader
getBufferBitSize
in interface BitStreamReader
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
protected 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 2024-12-05 10:34:50