Package com.unboundid.asn1
Class ASN1BitString
java.lang.Object
com.unboundid.asn1.ASN1Element
com.unboundid.asn1.ASN1BitString
- All Implemented Interfaces:
Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class ASN1BitString
extends ASN1Element
This class provides an ASN.1 bit string element, whose value represents a
series of zero or more bits, where each bit is either one or zero.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionASN1BitString(boolean... bits) Creates a new ASN.1 bit string element with the default BER type and the provided set of bits.ASN1BitString(byte type, boolean... bits) Creates a new ASN.1 bit string element with the specified BER type and the provided set of bits.ASN1BitString(byte type, String stringRepresentation) Creates a new ASN.1 bit string with the default BER type and a value created from the provided string representation.ASN1BitString(String stringRepresentation) Creates a new ASN.1 bit string with the default BER type and a value created from the provided string representation. -
Method Summary
Modifier and TypeMethodDescriptionstatic ASN1BitStringdecodeAsBitString(byte[] elementBytes) Decodes the contents of the provided byte array as a bit string element.static ASN1BitStringdecodeAsBitString(ASN1Element element) Decodes the provided ASN.1 element as a bit string element.boolean[]getBits()Retrieves an array ofbooleanvalues that correspond to the bits in this bit string.static boolean[]getBitsForBytes(byte... bytes) Retrieves an array of booleans that represent the bits in the provided array of bytes.byte[]getBytes()Retrieves the bytes represented by the bits that comprise this bit string, if the number of bits is a multiple of eight.voidtoString(StringBuilder buffer) Appends a string representation of the value for this ASN.1 element to the provided buffer.Methods inherited from class com.unboundid.asn1.ASN1Element
decode, decodeAsBigInteger, decodeAsBitString, decodeAsBoolean, decodeAsEnumerated, decodeAsGeneralizedTime, decodeAsIA5String, decodeAsInteger, decodeAsLong, decodeAsNull, decodeAsNumericString, decodeAsObjectIdentifier, decodeAsOctetString, decodeAsPrintableString, decodeAsSequence, decodeAsSet, decodeAsUTCTime, decodeAsUTF8String, encode, encodeLength, encodeTo, equals, equalsIgnoreType, getType, getTypeClass, getValue, getValueLength, hashCode, isConstructed, readFrom, readFrom, toString, writeTo
-
Constructor Details
-
ASN1BitString
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. Eachbooleanvalue oftruerepresents a bit of one, and eachbooleanvalue offalserepresents a bit of zero. It must not benullbut may be empty.
-
ASN1BitString
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. Eachbooleanvalue oftruerepresents a bit of one, and eachbooleanvalue offalserepresents a bit of zero. It must not benullbut may be empty.
-
ASN1BitString
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 benull, 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
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 benull, 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 Details
-
getBits
Retrieves an array ofbooleanvalues that correspond to the bits in this bit string. Eachbooleanvalue oftruerepresents a bit of one, and eachbooleanvalue offalserepresents a bit of zero.- Returns:
- An array of
booleanvalues that correspond to the bits in this bit string.
-
getBytes
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
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 benull.- 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.
-
decodeAsBitString
@NotNull public static ASN1BitString decodeAsBitString(@NotNull ASN1Element element) throws ASN1Exception Decodes the provided ASN.1 element as a bit string element.- Parameters:
element- The ASN.1 element to be decoded.- Returns:
- The decoded ASN.1 bit string element.
- Throws:
ASN1Exception- If the provided element cannot be decoded as a bit string element.
-
toString
Appends a string representation of the value for this ASN.1 element to the provided buffer.- Overrides:
toStringin classASN1Element- Parameters:
buffer- The buffer to which to append the information.
-