Package org.mozilla.jss.asn1
Class SET
java.lang.Object
org.mozilla.jss.asn1.SET
- All Implemented Interfaces:
ASN1Value
- Direct Known Subclasses:
SEQUENCE
An ASN.1 SET, which is an unordered collection of ASN.1 values.
It has an interface like a Java Vector, but the ordering is arbitrary.
Null entries may be added; they will be skipped when encoding.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
An element of a SETstatic class
A Template for decoding SET OF values.static class
SET.Template This class is used for decoding DER-encoded SETs. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an element to this SET.private void
void
addElement
(Tag implicitTag, ASN1Value v) Adds an element to this SET with the given implicit tag.void
BERencode
(Tag implicitTag, OutputStream ostream) Encodes this SET without re-ordering it.private static int
compare
(byte[] left, byte[] right) elementAt
(int index) Returns the element at the given index in the SET.elementWithTag
(Tag tag) Returns the element with the given Tag, or null if no element exists with the given tag.void
encode
(OutputStream ostream) Writes the DER encoding to the given output stream.void
encode
(Tag implicitTag, OutputStream ostream) Writes the DER encoding to the given output stream, using the given implicit tag.getTag()
Returns the base tag for this type, not counting any tags that may be imposed on it by its context.void
insertElementAt
(ASN1Value v, int index) Inserts an element at the given index.private void
insertElementAt
(SET.Element e, int index) void
insertElementAt
(Tag implicitTag, ASN1Value v, int index) Inserts an element with the given implicit tag at the given index.private static void
insertInOrder
(Vector<byte[]> encs, byte[] enc) private static void
insertInOrder
(Vector<byte[]> encs, byte[] enc, Vector<Integer> tags, int tag) static void
void
Removes all elements from this SET.void
removeElementAt
(int index) Removes the element from the specified index.int
size()
tagAt
(int index) Returns the tag of the element at the given index.
-
Field Details
-
TAG
-
FORM
-
elements
-
-
Constructor Details
-
SET
public SET()
-
-
Method Details
-
getTag
Description copied from interface:ASN1Value
Returns the base tag for this type, not counting any tags that may be imposed on it by its context. -
addElement
-
insertElementAt
-
addElement
Adds an element to this SET.- Parameters:
v
- Element.
-
addElement
Adds an element to this SET with the given implicit tag. For example, if the ASN.1 were:MyType ::= SET { item [0] IMPLICIT INTEGER, ... }
then the "item" element could be added (with a sample value of 45) to the SET with:myTypeInstance.addElement(new Tag(0), new INTEGER(45));
- Parameters:
implicitTag
- Implicit tag.v
- Element.
-
insertElementAt
Inserts an element at the given index.- Parameters:
v
- Element.index
- Index.
-
insertElementAt
Inserts an element with the given implicit tag at the given index.- Parameters:
implicitTag
- Implicit tag.v
- Element.index
- Index.
-
elementAt
Returns the element at the given index in the SET.- Parameters:
index
- Index.- Returns:
- Element.
-
tagAt
Returns the tag of the element at the given index. If the element has an implicit tag, that is returned. Otherwise, the tag of the underlying type is returned.- Parameters:
index
- Index.- Returns:
- Tag.
-
elementWithTag
Returns the element with the given Tag, or null if no element exists with the given tag.- Parameters:
tag
- Tag.- Returns:
- Element.
-
size
public int size()- Returns:
- The number of elements in this SET.
-
removeAllElements
public void removeAllElements()Removes all elements from this SET. -
removeElementAt
public void removeElementAt(int index) Removes the element from the specified index.- Parameters:
index
- Index.
-
encode
Writes the DER encoding to the given output stream.- Specified by:
encode
in interfaceASN1Value
- Parameters:
ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
encode
Writes the DER encoding to the given output stream, using the given implicit tag. To satisfy DER encoding rules, the elements will be re-ordered either by tag or lexicographically.- Specified by:
encode
in interfaceASN1Value
- Parameters:
implicitTag
- Implicit tag.ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
BERencode
Encodes this SET without re-ordering it. This may violate DER, but it is within BER.- Parameters:
implicitTag
- Implicit tag.ostream
- Output stream.- Throws:
IOException
- If an error occurred.
-
insertInOrder
-
insertInOrder
-
compare
private static int compare(byte[] left, byte[] right) -
main
-