com.sun.slamd.asn1
Class ASN1Sequence

java.lang.Object
  extended by com.sun.slamd.asn1.ASN1Element
      extended by com.sun.slamd.asn1.ASN1Sequence

public class ASN1Sequence
extends ASN1Element

This class defines an ASN.1 element that serves as a sequence, whose value is an ordered set of other ASN.1 elements.

Author:
Neil A. Wilson

Field Summary
static ASN1Element[] NO_ELEMENTS
          The set of elements that will be used if there are no elements.
 
Fields inherited from class com.sun.slamd.asn1.ASN1Element
ASN1_BOOLEAN_TYPE, ASN1_ENUMERATED_TYPE, ASN1_INTEGER_TYPE, ASN1_NULL_TYPE, ASN1_OCTET_STRING_TYPE, ASN1_SEQUENCE_TYPE, ASN1_SET_TYPE, EMPTY_BYTES
 
Constructor Summary
ASN1Sequence()
          Creates a new ASN.1 sequence with no elements encoded in the value.
ASN1Sequence(java.util.ArrayList elements)
          Creates a new ASN.1 sequence to hold the specified set of ASN.1 elements.
ASN1Sequence(ASN1Element[] elements)
          Creates a new ASN.1 sequence to hold the specified set of ASN.1 elements.
ASN1Sequence(byte type)
          Creates a new ASN.1 sequence with the specified type and no elements encoded in the value.
ASN1Sequence(byte type, java.util.ArrayList elements)
          Creates a new ASN.1 sequence with the given type to hold the specified set of ASN.1 elements.
ASN1Sequence(byte type, ASN1Element[] elements)
          Creates a new ASN.1 sequence with the given type to hold the specified set of ASN.1 elements.
 
Method Summary
 void addElement(ASN1Element element)
          Adds the specified ASN.1 element to the set of elements encoded in this sequence.
static ASN1Sequence decodeAsSequence(byte[] encodedValue)
          Decodes the provided byte array as an ASN.1 sequence element.
static ASN1Element[] decodeSequenceElements(byte[] sequenceValue)
          Decodes the provided byte array as if it were a set of ASN.1 elements.
static ASN1Element[] decodeSequenceElements(byte[] sequenceValue, int numElements)
          Decodes the provided byte array into a set of the specified number of ASN.1 elements.
 ASN1Element[] getElements()
          Retrieves the set of elements that are encoded in this ASN.1 sequence.
 void removeAllElements()
          Removes all elements encoded in the value of this ASN.1 element.
 void replaceElements(ASN1Element element)
          Replaces the current set of elements with the provided ASN.1 element.
 void replaceElements(ASN1Element[] elements)
          Replaces the current set of elements with the provided set.
 java.lang.String toString(int indent)
          Retrieves a string representation of this ASN.1 sequence.
 
Methods inherited from class com.sun.slamd.asn1.ASN1Element
byteArrayToInt, byteArrayToString, byteArrayToString, byteArrayToStringWithASCII, byteArrayToStringWithASCII, decode, decodeAsBoolean, decodeAsBoolean, decodeAsEnumerated, decodeAsEnumerated, decodeAsInteger, decodeAsInteger, decodeAsNull, decodeAsNull, decodeAsOctetString, decodeAsOctetString, decodeAsSequence, decodeAsSet, decodeAsSet, decodeLength, encode, encode, encodeLength, getBytes, getType, getTypeWithoutFlags, getValue, setType, setValue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_ELEMENTS

public static final ASN1Element[] NO_ELEMENTS
The set of elements that will be used if there are no elements.

Constructor Detail

ASN1Sequence

public ASN1Sequence()
Creates a new ASN.1 sequence with no elements encoded in the value.


ASN1Sequence

public ASN1Sequence(byte type)
Creates a new ASN.1 sequence with the specified type and no elements encoded in the value.

Parameters:
type - The type to use for this ASN.1 sequence.

ASN1Sequence

public ASN1Sequence(ASN1Element[] elements)
Creates a new ASN.1 sequence to hold the specified set of ASN.1 elements.

Parameters:
elements - The set of ASN.1 elements to encode in the value of this sequence.

ASN1Sequence

public ASN1Sequence(byte type,
                    ASN1Element[] elements)
Creates a new ASN.1 sequence with the given type to hold the specified set of ASN.1 elements.

Parameters:
type - The type to use for this ASN.1 sequence.
elements - The set of ASN.1 elements to encode in the value of this sequence.

ASN1Sequence

public ASN1Sequence(java.util.ArrayList elements)
Creates a new ASN.1 sequence to hold the specified set of ASN.1 elements.

Parameters:
elements - The set of ASN.1 elements to encode in the value of this sequence.

ASN1Sequence

public ASN1Sequence(byte type,
                    java.util.ArrayList elements)
Creates a new ASN.1 sequence with the given type to hold the specified set of ASN.1 elements.

Parameters:
type - The type to use for this ASN.1 sequence.
elements - The set of ASN.1 elements to encode in the value of this sequence.
Method Detail

getElements

public ASN1Element[] getElements()
Retrieves the set of elements that are encoded in this ASN.1 sequence.

Returns:
The set of elements that are encoded in this ASN.1 sequence.

addElement

public void addElement(ASN1Element element)
Adds the specified ASN.1 element to the set of elements encoded in this sequence.

Parameters:
element - The ASN.1 element to include in the set of elements encoded in this sequence.

removeAllElements

public void removeAllElements()
Removes all elements encoded in the value of this ASN.1 element.


replaceElements

public void replaceElements(ASN1Element element)
Replaces the current set of elements with the provided ASN.1 element.

Parameters:
element - The ASN.1 element to use to replace the existing set of elements encoded in this sequence.

replaceElements

public void replaceElements(ASN1Element[] elements)
Replaces the current set of elements with the provided set.

Parameters:
elements - The set of ASN.1 elements to use to replace the existing set of elements encoded in this sequence.

decodeAsSequence

public static ASN1Sequence decodeAsSequence(byte[] encodedValue)
                                     throws ASN1Exception
Decodes the provided byte array as an ASN.1 sequence element.

Parameters:
encodedValue - The encoded ASN.1 element.
Returns:
The decoded ASN.1 sequence element.
Throws:
ASN1Exception - If the provided byte array cannot be decoded as an ASN.1 sequence element.

decodeSequenceElements

public static ASN1Element[] decodeSequenceElements(byte[] sequenceValue)
                                            throws ASN1Exception
Decodes the provided byte array as if it were a set of ASN.1 elements.

Parameters:
sequenceValue - The set of encoded ASN.1 elements.
Returns:
The ASN.1 elements that were decoded from the provided byte array.
Throws:
ASN1Exception - If the provided byte array cannot be decoded into a set of ASN.1 elements.

decodeSequenceElements

public static ASN1Element[] decodeSequenceElements(byte[] sequenceValue,
                                                   int numElements)
                                            throws ASN1Exception
Decodes the provided byte array into a set of the specified number of ASN.1 elements.

Parameters:
sequenceValue - The set of encoded ASN.1 elements.
numElements - The number of elements to extract.
Returns:
The ASN.1 elements that were decoded from the provided byte array.
Throws:
ASN1Exception - If the provided byte array cannot be decoded into a set of ASN.1 elements.

toString

public java.lang.String toString(int indent)
Retrieves a string representation of this ASN.1 sequence. It will recursively display string representations for each of the elements.

Overrides:
toString in class ASN1Element
Parameters:
indent - The number of spaces to indent the information in the returned string.
Returns:
A string representation of this ASN.1 sequence.