public final class ValidationBitStreamReader extends ByteArrayBitStreamReader
The validation bit stream reader records - a special 'AND' bit mask (invalidMaskBuffer) which contains '1' if corresponding bit in read buffer is not used for validation and - a special 'OR' bit mask (nanMaskBuffer) which constains normalized NaN values (NaNs used by writer).
Bits in reader do not have to be used for validation in the following situations: 1. If the bits have been skipped (not read) which can happen using Zserio 'align' command for example. 2. If NaN occurs. NaNs do not have unique binary representation and they must be normalized to NaNs used by writer.
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 |
---|
ValidationBitStreamReader(byte[] bytes)
Constructs a new ValidationBitStreamReader.
|
Modifier and Type | Method and Description |
---|---|
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.
|
int |
getBitOffset()
Gets the current bit offset.
|
long |
getBitPosition()
Gets the current bit position.
|
int |
getBytePosition()
Gets the current byte position.
|
float |
readFloat16()
Reads the a float16 value from the bit stream.
|
void |
setBitPosition(long bitPosition)
Sets the bit position to the given value.
|
byte[] |
toMaskedByteArray()
Returns the read byte array with unused bits set to zero and with 'normalized' NaNs.
|
alignTo, close, getBuffer, getBufferBitSize, readBigInteger, readBitBuffer, readBits, readBool, readByte, readBytes, readFloat32, readFloat64, readInt, readLong, readShort, readSignedBigInteger, readSignedBits, readString, readUnsignedByte, readUnsignedInt, readUnsignedShort, readVarInt, readVarInt16, readVarInt32, readVarInt64, readVarSize, readVarUInt, readVarUInt16, readVarUInt32, readVarUInt64
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBitPosition, getBytePosition
protected int bytePosition
protected int bitOffset
protected static final java.lang.String DEFAULT_CHARSET_NAME
protected static final byte BYTE_MOD_MASK
public ValidationBitStreamReader(byte[] bytes)
bytes
- Array of bytes to construct from.public byte[] toMaskedByteArray()
public void setBitPosition(long bitPosition) throws java.io.IOException
setBitPosition
in interface BitStreamReader
bitPosition
- Bit position to set.java.io.IOException
- Throws in case of any error.public float readFloat16() throws java.io.IOException
BitStreamReader
readFloat16
in interface BitStreamReader
readFloat16
in class ByteArrayBitStreamReader
java.io.IOException
- If reading failed.public long getBitPosition()
public int getBytePosition()
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