Package com.unboundid.asn1
Class ASN1BitString
- java.lang.Object
-
- com.unboundid.asn1.ASN1Element
-
- com.unboundid.asn1.ASN1BitString
-
- All Implemented Interfaces:
java.io.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ASN1BitString(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, java.lang.String stringRepresentation)
Creates a new ASN.1 bit string with the default BER type and a value created from the provided string representation.ASN1BitString(java.lang.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ASN1BitString
decodeAsBitString(byte[] elementBytes)
Decodes the contents of the provided byte array as a bit string element.static ASN1BitString
decodeAsBitString(ASN1Element element)
Decodes the provided ASN.1 element as a bit string element.boolean[]
getBits()
Retrieves an array ofboolean
values 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.void
toString(java.lang.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 Detail
-
ASN1BitString
public ASN1BitString(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. Eachboolean
value oftrue
represents a bit of one, and eachboolean
value offalse
represents a bit of zero. It must not benull
but may be empty.
-
ASN1BitString
public ASN1BitString(byte type, 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. Eachboolean
value oftrue
represents a bit of one, and eachboolean
value offalse
represents a bit of zero. It must not benull
but may be empty.
-
ASN1BitString
public ASN1BitString(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 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
public ASN1BitString(byte type, 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 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 Detail
-
getBits
public boolean[] getBits()
Retrieves an array ofboolean
values that correspond to the bits in this bit string. Eachboolean
value oftrue
represents a bit of one, and eachboolean
value offalse
represents a bit of zero.- Returns:
- An array of
boolean
values that correspond to the bits in this bit string.
-
getBytes
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
public static boolean[] getBitsForBytes(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 benull
.- Returns:
- An array of the bits that make up the provided bytes.
-
decodeAsBitString
public static ASN1BitString decodeAsBitString(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
public static ASN1BitString decodeAsBitString(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
public void toString(java.lang.StringBuilder buffer)
Appends a string representation of the value for this ASN.1 element to the provided buffer.- Overrides:
toString
in classASN1Element
- Parameters:
buffer
- The buffer to which to append the information.
-
-