001package org.apache.commons.ssl.asn1;
002
003import java.io.IOException;
004import java.util.Enumeration;
005
006public class BERSet
007    extends DERSet {
008    /** create an empty sequence */
009    public BERSet() {
010    }
011
012    /** create a set containing one object */
013    public BERSet(
014        DEREncodable obj) {
015        super(obj);
016    }
017
018    /** @param v - a vector of objects making up the set. */
019    public BERSet(
020        DEREncodableVector v) {
021        super(v, false);
022    }
023
024    /** @param v - a vector of objects making up the set. */
025    BERSet(
026        DEREncodableVector v,
027        boolean needsSorting) {
028        super(v, needsSorting);
029    }
030
031    /*
032     */
033    void encode(
034        DEROutputStream out)
035        throws IOException {
036        if (out instanceof ASN1OutputStream || out instanceof BEROutputStream) {
037            out.write(SET | CONSTRUCTED);
038            out.write(0x80);
039
040            Enumeration e = getObjects();
041            while (e.hasMoreElements()) {
042                out.writeObject(e.nextElement());
043            }
044
045            out.write(0x00);
046            out.write(0x00);
047        } else {
048            super.encode(out);
049        }
050    }
051}