1    package org.bouncycastle.asn1;
2    
3    import java.io.*;
4    import java.util.*;
5    
6    public class BERSet
7        extends DERSet
8    {
9        /**
10        * create an empty sequence
11        */
12       public BERSet()
13       {
14       }
15   
16       /**
17        * create a set containing one object
18        */
19       public BERSet(
20           DEREncodable    obj)
21       {
22           super(obj);
23       }
24   
25       /**
26        * create a set containing a vector of objects.
27        */
28       public BERSet(
29           DEREncodableVector   v)
30       {
31           super(v);
32       }
33   
34       /*
35        */
36       void encode(
37           DEROutputStream out)
38           throws IOException
39       {
40           if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
41           {
42               out.write(SET | CONSTRUCTED);
43               out.write(0x80);
44               
45               Enumeration e = getObjects();
46               while (e.hasMoreElements())
47               {
48                   out.writeObject(e.nextElement());
49               }
50           
51               out.write(0x00);
52               out.write(0x00);
53           }
54           else
55           {
56               super.encode(out);
57           }
58       }
59   }
60