ASN1BitString (Bouncy Castle Library 1.54 API Specification)
Date: 2015-12-29

org.bouncycastle.asn1

## Class ASN1BitString

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.ASN1Primitive
    - - org.bouncycastle.asn1.ASN1BitString

- All Implemented Interfaces:
    ASN1Encodable, ASN1String, Encodable
  Direct Known Subclasses:
    DERBitString, DLBitString

      public abstract class ASN1BitString
      extends ASN1Primitive
      implements ASN1String

  Base class for BIT STRING objects

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected byte[]` | `data`
    `protected int` | `padBits`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ASN1BitString(byte[] data, int padBits)` Base constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `asn1Equals(ASN1Primitive o)`
    `protected static byte[]` | `derForm(byte[] data, int padBits)`
    `byte[]` | `getBytes()`
    `protected static byte[]` | `getBytes(int bitString)`
    `ASN1Primitive` | `getLoadedObject()`
    `byte[]` | `getOctets()` Return the octets contained in this BIT STRING, checking that this BIT STRING really does represent an octet aligned string.
    `int` | `getPadBits()`
    `protected static int` | `getPadBits(int bitString)`
    `java.lang.String` | `getString()` Return a String representation of this BIT STRING
    `int` | `hashCode()`
    `int` | `intValue()`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Primitive

      `equals, fromByteArray, toASN1Primitive`

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

      `getEncoded, getEncoded, hasEncodedTagValue, toASN1Object`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### data

          protected final byte[] data

    - #### padBits

          protected final int padBits

  - ### Constructor Detail

    - #### ASN1BitString

          public ASN1BitString(byte[] data,
                       int padBits)

      Base constructor.
      Parameters:
        `data` - the octets making up the bit string.
        `padBits` - the number of extra bits at the end of the string.

  - ### Method Detail

    - #### getPadBits

          protected static int getPadBits(int bitString)

      Parameters:
        `bitString` - an int containing the BIT STRING
      Returns:
        the correct number of pad bits for a bit string defined in a 32 bit constant

    - #### getBytes

          protected static byte[] getBytes(int bitString)

      Parameters:
        `bitString` - an int containing the BIT STRING
      Returns:
        the correct number of bytes for a bit string defined in a 32 bit constant

    - #### getString

          public java.lang.String getString()

      Return a String representation of this BIT STRING
      Specified by:
        `getString` in interface `ASN1String`
      Returns:
        a String representation.

    - #### intValue

          public int intValue()

      Returns:
        the value of the bit string as an int (truncating if necessary)

    - #### getOctets

          public byte[] getOctets()

      Return the octets contained in this BIT STRING, checking that this BIT STRING really does represent an octet aligned string. Only use this method when the standard you are following dictates that the BIT STRING will be octet aligned.
      Returns:
        a copy of the octet aligned data.

    - #### getBytes

          public byte[] getBytes()

    - #### getPadBits

          public int getPadBits()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in class `ASN1Primitive`

    - #### asn1Equals

          protected boolean asn1Equals(ASN1Primitive o)

    - #### derForm

          protected static byte[] derForm(byte[] data,
                       int padBits)

    - #### getLoadedObject

          public ASN1Primitive getLoadedObject()