org.opends.server.protocols.asn1
Class ASN1OctetString

java.lang.Object
  extended by org.opends.server.protocols.asn1.ASN1Element
      extended by org.opends.server.protocols.asn1.ASN1OctetString
All Implemented Interfaces:
java.io.Serializable, ProtocolElement, ByteString

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class ASN1OctetString
extends ASN1Element
implements ByteString

This class defines the data structures and methods to use when interacting with ASN.1 octet string elements.

Note that this class also implements the ByteString interface, but in most cases whenever it is necessary to create an instance of a ByteString object, the caller should use one of the ByteStringFactory.create methods rather than creating an ASN1OctetString object directly. In general, direct references to ASN.1 elements should be limited to cases in which ASN.1 is actually involved.

See Also:
Serialized Form

Constructor Summary
ASN1OctetString()
          Creates a new ASN.1 octet string element with the default 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 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, java.lang.String stringValue)
          Creates a new ASN.1 octet string element with the specified type and the provided value.
ASN1OctetString(Message messageValue)
          Creates a new ASN.1 octet string element with the default type and the provided value.
ASN1OctetString(java.lang.String stringValue)
          Creates a new ASN.1 octet string element with the default type and the provided value.
 
Method Summary
static ASN1OctetString decodeAsOctetString(ASN1Element element)
          Decodes the provided ASN.1 element as an octet string element.
static ASN1OctetString decodeAsOctetString(byte[] encodedElement)
          Decodes the provided byte array as an ASN.1 octet string element.
 ASN1OctetString duplicate()
          Creates a duplicate of this ASN.1 octet string.
 void setValue(byte[] value)
          Specifies the value for this ASN.1 octet string element.
 void setValue(java.lang.String stringValue)
          Specifies the string value for this ASN.1 octet string element.
 java.lang.String stringValue()
          Retrieves the string representation of the value for this ASN.1 octet string element.
 void stringValue(java.lang.StringBuilder buffer)
          Appends a string representation of the value for this ASN.1 octet string element to the provided buffer.
 ASN1OctetString toASN1OctetString()
          Retrieves this byte string as an ASN.1 octet string.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this ASN.1 octet string element to the provided buffer.
 void toString(java.lang.StringBuilder buffer, int indent)
          Appends a string representation of this protocol element to the provided buffer.
 
Methods inherited from class org.opends.server.protocols.asn1.ASN1Element
decode, decode, decodeAsBoolean, decodeAsEnumerated, decodeAsInteger, decodeAsLong, decodeAsNull, decodeAsOctetString, decodeAsSequence, decodeAsSet, decodeElements, encode, encodeLength, encodeLongValue, encodeValue, encodeValue, encodeValue, equals, equalsElement, equalsIgnoreType, equalsIgnoreType, getProtocolElementName, getType, hashCode, isApplicationSpecific, isConstructed, isContextSpecific, isPrimitive, isPrivate, isUniversal, setType, setValueInternal, toString, value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opends.server.types.ByteString
toString, value
 

Constructor Detail

ASN1OctetString

public ASN1OctetString()
Creates a new ASN.1 octet string element with the default type and no value.


ASN1OctetString

public ASN1OctetString(byte type)
Creates a new ASN.1 octet string element with the specified type and no value.

Parameters:
type - The BER type for this ASN.1 octet string element.

ASN1OctetString

public ASN1OctetString(byte[] value)
Creates a new ASN.1 octet string element with the default type and the provided value.

Parameters:
value - The value for this ASN.1 octet string element.

ASN1OctetString

public ASN1OctetString(Message messageValue)
Creates a new ASN.1 octet string element with the default type and the provided value.

Parameters:
messageValue - The value for this ASN.1 octet string element as a string.

ASN1OctetString

public ASN1OctetString(java.lang.String stringValue)
Creates a new ASN.1 octet string element with the default type and the provided value.

Parameters:
stringValue - The value for this ASN.1 octet string element as a string.

ASN1OctetString

public ASN1OctetString(byte type,
                       byte[] value)
Creates a new ASN.1 octet string element with the specified type and the provided value.

Parameters:
type - The BER type for this ASN.1 octet string element.
value - The value for this ASN.1 octet string element.

ASN1OctetString

public ASN1OctetString(byte type,
                       java.lang.String stringValue)
Creates a new ASN.1 octet string element with the specified type and the provided value.

Parameters:
type - The BER type for this ASN.1 octet string element.
stringValue - The value for this ASN.1 octet string element as a string.
Method Detail

stringValue

public java.lang.String stringValue()
Retrieves the string representation of the value for this ASN.1 octet string element. The behavior of this method when the bytes are not valid in the UTF-8 charset is unspecified. In particular the behavior for binary values is unspecified.

Specified by:
stringValue in interface ByteString
Returns:
The string representation of the value for this ASN.1 octet string element.

stringValue

public void stringValue(java.lang.StringBuilder buffer)
Appends a string representation of the value for this ASN.1 octet string element to the provided buffer.

Parameters:
buffer - The buffer to which the string representation should be appended.

setValue

public void setValue(java.lang.String stringValue)
Specifies the string value for this ASN.1 octet string element.

Specified by:
setValue in interface ByteString
Parameters:
stringValue - The string value for this ASN.1 octet string element.

setValue

public void setValue(byte[] value)
Specifies the value for this ASN.1 octet string element.

Specified by:
setValue in interface ByteString
Overrides:
setValue in class ASN1Element
Parameters:
value - The encoded value for this ASN.1 octet string element.

decodeAsOctetString

public static ASN1OctetString decodeAsOctetString(ASN1Element element)
                                           throws ASN1Exception
Decodes the provided ASN.1 element as an octet string element.

Parameters:
element - The ASN.1 element to decode as an octet string element.
Returns:
The decoded ASN.1 octet string element.
Throws:
ASN1Exception - If the provided ASN.1 element cannot be decoded as an octet string element.

decodeAsOctetString

public static ASN1OctetString decodeAsOctetString(byte[] encodedElement)
                                           throws ASN1Exception
Decodes the provided byte array as an ASN.1 octet string element.

Parameters:
encodedElement - 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 byte array cannot be decoded as an ASN.1 octet string element.

duplicate

public ASN1OctetString duplicate()
Creates a duplicate of this ASN.1 octet string.

Specified by:
duplicate in interface ByteString
Returns:
A duplicate of this ASN.1 octet string.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this ASN.1 octet string element to the provided buffer.

Specified by:
toString in interface ProtocolElement
Specified by:
toString in interface ByteString
Overrides:
toString in class ASN1Element
Parameters:
buffer - The buffer to which the information should be appended.

toString

public void toString(java.lang.StringBuilder buffer,
                     int indent)
Appends a string representation of this protocol element to the provided buffer.

Specified by:
toString in interface ProtocolElement
Overrides:
toString in class ASN1Element
Parameters:
buffer - The buffer into which the string representation should be written.
indent - The number of spaces that should be used to indent the resulting string representation.

toASN1OctetString

public ASN1OctetString toASN1OctetString()
Retrieves this byte string as an ASN.1 octet string.

Specified by:
toASN1OctetString in interface ByteString
Returns:
An ASN.1 octet string with the value of this byte string.