Package org.mozilla.jss.asn1
Class CHOICE.Template
java.lang.Object
org.mozilla.jss.asn1.CHOICE.Template
- All Implemented Interfaces:
ASN1Template
- Enclosing class:
CHOICE
A Template for decoding ASN.1
CHOICE
s-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
An element in a CHOICE template, consisting of a nested template and, optionally, an implicit tag for that template. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(ASN1Template template) Adds a new sub-template to this CHOICE template with no implicit tag.void
addElement
(Tag implicitTag, ASN1Template template) Adds a new sub-template to this CHOICE template with an implicit tag.decode
(InputStream istream) Decodes an ASN1Value from the InputStream without an implicit tag.decode
(Tag implicitTag, InputStream istream) Decodes a CHOICE.elementAt
(int index) implicitTagAt
(int index) Retrieves the implicit tag of the element at the specified index.void
Empties this CHOICE template.void
removeElementAt
(int index) Removes the element at the specified index.int
size()
boolean
Determines whether the given tag will satisfy this template.
-
Field Details
-
templates
-
-
Constructor Details
-
Template
public Template()Creates an empty CHOICE template
-
-
Method Details
-
addElement
Adds a new sub-template to this CHOICE template with no implicit tag.- Parameters:
template
- Sub-template.
-
addElement
Adds a new sub-template to this CHOICE template with an implicit tag.- Parameters:
implicitTag
- Implicit tag.template
- Sub-template.
-
size
public int size()- Returns:
- The number of elements in this CHOICE template.
-
elementAt
- Parameters:
index
- Element index.- Returns:
- The element at the specified index.
-
implicitTagAt
Retrieves the implicit tag of the element at the specified index. Returns null if there is no implicit tag for this element.- Parameters:
index
- Element index.- Returns:
- The implicit tag.
-
removeAllElements
public void removeAllElements()Empties this CHOICE template. -
removeElementAt
public void removeElementAt(int index) Removes the element at the specified index.- Parameters:
index
- Element index.
-
tagMatch
Determines whether the given tag will satisfy this template.- Specified by:
tagMatch
in interfaceASN1Template
- Parameters:
t
- The tag.- Returns:
- True if the tag satisfies any sub-template.
-
decode
Description copied from interface:ASN1Template
Decodes an ASN1Value from the InputStream without an implicit tag.- Specified by:
decode
in interfaceASN1Template
- Parameters:
istream
- Must support marking (markSupported() == true). For example, ByteArrayInputStream and BufferedInputStream support marking, but FileInputStream does not. If your source does not support marking, you can wrap it in a BufferedInputStream.- Returns:
- ASN.1 value.
- Throws:
IOException
- If other error occurred.InvalidBERException
- If there is an invalid BER encoding.
-
decode
public ASN1Value decode(Tag implicitTag, InputStream istream) throws IOException, InvalidBERException Decodes a CHOICE.- Specified by:
decode
in interfaceASN1Template
- Parameters:
implicitTag
- This parameter is ignored. A choice cannot have an implicit tag.istream
- Must support marking (markSupported() == true). For example, ByteArrayInputStream and BufferedInputStream support marking, but FileInputStream does not. If your source does not support marking, you can wrap it in a BufferedInputStream.- Returns:
- ASN.1 value.
- Throws:
IOException
- If other error occurred.InvalidBERException
- If there is an invalid BER encoding.
-