Package com.unboundid.asn1
Class ASN1OctetString
java.lang.Object
com.unboundid.asn1.ASN1Element
com.unboundid.asn1.ASN1OctetString
- All Implemented Interfaces:
ByteString,Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class ASN1OctetString
extends ASN1Element
implements ByteString
This class provides an ASN.1 octet string element, whose value is simply
comprised of zero or more bytes. Octet string elements are frequently used
to represent string values as well.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ASN.1 octet string element with the default BER type and no value.ASN1OctetString(byte type) Creates a new ASN.1 octet string element with the specified type and no value.ASN1OctetString(byte[] value) Creates a new ASN.1 octet string element with the default BER type and the provided value.ASN1OctetString(byte[] value, int offset, int length) Creates a new ASN.1 octet string element with the default BER type and the provided value.ASN1OctetString(byte type, byte[] value) Creates a new ASN.1 octet string element with the specified type and the provided value.ASN1OctetString(byte type, byte[] value, int offset, int length) Creates a new ASN.1 octet string element with the specified type and the provided value.ASN1OctetString(byte type, String value) Creates a new ASN.1 octet string element with the specified type and the provided value.ASN1OctetString(String value) Creates a new ASN.1 octet string element with the default BER type and the provided value. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendValueTo(ByteStringBuffer buffer) Appends the value of this ASN.1 octet string to the provided buffer.static ASN1OctetStringdecodeAsOctetString(byte[] elementBytes) Decodes the contents of the provided byte array as an octet string element.static ASN1OctetStringdecodeAsOctetString(ASN1Element element) Decodes the provided ASN.1 element as an octet string element.voidencodeTo(ByteStringBuffer buffer) Appends an encoded representation of this ASN.1 element to the provided buffer.byte[]getValue()Retrieves the encoded value for this element.intRetrieves the number of bytes contained in the value.Retrieves the string value for this element.Converts this byte string to an ASN.1 octet string.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, equals, equalsIgnoreType, getType, getTypeClass, hashCode, isConstructed, readFrom, readFrom, toString, writeTo
-
Constructor Details
-
ASN1OctetString
public ASN1OctetString()Creates a new ASN.1 octet string element with the default BER type and no value. -
ASN1OctetString
Creates a new ASN.1 octet string element with the specified type and no value.- Parameters:
type- The BER type to use for this element.
-
ASN1OctetString
Creates a new ASN.1 octet string element with the default BER type and the provided value.- Parameters:
value- The value to use for this element.
-
ASN1OctetString
Creates a new ASN.1 octet string element with the default BER type and the provided value.- Parameters:
value- The byte array containing the value to use for this element It must not benull.offset- The offset within the array at which the value begins. It must be greater than or equal to zero and less than or equal to the length of the array.length- The length in bytes of the value. It must be greater than or equal to zero, and it must not extend beyond the end of the array.
-
ASN1OctetString
Creates a new ASN.1 octet string element with the specified type and the provided value.- Parameters:
type- The BER type to use for this element.value- The value to use for this element.
-
ASN1OctetString
Creates a new ASN.1 octet string element with the specified type and the provided value.- Parameters:
type- The BER type to use for this element.value- The byte array containing the value to use for this element. It must not benull.offset- The offset within the array at which the value begins. It must be greater than or equal to zero and less than or equal to the length of the array.length- The length in bytes of the value. It must be greater than or equal to zero, and it must not extend beyond the end of the array.
-
ASN1OctetString
Creates a new ASN.1 octet string element with the default BER type and the provided value.- Parameters:
value- The value to use for this element.
-
ASN1OctetString
Creates a new ASN.1 octet string element with the specified type and the provided value.- Parameters:
type- The BER type to use for this element.value- The value to use for this element.
-
-
Method Details
-
getValueLength
Retrieves the number of bytes contained in the value.- Overrides:
getValueLengthin classASN1Element- Returns:
- The number of bytes contained in the value.
-
getValue
Retrieves the encoded value for this element.- Specified by:
getValuein interfaceByteString- Overrides:
getValuein classASN1Element- Returns:
- The encoded value for this element.
-
encodeTo
Appends an encoded representation of this ASN.1 element to the provided buffer.- Overrides:
encodeToin classASN1Element- Parameters:
buffer- The buffer to which the encoded representation should be appended.
-
stringValue
Retrieves the string value for this element.- Specified by:
stringValuein interfaceByteString- Returns:
- The String value for this element.
-
decodeAsOctetString
@NotNull public static ASN1OctetString decodeAsOctetString(@NotNull byte[] elementBytes) throws ASN1Exception Decodes the contents of the provided byte array as an octet string element.- Parameters:
elementBytes- The byte array to decode as an ASN.1 octet string element.- Returns:
- The decoded ASN.1 octet string element.
- Throws:
ASN1Exception- If the provided array cannot be decoded as an octet string element.
-
decodeAsOctetString
Decodes the provided ASN.1 element as an octet string element.- Parameters:
element- The ASN.1 element to be decoded.- Returns:
- The decoded ASN.1 octet string element.
-
appendValueTo
Appends the value of this ASN.1 octet string to the provided buffer.- Specified by:
appendValueToin interfaceByteString- Parameters:
buffer- The buffer to which the value is to be appended.
-
toASN1OctetString
Converts this byte string to an ASN.1 octet string.- Specified by:
toASN1OctetStringin interfaceByteString- Returns:
- An ASN.1 octet string with the value of this byte string.
-
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.
-