Package com.itextpdf.barcodes.qrcode
Class BitVector
java.lang.Object
com.itextpdf.barcodes.qrcode.BitVector
JAVAPORT: This should be combined with BitArray in the future, although that class is not yet
dynamically resizeable. This implementation is reasonable but there is a lot of function calling
in loops I'd like to get rid of.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
private static final int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendBit
(int bit) Append the a bit to the bit vectorvoid
appendBits
(int value, int numBits) Append "numBits" bits in "value" to the bit vector.void
appendBitVector
(BitVector bits) Append a different BitVector to this BitVectorprivate void
appendByte
(int value) Add a new byte to the end, possibly reallocating and doubling the size of the array if we've run out of room.int
at
(int index) Return the bit value at "index".byte[]
getArray()
Callers should not assume that array.length is the exact number of bytes needed to hold sizeInBits - it will typically be larger for efficiency.int
size()
int
toString()
void
XOR the contents of this bitvector with the contetns of "other"
-
Field Details
-
sizeInBits
private int sizeInBits -
array
private byte[] array -
DEFAULT_SIZE_IN_BYTES
private static final int DEFAULT_SIZE_IN_BYTES- See Also:
-
-
Constructor Details
-
BitVector
public BitVector()Create a bitvector usng the default size
-
-
Method Details
-
at
public int at(int index) Return the bit value at "index".- Parameters:
index
- index in the vector- Returns:
- bit value at "index"
-
size
public int size()- Returns:
- the number of bits in the bit vector.
-
sizeInBytes
public int sizeInBytes()- Returns:
- the number of bytes in the bit vector.
-
appendBit
public void appendBit(int bit) Append the a bit to the bit vector- Parameters:
bit
- 0 or 1
-
appendBits
public void appendBits(int value, int numBits) Append "numBits" bits in "value" to the bit vector. Examples: - appendBits(0x00, 1) adds 0. - appendBits(0x00, 4) adds 0000. - appendBits(0xff, 8) adds 11111111.- Parameters:
value
- int interpreted as bitvectornumBits
- 0 <= numBits <= 32.
-
appendBitVector
Append a different BitVector to this BitVector- Parameters:
bits
- BitVector to append
-
xor
XOR the contents of this bitvector with the contetns of "other"- Parameters:
other
- Bitvector of equal length
-
toString
-
getArray
public byte[] getArray()Callers should not assume that array.length is the exact number of bytes needed to hold sizeInBits - it will typically be larger for efficiency.- Returns:
- size of the array containing the bitvector
-
appendByte
private void appendByte(int value) Add a new byte to the end, possibly reallocating and doubling the size of the array if we've run out of room.- Parameters:
value
- byte to add.
-