Package com.itextpdf.barcodes.qrcode
Class BitVector
- java.lang.Object
-
- com.itextpdf.barcodes.qrcode.BitVector
-
final class BitVector extends java.lang.Object
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
Fields Modifier and Type Field Description private byte[]
array
private static int
DEFAULT_SIZE_IN_BYTES
private int
sizeInBits
-
Constructor Summary
Constructors Constructor Description BitVector()
Create a bitvector usng the default size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
sizeInBytes()
java.lang.String
toString()
void
xor(BitVector other)
XOR the contents of this bitvector with the contetns of "other"
-
-
-
Field Detail
-
sizeInBits
private int sizeInBits
-
array
private byte[] array
-
DEFAULT_SIZE_IN_BYTES
private static final int DEFAULT_SIZE_IN_BYTES
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public void appendBitVector(BitVector bits)
Append a different BitVector to this BitVector- Parameters:
bits
- BitVector to append
-
xor
public void xor(BitVector other)
XOR the contents of this bitvector with the contetns of "other"- Parameters:
other
- Bitvector of equal length
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representation of the bitvector
-
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.
-
-