Class BitStringValue

java.lang.Object
net.aifusion.asn.AsnValue
net.aifusion.asn.BitStringValue

public class BitStringValue extends AsnValue
Class to represent an ASN.1 BitString
Author:
Sharad Singhal
  • 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

      public BitStringValue(String bitString)
      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

      public static BitStringValue create(byte[] buffer, int blen, int cursor)
      Create a bit string from an encoded value
      Parameters:
      buffer - - input buffer
      blen - - length of input buffer
      cursor - - current position of the cursor in the input buffer
      Returns:
      - bit string value
    • getValue

      public String getValue()
      Get the value of this bit string.
      Returns:
      value of this string
    • getLength

      public int getLength()
      Get the size of this bit string
      Overrides:
      getLength in class AsnValue
      Returns:
      length 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 class AsnValue
      Returns:
      byte [] containing encoded value for this ASN.1 value (including tag, length, content)
    • toAsnString

      public String toAsnString(String prefix)
      Description copied from class: AsnValue
      Get a (semi) ASN.1 notation for this value.
      Overrides:
      toAsnString in class AsnValue
      Parameters:
      prefix - - prefix to add to each line
      Returns:
      - string containing the ASN.1 value
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object