Package com.itextpdf.barcodes.qrcode
Class BitVector
- java.lang.Object
-
- com.itextpdf.barcodes.qrcode.BitVector
-
final class BitVector extends java.lang.ObjectJAVAPORT: 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[]arrayprivate static intDEFAULT_SIZE_IN_BYTESprivate intsizeInBits
-
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 voidappendBit(int bit)Append the a bit to the bit vectorvoidappendBits(int value, int numBits)Append "numBits" bits in "value" to the bit vector.voidappendBitVector(BitVector bits)Append a different BitVector to this BitVectorprivate voidappendByte(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.intat(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.intsize()intsizeInBytes()java.lang.StringtoString()voidxor(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:
toStringin 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.
-
-