public class BitString extends AbstractData
BitString
class represents the BIT STRING type. BIT STRING values can store
binary data whose size is not a multiple of 8 bits.Constructor and Description |
---|
BitString()
The default constructor.
|
BitString(byte[] value)
Constructs the
BitString object from a byte array that contains bit values
(little endian). |
BitString(byte[] value,
int size)
Constructs the
BitString object from a byte array that contains bit values
(little endian). |
Modifier and Type | Method and Description |
---|---|
byte[] |
byteArrayValue()
Returns bit values of the
BitString in little endian format. |
void |
clearBit(int i)
Sets the value of the bit at the specified position to '0'.
|
java.lang.Object |
clone()
Creates a deep copy of
this object. |
boolean |
equals(java.lang.Object that)
Compares this object to another
BitString to see if they are equal. |
boolean |
getBit(int i)
Gets the value of the bit at the specified position.
|
int |
getSize()
Returns the
BitString size in bits. |
int |
hashCode()
Computes the hash code of this BitString.
|
void |
setBit(int i)
Sets the value of the bit at the specified position to '1'.
|
void |
setBit(int i,
boolean value)
Sets the value of the bit at the specified position.
|
void |
setValue(byte[] value,
int size)
Sets the bit values of the
BitString . |
public BitString()
BitString
to the default value
(an empty bit string).public BitString(byte[] value)
BitString
object from a byte array that contains bit values
(little endian). The size of the bit string is set to value.length * 8
.value
- specifies bit values in little endian format.public BitString(byte[] value, int size)
BitString
object from a byte array that contains bit values
(little endian). If the specified size
exceeds the capacity of
the value
, the value is padded with the appropriate number of zero bits.value
- specifies bit values in little endian format.size
- specifies bit string size in bits.public final byte[] byteArrayValue()
BitString
in little endian format.BitString
.public final void setValue(byte[] value, int size)
BitString
. If the specified
size
exceeds the capacity of the value
, the value is padded with
the appropriate number of zero bits.value
- specifies bit values in little endian format.size
- specifies the bit string size in bits.public final int getSize()
BitString
size in bits.BitString
size in bits.public boolean getBit(int i)
i
- bit position (zero based).java.lang.IndexOutOfBoundsException
- if the bit position is out of the range
(i < 0 || i >= getSize())
.public void setBit(int i, boolean value)
i
- bit position (zero based).value
- specifies the bit value.java.lang.IndexOutOfBoundsException
- if the bit position is out of the range
(i < 0 || i >= getSize())
.public void setBit(int i)
i
- bit position (zero based).java.lang.IndexOutOfBoundsException
- if the bit position is out of the range
(i < 0 || i >= getSize())
.public void clearBit(int i)
i
- bit position (zero based).java.lang.IndexOutOfBoundsException
- if the bit position is out of the range
(i < 0 || i >= getSize())
.public java.lang.Object clone()
AbstractData
this
object.clone
in class AbstractData
public boolean equals(java.lang.Object that)
BitString
to see if they are equal. Two bit
strings are considered equal if and only if they have identical sizes and identical
bit values.equals
in class java.lang.Object
that
- the BitString
object to be compared to.public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2023 OSS Nokalva, Inc. All rights reserved.
This document is proprietary to OSS Nokalva, Inc., and may be used only by their direct licensees. Distribution is not permitted. This copyright statement must not be removed.