org.mozilla.jss.asn1

Class SEQUENCE.Template

public static class SEQUENCE.Template extends Object implements ASN1Template

A class for constructing a SEQUENCE from its BER encoding. It is an ordered collection of sub-templates. Each sub-template can be marked optional, or a default value can be given.
Method Summary
voidaddElement(ASN1Template t)
Adds a sub-template to the end of this SEQUENCE template.
voidaddElement(Tag implicitTag, ASN1Template t)
Adds a sub-template to the end of this SEQUENCE template, with the given implicit tag.
voidaddElement(ASN1Template t, ASN1Value def)
Adds a sub-template with a default value.
voidaddElement(Tag implicitTag, ASN1Template t, ASN1Value def)
Adds a sub-template with a default value and an implicit tag.
voidaddOptionalElement(ASN1Template t)
Adds an optional sub-template.
voidaddOptionalElement(Tag implicitTag, ASN1Template t)
Adds an optional sub-template with an implicit tag.
ASN1Valuedecode(InputStream istream)
Decodes a SEQUENCE from its BER encoding.
ASN1Valuedecode(Tag tag, InputStream istream)
Decodes a SEQUENCE from its BER encoding, where the SEQUENCE itself has an implicit tag.
ASN1ValuedefaultAt(int index)
Returns the default value for the sub-template at the given index.
TagimplicitTagAt(int index)
Returns the implicit tag of the item stored at the given index.
voidinsertElementAt(ASN1Template t, int index)
Inserts the template at the given index.
voidinsertElementAt(Tag implicit, ASN1Template t, int index)
Inserts the template with the given implicit tag at the given index.
voidinsertElementAt(ASN1Template t, ASN1Value def, int index)
Inserts the template with the given default value at the given index.
voidinsertElementAt(Tag implicit, ASN1Template t, ASN1Value def, int index)
Inserts the template with the given implicit tag and given default value at the given index.
voidinsertOptionalElementAt(ASN1Template t, int index)
Inserts the optional template at the given index.
voidinsertOptionalElementAt(Tag implicit, ASN1Template t, int index)
Inserts the optional template with the given default value at the given index.
booleanisOptionalAt(int index)
Returns whether the sub-template at the given index is optional.
voidremoveAllElements()
Removes all sub-templates from this SEQUENCE template.
voidremoveElementAt(int index)
Removes the sub-template at the given index.
intsize()
Returns the number of elements in this SEQUENCE template.
booleantagMatch(Tag tag)
ASN1TemplatetemplateAt(int index)
Returns the sub-template stored at the given index.

Method Detail

addElement

public void addElement(ASN1Template t)
Adds a sub-template to the end of this SEQUENCE template. For example, if the ASN.1 included:
 MySequence ::= SEQUENCE {
      item        SubType,
      ... }
 
the "item" element would be added to the MySequence template with:
  mySequence.addElement( new SubType.Template() );
 

addElement

public void addElement(Tag implicitTag, ASN1Template t)
Adds a sub-template to the end of this SEQUENCE template, with the given implicit tag. For example, if the ASN.1 were:
 MySequence ::= SEQUENCE {
      item        [0] IMPLICIT  SubType,
      ... }
 
the "item" element would be added to the MySequence template with:
  mySequence.addElement( new Tag(0), new SubType.Template());
 

addElement

public void addElement(ASN1Template t, ASN1Value def)
Adds a sub-template with a default value. For example, if the ASN.1 were:
 MySequence ::= SEQUENCE {
      version     INTEGER DEFAULT 1,
      ... }
 
the "item" element would be added to the MySequence template with:
  mySequence.addElement( new INTEGER.Template(), new INTEGER(1) );
 

Parameters: def The default value for this field, which will be used if no value is supplied by the encoded structure. It must be of the same type as what the template would produce.

addElement

public void addElement(Tag implicitTag, ASN1Template t, ASN1Value def)
Adds a sub-template with a default value and an implicit tag. For example, if the ASN.1 were:
 MySequence ::= SEQUENCE {
      version     [0] IMPLICIT INTEGER DEFAULT 1,
      ... }
 
the "item" element would be added to the MySequence template with:
  mySequence.addElement( new Tag(0), new INTEGER.Template(),
      new INTEGER(1) );
 

Parameters: def The default value for this field, which will be used if no value is supplied by the encoded structure. It must be of the same type as what the template would produce.

addOptionalElement

public void addOptionalElement(ASN1Template t)
Adds an optional sub-template. For example, if the ASN.1 were:
 MySequence ::= SEQUENCE {
      item        SubType OPTIONAL,
      ... }
 
the "item" element would be added to the MySequence template with:
  mySequence.addOptionalElement( new SubType.Template() );
 

addOptionalElement

public void addOptionalElement(Tag implicitTag, ASN1Template t)
Adds an optional sub-template with an implicit tag. For example, if the ASN.1 were:
 MySequence ::= SEQUENCE {
      item        [0] IMPLICIT SubType OPTIONAL,
      ... }
 
the "item" element would be added to the MySequence template with:
  mySequence.addOptionalElement( new SubType.Template() );
 

decode

public ASN1Value decode(InputStream istream)
Decodes a SEQUENCE from its BER encoding.

decode

public ASN1Value decode(Tag tag, InputStream istream)
Decodes a SEQUENCE from its BER encoding, where the SEQUENCE itself has an implicit tag.

defaultAt

public ASN1Value defaultAt(int index)
Returns the default value for the sub-template at the given index. May return NULL if no default value was specified.

implicitTagAt

public Tag implicitTagAt(int index)
Returns the implicit tag of the item stored at the given index. May be NULL if no implicit tag was specified.

insertElementAt

public void insertElementAt(ASN1Template t, int index)
Inserts the template at the given index.

insertElementAt

public void insertElementAt(Tag implicit, ASN1Template t, int index)
Inserts the template with the given implicit tag at the given index.

insertElementAt

public void insertElementAt(ASN1Template t, ASN1Value def, int index)
Inserts the template with the given default value at the given index.

insertElementAt

public void insertElementAt(Tag implicit, ASN1Template t, ASN1Value def, int index)
Inserts the template with the given implicit tag and given default value at the given index.

insertOptionalElementAt

public void insertOptionalElementAt(ASN1Template t, int index)
Inserts the optional template at the given index.

insertOptionalElementAt

public void insertOptionalElementAt(Tag implicit, ASN1Template t, int index)
Inserts the optional template with the given default value at the given index.

isOptionalAt

public boolean isOptionalAt(int index)
Returns whether the sub-template at the given index is optional.

removeAllElements

public void removeAllElements()
Removes all sub-templates from this SEQUENCE template.

removeElementAt

public void removeElementAt(int index)
Removes the sub-template at the given index.

size

public int size()
Returns the number of elements in this SEQUENCE template.

tagMatch

public boolean tagMatch(Tag tag)

templateAt

public ASN1Template templateAt(int index)
Returns the sub-template stored at the given index.