org.mozilla.jss.asn1

Class SET

public class SET extends Object implements ASN1Value

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
static classSET.OF_Template
A Template for decoding SET OF values.
static classSET.Template
SET.Template This class is used for decoding DER-encoded SETs.
Field Summary
protected Vectorelements
protected static FormFORM
static TagTAG
Method Summary
voidaddElement(ASN1Value v)
Adds an element to this SET.
voidaddElement(Tag implicitTag, ASN1Value v)
Adds an element to this SET with the given implicit tag.
voidBERencode(Tag implicitTag, OutputStream ostream)
Encodes this SET without re-ordering it.
ASN1ValueelementAt(int index)
Returns the element at the given index in the SET.
ASN1ValueelementWithTag(Tag tag)
Returns the element with the given Tag, or null if no element exists with the given tag.
voidencode(OutputStream ostream)
Writes the DER encoding to the given output stream.
voidencode(Tag implicitTag, OutputStream ostream)
Writes the DER encoding to the given output stream, using the given implicit tag.
TaggetTag()
voidinsertElementAt(ASN1Value v, int index)
Inserts an element at the given index.
voidinsertElementAt(Tag implicitTag, ASN1Value v, int index)
Inserts an element with the given implicit tag at the given index.
static voidmain(String[] args)
voidremoveAllElements()
Removes all elements from this SET.
voidremoveElementAt(int index)
Removes the element from the specified index.
intsize()
Returns the number of elements in this SET.
TagtagAt(int index)
Returns the tag of the element at the given index.

Field Detail

elements

protected Vector elements

FORM

protected static final Form FORM

TAG

public static final Tag TAG

Method Detail

addElement

public void addElement(ASN1Value v)
Adds an element to this SET.

addElement

public void addElement(Tag implicitTag, ASN1Value v)
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) );
 

BERencode

public void BERencode(Tag implicitTag, OutputStream ostream)
Encodes this SET without re-ordering it. This may violate DER, but it is within BER.

elementAt

public ASN1Value elementAt(int index)
Returns the element at the given index in the SET.

elementWithTag

public ASN1Value elementWithTag(Tag tag)
Returns the element with the given Tag, or null if no element exists with the given tag.

encode

public void encode(OutputStream ostream)
Writes the DER encoding to the given output stream.

encode

public void encode(Tag implicitTag, OutputStream ostream)
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.

getTag

public Tag getTag()

insertElementAt

public void insertElementAt(ASN1Value v, int index)
Inserts an element at the given index.

insertElementAt

public void insertElementAt(Tag implicitTag, ASN1Value v, int index)
Inserts an element with the given implicit tag at the given index.

main

public static void main(String[] args)

removeAllElements

public void removeAllElements()
Removes all elements from this SET.

removeElementAt

public void removeElementAt(int index)
Removes the element from the specified index.

size

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

tagAt

public Tag tagAt(int index)
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.