Package org.asnlab.asndt.runtime.value
Class BitString
java.lang.Object
org.asnlab.asndt.runtime.value.BitString
Immutable representation of an ASN.1 BIT STRING, which is equivalent to a
byte array except some number of the rightmost bits are ignored. For
example, this could be the bit string:
00010101 11101101 11010xxx
Where the "xxx" represents three bits that should be ignored, and can have any value.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleangetBit(int bit) Returns the bit at the specified index.booleangetBit(org.asnlab.asndt.runtime.type.NamedNumber namedBit) intReturns the size, in bits, of this bit string.static voidvoidsetBit(int bit, boolean value) Sets the bit at the specified index.voidsetBit(org.asnlab.asndt.runtime.type.NamedNumber namedBit, boolean value) toString()void
-
Field Details
-
bytes
public byte[] bytes -
unusedBits
public byte unusedBits
-
-
Constructor Details
-
BitString
public BitString(byte[] bytes, byte unusedBits) Create a new bit string- Parameters:
bytes- The byte array holding the bit string.unusedBits- The number of tailing bits that are not used.- Throws:
NullPointerException- If bytes is null.
-
BitString
public BitString(int length) Create a new bit string of a given length- Parameters:
length- The size of the bit string.
-
BitString
public BitString(org.asnlab.asndt.runtime.type.BitStringType bitStringType)
-
-
Method Details
-
trimTailingZeros
public void trimTailingZeros() -
clearUnusedBits
public void clearUnusedBits() -
getBit
public boolean getBit(int bit) Returns the bit at the specified index.- Parameters:
bit- The bit index- Returns:
- The boolean value of the bit
-
setBit
public void setBit(int bit, boolean value) Sets the bit at the specified index.- Parameters:
bit- The bit indexvalue- The boolean value of the bit
-
main
-
getBitSize
public int getBitSize()Returns the size, in bits, of this bit string.- Returns:
- The size of this bit string.
-
getBit
public boolean getBit(org.asnlab.asndt.runtime.type.NamedNumber namedBit) -
setBit
public void setBit(org.asnlab.asndt.runtime.type.NamedNumber namedBit, boolean value) -
toString
-