Package org.ngengine.gui.qr
Class BitBuffer
java.lang.Object
org.ngengine.gui.qr.BitBuffer
- All Implemented Interfaces:
Cloneable
An appendable sequence of bits (0s and 1s). Mainly used by
QrSegment.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendBits(int val, int len) Appends the specified number of low-order bits of the specified value to this buffer.voidappendData(BitBuffer bb) Appends the content of the specified bit buffer to this buffer.intReturns the length of this sequence, which is a non-negative value.clone()Returns a new copy of this buffer.intgetBit(int index) Returns the bit at the specified index, yielding 0 or 1.
-
Constructor Details
-
BitBuffer
public BitBuffer()Constructs an empty bit buffer (length 0).
-
-
Method Details
-
bitLength
public int bitLength()Returns the length of this sequence, which is a non-negative value.- Returns:
- the length of this sequence
-
getBit
public int getBit(int index) Returns the bit at the specified index, yielding 0 or 1.- Parameters:
index- the index to get the bit at- Returns:
- the bit at the specified index
- Throws:
IndexOutOfBoundsException- if index < 0 or index ≥ bitLength
-
appendBits
public void appendBits(int val, int len) Appends the specified number of low-order bits of the specified value to this buffer. Requires 0 ≤ len ≤ 31 and 0 ≤ val < 2len.- Parameters:
val- the value to appendlen- the number of low-order bits in the value to take- Throws:
IllegalArgumentException- if the value or number of bits is out of rangeIllegalStateException- if appending the data would make bitLength exceed Integer.MAX_VALUE
-
appendData
Appends the content of the specified bit buffer to this buffer.- Parameters:
bb- the bit buffer whose data to append (notnull)- Throws:
NullPointerException- if the bit buffer isnullIllegalStateException- if appending the data would make bitLength exceed Integer.MAX_VALUE
-
clone
Returns a new copy of this buffer.
-