Package org.mozilla.jss.asn1
Class SEQUENCE.Template
java.lang.Object
org.mozilla.jss.asn1.SEQUENCE.Template
- All Implemented Interfaces:
ASN1Template
- Direct Known Subclasses:
Encoding.Template
- Enclosing class:
SEQUENCE
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
An element of a SEQUENCE template. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a sub-template to the end of this SEQUENCE template.void
addElement
(ASN1Template t, ASN1Value def) Adds a sub-template with a default value.private void
void
addElement
(Tag implicitTag, ASN1Template t) Adds a sub-template to the end of this SEQUENCE template, with the given implicit tag.void
addElement
(Tag implicitTag, ASN1Template t, ASN1Value def) Adds a sub-template with a default value and an implicit tag.void
Adds an optional sub-template.void
addOptionalElement
(Tag implicitTag, ASN1Template t) Adds an optional sub-template with an implicit tag.decode
(InputStream istream) Decodes a SEQUENCE from its BER encoding.decode
(Tag tag, InputStream istream) Decodes a SEQUENCE from its BER encoding, where the SEQUENCE itself has an implicit tag.defaultAt
(int index) Returns the default value for the sub-template at the given index.(package private) Tag
getTag()
implicitTagAt
(int index) Returns the implicit tag of the item stored at the given index.void
insertElementAt
(ASN1Template t, int index) Inserts the template at the given index.void
insertElementAt
(ASN1Template t, ASN1Value def, int index) Inserts the template with the given default value at the given index.private void
insertElementAt
(SEQUENCE.Template.Element e, int index) void
insertElementAt
(Tag implicit, ASN1Template t, int index) Inserts the template with the given implicit tag at the given index.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.void
insertOptionalElementAt
(ASN1Template t, int index) Inserts the optional template at the given index.void
insertOptionalElementAt
(Tag implicit, ASN1Template t, int index) Inserts the optional template with the given default value at the given index.boolean
isOptionalAt
(int index) Returns whether the sub-template at the given index is optional.void
Removes all sub-templates from this SEQUENCE template.void
removeElementAt
(int index) Removes the sub-template at the given index.int
size()
boolean
Determines whether the given tag will satisfy this template.templateAt
(int index) Returns the sub-template stored at the given index.
-
Field Details
-
elements
-
-
Constructor Details
-
Template
public Template()
-
-
Method Details
-
addElement
-
insertElementAt
-
addElement
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());
- Parameters:
t
- Sub-template.
-
insertElementAt
Inserts the template at the given index.- Parameters:
t
- Sub-template.index
- Index.
-
addElement
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());
- Parameters:
implicitTag
- Implicit tag.t
- Sub-template.
-
insertElementAt
Inserts the template with the given implicit tag at the given index.- Parameters:
implicit
- Implicit tag.t
- Sub-Template.index
- Index.
-
addOptionalElement
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());
- Parameters:
t
- Optional sub-template.
-
insertOptionalElementAt
Inserts the optional template at the given index.- Parameters:
t
- Optional sub-template.index
- Index.
-
addOptionalElement
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());
- Parameters:
implicitTag
- Implicit tag.t
- Optional sub-template.
-
insertOptionalElementAt
Inserts the optional template with the given default value at the given index.- Parameters:
implicit
- Implicit tag.t
- Optional sub-template.index
- Index.
-
addElement
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:
t
- Sub-template.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.
-
insertElementAt
Inserts the template with the given default value at the given index.- Parameters:
t
- Sub-template.def
- Default value.index
- Index.
-
addElement
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:
implicitTag
- Implicit tag.t
- Sub-template.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.
-
insertElementAt
Inserts the template with the given implicit tag and given default value at the given index.- Parameters:
implicit
- Implicit tag.t
- Sub-template.def
- Default value.index
- Index.
-
implicitTagAt
Returns the implicit tag of the item stored at the given index. May be NULL if no implicit tag was specified.- Parameters:
index
- Index.- Returns:
- Tag.
-
templateAt
Returns the sub-template stored at the given index.- Parameters:
index
- Index.- Returns:
- Sub-template.
-
isOptionalAt
public boolean isOptionalAt(int index) Returns whether the sub-template at the given index is optional.- Parameters:
index
- Index.- Returns:
- True if the sub-template is optional.
-
defaultAt
Returns the default value for the sub-template at the given index. May return NULL if no default value was specified.- Parameters:
index
- Index.- Returns:
- Default value.
-
size
public int size()- Returns:
- The number of elements in this SEQUENCE template.
-
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.- Parameters:
index
- Index.
-
getTag
Tag getTag() -
tagMatch
Description copied from interface:ASN1Template
Determines whether the given tag will satisfy this template.- Specified by:
tagMatch
in interfaceASN1Template
- Parameters:
tag
- Tag.- Returns:
- True if the given tag will satisfy this template.
-
decode
Decodes a SEQUENCE from its BER encoding.- Specified by:
decode
in interfaceASN1Template
- Parameters:
istream
- Input stream.- Returns:
- ASN.1 value.
- Throws:
IOException
- If other error occurred.InvalidBERException
- If there is an invalid BER encoding.
-
decode
Decodes a SEQUENCE from its BER encoding, where the SEQUENCE itself has an implicit tag.- Specified by:
decode
in interfaceASN1Template
- Parameters:
tag
- Tag.istream
- Input stream.- Returns:
- ASN.1 value.
- Throws:
IOException
- If other error occurred.InvalidBERException
- If there is an invalid BER encoding.
-