Class ASN1BitString

    • Constructor Detail

      • ASN1BitString

        public ASN1BitString​(@NotNull
                             boolean... bits)
        Creates a new ASN.1 bit string element with the default BER type and the provided set of bits.
        Parameters:
        bits - The bits to include in the bit string. Each boolean value of true represents a bit of one, and each boolean value of false represents a bit of zero. It must not be null but may be empty.
      • ASN1BitString

        public ASN1BitString​(byte type,
                             @NotNull
                             boolean... bits)
        Creates a new ASN.1 bit string element with the specified BER type and the provided set of bits.
        Parameters:
        type - The BER type to use for this element.
        bits - The bits to include in the bit string. Each boolean value of true represents a bit of one, and each boolean value of false represents a bit of zero. It must not be null but may be empty.
      • ASN1BitString

        public ASN1BitString​(@NotNull
                             java.lang.String stringRepresentation)
                      throws ASN1Exception
        Creates a new ASN.1 bit string with the default BER type and a value created from the provided string representation.
        Parameters:
        stringRepresentation - A string representation of the bit string to create. It must not be null, but may be empty. It must be comprised only of the characters '1' and '0'.
        Throws:
        ASN1Exception - If the provided string does not represent a valid bit string value.
      • ASN1BitString

        public ASN1BitString​(byte type,
                             @NotNull
                             java.lang.String stringRepresentation)
                      throws ASN1Exception
        Creates a new ASN.1 bit string with the default BER type and a value created from the provided string representation.
        Parameters:
        type - The BER type to use for this element.
        stringRepresentation - A string representation of the bit string to create. It must not be null, but may be empty. It must be comprised only of the characters '1' and '0'.
        Throws:
        ASN1Exception - If the provided string does not represent a valid bit string value.
    • Method Detail

      • getBits

        @NotNull
        public boolean[] getBits()
        Retrieves an array of boolean values that correspond to the bits in this bit string. Each boolean value of true represents a bit of one, and each boolean value of false represents a bit of zero.
        Returns:
        An array of boolean values that correspond to the bits in this bit string.
      • getBytes

        @NotNull
        public byte[] getBytes()
                        throws ASN1Exception
        Retrieves the bytes represented by the bits that comprise this bit string, if the number of bits is a multiple of eight.
        Returns:
        The bytes represented by the bits that comprise this bit string.
        Throws:
        ASN1Exception - If the number of bits in this bit string is not a multiple of eight.
      • getBitsForBytes

        @NotNull
        public static boolean[] getBitsForBytes​(@NotNull
                                                byte... bytes)
        Retrieves an array of booleans that represent the bits in the provided array of bytes.
        Parameters:
        bytes - The bytes for which to retrieve the corresponding bits. It must not be null.
        Returns:
        An array of the bits that make up the provided bytes.
      • decodeAsBitString

        @NotNull
        public static ASN1BitString decodeAsBitString​(@NotNull
                                                      byte[] elementBytes)
                                               throws ASN1Exception
        Decodes the contents of the provided byte array as a bit string element.
        Parameters:
        elementBytes - The byte array to decode as an ASN.1 bit string element.
        Returns:
        The decoded ASN.1 bit string element.
        Throws:
        ASN1Exception - If the provided array cannot be decoded as a bit string element.
      • toString

        public void toString​(@NotNull
                             java.lang.StringBuilder buffer)
        Appends a string representation of the value for this ASN.1 element to the provided buffer.
        Overrides:
        toString in class ASN1Element
        Parameters:
        buffer - The buffer to which to append the information.