iaik.asn1
Class SET

java.lang.Object
  |
  +--iaik.asn1.ASN1Object
        |
        +--iaik.asn1.ConstructedType
              |
              +--iaik.asn1.SET
All Implemented Interfaces:
Cloneable

public class SET
extends ConstructedType

This class implements the ASN.1 native type "SET". SET is a structered ASN.1 type identified by the UNIVERSAL TAG number 17. An ASN.1 SET object is composed of several unordered components. All the components may have the same type or may have different types.

A SET object is DER encoded using the constructed encoding practice by splitting it into separately encoded components. Therefore the SEQUENCE class is extended to be a subclass of the ConstructedType class. Each component can be added to the current SET object by using a proper addComponent method of the ConstructedType super class.

The constructed form can be recognized by bit 6 of the (first) identifier octet(s) of the DER encoded bit stream, which is set to 1.

The following example creates a new SET object and adds an INTERGER, BOOLEAN, and a PrintableString component:

 SET set = new SET();
 set.addComponent(new INTEGER(3));
 set.addComponent(new BOOLEAN(true));
 set.addComponent(new PrintableString("Test"));
 
Of course, sets may be nested meaning that one SET contains another SET as one of its components. The nesting may be of any depth.

Version:
File Revision 19
See Also:
ASN1Object, ASN, ConstructedType, ConstructedType.addComponent(iaik.asn1.ASN1Object)

Field Summary
protected  boolean sorted
           
 
Fields inherited from class iaik.asn1.ConstructedType
content_count, content_data
 
Fields inherited from class iaik.asn1.ASN1Object
asnType, constructed, encode_listener, indefinite_length, isStringType, stream_mode
 
Constructor Summary
SET()
          Creates a new SET.
SET(boolean sorted)
          Creates a new SET.
 
Method Summary
protected  void encode(OutputStream os)
          DER encodes this ASN1Object and writes the result to the supplied OutputStream.
 String toString()
          Returns a String that represents the value of this SET.
 
Methods inherited from class iaik.asn1.ConstructedType
addComponent, addComponent, addEncodeListener, clone, countComponents, decode, getComponentAt, getComponents, getValue, removeComponent, removeComponent, setComponent, setValue
 
Methods inherited from class iaik.asn1.ASN1Object
addEncodeListener, encodeObject, getAsnType, indefiniteLength, isA, isConstructed, isStringType, setIndefiniteLength
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sorted

protected boolean sorted
Constructor Detail

SET

public SET()
Creates a new SET.

Components may be added by means of the addComponent method of the ConstructedType super class.


SET

public SET(boolean sorted)
Creates a new SET. If the parameter sorted is set to true the components are sorted by their encodings. This constructor only shall be used for creating SET OF structures where all components have the same type. In this way, an application may prefer to call the createSetOf(ASN1Type[] array, boolean sorted) method of class ASN for creating the SET OF.
Parameters:
sorted - whether to sort the components by their encodings or not
Method Detail

toString

public String toString()
Returns a String that represents the value of this SET.
Overrides:
toString in class ASN1Object
Returns:
the String representation
See Also:
ASN1Object.toString()

encode

protected void encode(OutputStream os)
               throws IOException
Description copied from class: ConstructedType
DER encodes this ASN1Object and writes the result to the supplied OutputStream. In stream mode the components are encoded in correct order and the indefinite length encoding method is used, in normal mode the components are encoded in reverse order to facilitate length determination. Indefinite length encoding may be preferable when dealing with large objects where whole the data is not known at beginning of the data transfer.
Overrides:
encode in class ConstructedType
Following copied from class: iaik.asn1.ConstructedType
Parameters:
os - the output stream to which to write the data
Throws:
IOException - if an error occurs while reading from the stream

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK