01: package org.bouncycastle.asn1;
02:
03: import java.io.IOException;
04: import java.util.Enumeration;
05:
06: public class BERSet extends DERSet {
07: /**
08: * create an empty sequence
09: */
10: public BERSet() {
11: }
12:
13: /**
14: * create a set containing one object
15: */
16: public BERSet(DEREncodable obj) {
17: super (obj);
18: }
19:
20: /**
21: * @param v - a vector of objects making up the set.
22: */
23: public BERSet(DEREncodableVector v) {
24: super (v, false);
25: }
26:
27: /**
28: * @param v - a vector of objects making up the set.
29: */
30: BERSet(DEREncodableVector v, boolean needsSorting) {
31: super (v, needsSorting);
32: }
33:
34: /*
35: */
36: void encode(DEROutputStream out) throws IOException {
37: if (out instanceof ASN1OutputStream
38: || out instanceof BEROutputStream) {
39: out.write(SET | CONSTRUCTED);
40: out.write(0x80);
41:
42: Enumeration e = getObjects();
43: while (e.hasMoreElements()) {
44: out.writeObject(e.nextElement());
45: }
46:
47: out.write(0x00);
48: out.write(0x00);
49: } else {
50: super.encode(out);
51: }
52: }
53: }
|