public interface BitField
| Modifier and Type | Method and Description |
|---|---|
void |
copyBits(long sourceStart,
long numberOfBits,
long destStart)
Copies the specified number of bits from one position in the bit field to another.
|
void |
insertBits(long start,
long numberOfBits)
Inserts the specified number of bits at the specified position of the bit field and moves all bits
with indices
>= start to the right. |
long |
length()
Returns the current length of the bit field.
|
void |
moveBits(long sourceStart,
long numberOfBits,
long destStart)
Moves the specified number of bits from one position in the bit field to another.
|
boolean |
readBoolean(long position)
Interprets the bit at the specified position as a boolean value.
|
byte |
readByte(long start,
long numberOfBits)
Reads a signed integer with the specified length and returns it as a
byte value. |
int |
readInt(long start,
long numberOfBits)
Reads a signed integer with the specified length and returns it as a
int value. |
long |
readLong(long start,
long numberOfBits)
Reads a signed integer with the specified length and returns it as a
long value. |
short |
readShort(long start,
long numberOfBits)
Reads a signed integer with the specified length and returns it as a
short value. |
byte |
readUnsignedByte(long start,
long numberOfBits)
Reads an unsigned integer with the specified length and returns it as a
byte value. |
int |
readUnsignedInt(long start,
long numberOfBits)
Reads an unsigned integer with the specified length and returns it as a
int value. |
long |
readUnsignedLong(long start,
long numberOfBits)
Reads an unsigned integer with the specified length and returns it as a
long value. |
short |
readUnsignedShort(long start,
long numberOfBits)
Reads an unsigned integer with the specified length and returns it as a
short value. |
void |
removeBits(long start,
long numberOfBits)
Removes the specified number of bits from the specified position of the bit field and moves all bits
with indices
>= start + numberOfBits to the left. |
void |
writeBoolean(boolean value,
long position)
Sets the bit at the specified position according the specified boolean value.
|
void |
writeByte(byte value,
long start,
long numberOfBits) |
void |
writeInt(int value,
long start,
long numberOfBits) |
void |
writeLong(long value,
long start,
long numberOfBits) |
void |
writeShort(short value,
long start,
long numberOfBits) |
void |
writeUnsignedByte(byte value,
long start,
long numberOfBits) |
void |
writeUnsignedInt(int value,
long start,
long numberOfBits) |
void |
writeUnsignedLong(long value,
long start,
long numberOfBits) |
void |
writeUnsignedShort(short value,
long start,
long numberOfBits) |
void insertBits(long start, long numberOfBits) throws BitIndexOutOfBoundException
>= start to the right. The new bit area is not necessarily initialized.start - the index where the first bit shall be insertednumberOfBits - the number of bits to be insertedBitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()void removeBits(long start, long numberOfBits) throws BitIndexOutOfBoundException
>= start + numberOfBits to the left.start - the index where the first bit shall be insertednumberOfBits - the number of bits to be insertedBitIndexOutOfBoundExceptionvoid copyBits(long sourceStart, long numberOfBits, long destStart) throws BitIndexOutOfBoundException
sourceStart - the index of the first bit to be copiednumberOfBits - the number of bits to be copieddestStart - the index where the left most bit of the copied area shall be written toBitIndexOutOfBoundException - if sourceStart or sourceStart are lower than 0 or
sourceStart + numberOfBits or sourceStart + numberOfBits are greater than
length() or if the source and the destination area overlapvoid moveBits(long sourceStart, long numberOfBits, long destStart) throws BitIndexOutOfBoundException
copyBits(long, long, long) with the only difference that the source and the destination area
are allowed to overlap.sourceStart - the index of the first bit to be copiednumberOfBits - the number of bits to be copieddestStart - the index where the left most bit of the moved area shall be written toBitIndexOutOfBoundException - if sourceStart or sourceStart are lower than 0 or
sourceStart + numberOfBits or sourceStart + numberOfBits are greater than
length()long length()
byte readByte(long start, long numberOfBits) throws BitIndexOutOfBoundException
byte value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be read (The first left most bit determines the
algebraic sign.)BitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()byte readUnsignedByte(long start, long numberOfBits) throws BitIndexOutOfBoundException
byte value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be readBitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()void writeByte(byte value, long start, long numberOfBits) throws BitIndexOutOfBoundException
value - start - numberOfBits - BitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()void writeUnsignedByte(byte value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionshort readShort(long start, long numberOfBits) throws BitIndexOutOfBoundException
short value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be read (The first left most bit determines the
algebraic sign.)BitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()short readUnsignedShort(long start, long numberOfBits) throws BitIndexOutOfBoundException
short value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be readBitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()void writeShort(short value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionvoid writeUnsignedShort(short value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionint readInt(long start, long numberOfBits) throws BitIndexOutOfBoundException
int value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be read (The first left most bit determines the
algebraic sign.)BitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()int readUnsignedInt(long start, long numberOfBits) throws BitIndexOutOfBoundException
int value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be readBitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()void writeInt(int value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionvoid writeUnsignedInt(int value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionlong readLong(long start, long numberOfBits) throws BitIndexOutOfBoundException
long value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be read (The first left most bit determines the
algebraic sign.)BitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()long readUnsignedLong(long start, long numberOfBits) throws BitIndexOutOfBoundException
long value.start - the index of the bit in the bit field that shall be interpreted as the beginning of
the integer valuenumberOfBits - the number of bits to be readBitIndexOutOfBoundException - if start is lower than 0 or start + numberOfBits
is greater than length()void writeLong(long value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionvoid writeUnsignedLong(long value, long start, long numberOfBits) throws BitIndexOutOfBoundException
BitIndexOutOfBoundExceptionboolean readBoolean(long position) throws BitIndexOutOfBoundException
position - the position of the bit to be readtrue if the specified bit is set, false otherwiseBitIndexOutOfBoundException - if position is lower than 0 or greater or equal to
length()void writeBoolean(boolean value, long position) throws BitIndexOutOfBoundException
value - Determine whether the bit shall be set to 0 or 1position - the index of the bit in the fieldBitIndexOutOfBoundException - if position is lower than 0 or greater or equal to
length()