Package net.aifusion.asn
Class BitStringValue
java.lang.Object
net.aifusion.asn.AsnValue
net.aifusion.asn.BitStringValue
Class to represent an ASN.1 BitString
- Author:
- Sharad Singhal
-
Constructor Summary
ConstructorDescriptionBitStringValue
(byte[] bits) Create a BitString from a byte [].BitStringValue
(String bitString) Create a BitString. -
Method Summary
Modifier and TypeMethodDescriptionstatic BitStringValue
create
(byte[] buffer, int blen, int cursor) Create a bit string from an encoded valueboolean
byte[]
Get the encoded value for this ASN.1 value.int
Get the size of this bit stringgetValue()
Get the value of this bit string.int
hashCode()
boolean
isSet
(int index) Check if a particular bit in this bitSet is settoAsnString
(String prefix) Get a (semi) ASN.1 notation for this value.toString()
Methods inherited from class net.aifusion.asn.AsnValue
getTag, getTagClass, getTagEncoding, getTagNumber, toHex, toHex, toHex, toHex
-
Constructor Details
-
BitStringValue
public BitStringValue(byte[] bits) Create a BitString from a byte []. Note that bits[bits.length-1] is the MSB in the bitString- Parameters:
bits
- - byte array containing bits in the Bit String
-
BitStringValue
Create a BitString. Note that java BitSets are little-endian, while ASN.1 are big-endian. Bit 0 is the left-most bit in the string representation- Parameters:
bitString
- - bit string using the ASN.1 bit string format 'nnn...'[B|H]
-
-
Method Details
-
create
Create a bit string from an encoded value- Parameters:
buffer
- - input bufferblen
- - length of input buffercursor
- - current position of the cursor in the input buffer- Returns:
- - bit string value
-
getValue
Get the value of this bit string.- Returns:
- value of this string
-
getLength
public int getLength()Get the size of this bit string -
isSet
public boolean isSet(int index) Check if a particular bit in this bitSet is set- Parameters:
index
- - index of the bit to check. Bit 0 is the left-most bit.- Returns:
- - true if the bit is set, false otherwise
-
getEncodedValue
public byte[] getEncodedValue()Description copied from class:AsnValue
Get the encoded value for this ASN.1 value. This method should be implemented by subclasses to provide the encoded ASN.1 value- Specified by:
getEncodedValue
in classAsnValue
- Returns:
- byte [] containing encoded value for this ASN.1 value (including tag, length, content)
-
toAsnString
Description copied from class:AsnValue
Get a (semi) ASN.1 notation for this value.- Overrides:
toAsnString
in classAsnValue
- Parameters:
prefix
- - prefix to add to each line- Returns:
- - string containing the ASN.1 value
-
hashCode
public int hashCode() -
equals
-
toString
-