Class BitArray
java.lang.Object
org.openhab.core.io.transport.modbus.BitArray
Class that implements a collection for
bits
- Author:
- Sami Salonen - Initial contribution
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
getBit
(int index) Returns the state of the bit at the given index Index 0 matches LSB (rightmost) bititerator()
void
setBit
(int index, boolean value) int
size()
Get number of bits stored in this instanceGet data as binary string For example, 0010toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BitArray
public BitArray(int nbits) -
BitArray
public BitArray(boolean... bits) -
BitArray
-
-
Method Details
-
getBit
public boolean getBit(int index) Returns the state of the bit at the given index Index 0 matches LSB (rightmost) bit- Parameters:
index
- the index of the bit to be returned.- Returns:
- true if the bit at the specified index is set, false otherwise.
- Throws:
IndexOutOfBoundsException
- if the index is out of bounds.
-
setBit
public void setBit(int index, boolean value) -
size
public int size()Get number of bits stored in this instance- Returns:
-
toString
-
iterator
-
equals
-
toBinaryString
Get data as binary string For example, 0010- Returns:
- string representing the data
-