|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opends.server.protocols.asn1.ASN1Element
@PublicAPI(stability=UNCOMMITTED, mayInstantiate=true, mayExtend=false, mayInvoke=true) public class ASN1Element
This class defines the data structures and methods to use when interacting with generic ASN.1 elements. Subclasses may provide more specific functionality for individual element types.
Constructor Summary | |
---|---|
ASN1Element(byte type)
Creates a new ASN.1 element with the specified type and no value. |
|
ASN1Element(byte type,
byte[] value)
Creates a new ASN.1 element with the specified type and value. |
Method Summary | |
---|---|
static ASN1Element |
decode(byte[] encodedElement)
Decodes the contents of the provided byte array as an ASN.1 element. |
static ASN1Element |
decode(byte[] encodedElement,
int startPos,
int length)
Decodes the specified portion of the provided byte array as an ASN.1 element. |
ASN1Boolean |
decodeAsBoolean()
Decodes this ASN.1 element as an ASN.1 Boolean element. |
ASN1Enumerated |
decodeAsEnumerated()
Decodes this ASN.1 element as an ASN.1 enumerated element. |
ASN1Integer |
decodeAsInteger()
Decodes this ASN.1 element as an ASN.1 integer element. |
ASN1Long |
decodeAsLong()
Decodes this ASN.1 element as an ASN.1 long element. |
ASN1Null |
decodeAsNull()
Decodes this ASN.1 element as an ASN.1 null element. |
ASN1OctetString |
decodeAsOctetString()
Decodes this ASN.1 element as an ASN.1 octet string element. |
ASN1Sequence |
decodeAsSequence()
Decodes this ASN.1 element as an ASN.1 sequence element. |
ASN1Set |
decodeAsSet()
Decodes this ASN.1 element as an ASN.1 set element. |
static java.util.ArrayList<ASN1Element> |
decodeElements(byte[] encodedElements)
Decodes the provided byte array as a collection of ASN.1 elements as would be found in the value of a sequence or set. |
byte[] |
encode()
Encodes this ASN.1 element to a byte array. |
static byte[] |
encodeLength(int length)
Encodes the provided value for use as the length of an ASN.1 element. |
static byte[] |
encodeLongValue(long longValue)
Retrieves a byte array containing the encoded representation of the provided long value. |
static byte[] |
encodeValue(java.util.ArrayList<ASN1Element> elements)
Retrieves a byte array containing the encoded representation of the provided set of ASN.1 elements. |
static byte[] |
encodeValue(boolean booleanValue)
Retrieves a byte array containing the encoded representation of the provided boolean value. |
static byte[] |
encodeValue(int intValue)
Retrieves a byte array containing the encoded representation of the provided integer value. |
boolean |
equals(java.lang.Object o)
Indicates whether the provided object is equal to this ASN.1 element. |
boolean |
equalsElement(ASN1Element e)
Indicates whether the provided ASN.1 element is equal to this element. |
boolean |
equalsIgnoreType(ASN1Element element)
Indicates whether the provided ASN.1 element has a value that is equal to the value of this ASN.1 element. |
boolean |
equalsIgnoreType(ByteString byteString)
Indicates whether the provided byte string has a value that is equal to the value of this ASN.1 element. |
java.lang.String |
getProtocolElementName()
Retrieves the name of the protocol associated with this protocol element. |
byte |
getType()
Retrieves the BER type for this ASN.1 element. |
int |
hashCode()
Retrieves the hash code for this ASN.1 element. |
boolean |
isApplicationSpecific()
Indicates whether this ASN.1 element is in the application-specific class. |
boolean |
isConstructed()
Indicates whether this ASN.1 element has a constructed value. |
boolean |
isContextSpecific()
Indicates whether this ASN.1 element is in the context-specific class. |
boolean |
isPrimitive()
Indicates whether this ASN.1 element has a primitive value. |
boolean |
isPrivate()
Indicates whether this ASN.1 element is in the private class. |
boolean |
isUniversal()
Indicates whether this ASN.1 element is in the universal class. |
void |
setType(byte type)
Specifies the BER type for this ASN.1 element. |
void |
setValue(byte[] value)
Specifies the encoded value for this ASN.1 element. |
protected void |
setValueInternal(byte[] value)
Specifies the value to use for this ASN.1 element, but without performing any validity checks. |
java.lang.String |
toString()
Retrieves a string representation of this ASN.1 element. |
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this ASN.1 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. |
byte[] |
value()
Retrieves the encoded value for this ASN.1 element. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ASN1Element(byte type)
type
- The BER type for this ASN.1 element.public ASN1Element(byte type, byte[] value)
type
- The BER type for this ASN.1 element.value
- The encoded value for this ASN.1 element.Method Detail |
---|
public final byte getType()
public final void setType(byte type)
type
- The BER type for this ASN.1 element.public final boolean isUniversal()
true
if this ASN.1 element is in the universal class,
or false
if not.public final boolean isApplicationSpecific()
true
if this ASN.1 element is in the
application-specific class, or false
if not.public final boolean isContextSpecific()
true
if this ASN.1 element is in the context-specific
class, or false
if not.public final boolean isPrivate()
true
if this ASN.1 element is in the private class,
or false
if not.public final boolean isPrimitive()
true
if this ASN.1 element has a primitive value, or
false
if it is constructed.public final boolean isConstructed()
true
if this ASN.1 element has a constructed value,
or false
if it is primitive.public final byte[] value()
public void setValue(byte[] value) throws ASN1Exception
value
- The encoded value for this ASN.1 element.
ASN1Exception
- If the provided value is not appropriate for this
type of ASN.1 element.protected final void setValueInternal(byte[] value)
value
- The encoded value for this ASN.1 element.public static byte[] encodeLength(int length)
length
- The length to encode for use in an ASN.1 element.
public final byte[] encode()
public static byte[] encodeValue(boolean booleanValue)
booleanValue
- The boolean value to encode.
public static byte[] encodeValue(int intValue)
intValue
- The integer value to encode.
public static byte[] encodeLongValue(long longValue)
longValue
- The long value to encode.
public static byte[] encodeValue(java.util.ArrayList<ASN1Element> elements)
elements
- The set of ASN.1 elements to encode into the value.
public static ASN1Element decode(byte[] encodedElement) throws ASN1Exception
encodedElement
- The byte array containing the ASN.1 element to
decode.
ASN1Exception
- If a problem occurs while attempting to decode the
byte array as an ASN.1 element.public static ASN1Element decode(byte[] encodedElement, int startPos, int length) throws ASN1Exception
encodedElement
- The byte array containing the ASN.1 element to
decode.startPos
- The position in the provided array at which to
start decoding.length
- The number of bytes in the set of data to decode as
an ASN.1 element.
ASN1Exception
- If a problem occurs while attempting to decode the
byte array as an ASN.1 element.public final ASN1Boolean decodeAsBoolean() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 Boolean element.public final ASN1Enumerated decodeAsEnumerated() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 enumerated element.public final ASN1Integer decodeAsInteger() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 integer element.public final ASN1Long decodeAsLong() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 long element.public final ASN1Null decodeAsNull() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 null element.public final ASN1OctetString decodeAsOctetString() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 octet string element.public final ASN1Sequence decodeAsSequence() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 sequence element.public final ASN1Set decodeAsSet() throws ASN1Exception
ASN1Exception
- If a problem occurs while attempting to decode this
element as an ASN.1 set element.public static java.util.ArrayList<ASN1Element> decodeElements(byte[] encodedElements) throws ASN1Exception
encodedElements
- The byte array containing the data to decode.
ASN1Exception
- If a problem occurs while attempting to decode the
set of ASN.1 elements from the provided byte array.public final java.lang.String getProtocolElementName()
getProtocolElementName
in interface ProtocolElement
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- The object for which to make the determination.
true
if the provided object is an ASN.1 element that
is equal to this element, or false
if not. The
object will be considered equal if it is an ASN.1 element (or a
subclass) with the same type and encoded value.public final boolean equalsIgnoreType(ASN1Element element)
element
- The ASN.1 element whose value should be compared against
the value of this element.
true
if the values of the elements are equal, or
false
if not.public final boolean equalsIgnoreType(ByteString byteString)
byteString
- The byte string whose value should be compared against
the value of this element.
true
if the values are equal, or false
if not.public final boolean equalsElement(ASN1Element e)
e
- The ASN.1 element for which to make the determination.
true
ASN.1 element is equal to this element,
or false
if not. The elements will be considered
equal if they have the same type and encoded value.public final int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
toString
in interface ProtocolElement
toString
in class java.lang.Object
public void toString(java.lang.StringBuilder buffer)
toString
in interface ProtocolElement
buffer
- The buffer to which the information should be appended.public void toString(java.lang.StringBuilder buffer, int indent)
toString
in interface ProtocolElement
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |