KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > BERSet


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.util.asn1;
19
20 import java.io.IOException JavaDoc;
21 import java.util.Enumeration JavaDoc;
22
23 public class BERSet
24     extends DERSet
25 {
26     /**
27      * create an empty sequence
28      */

29     public BERSet()
30     {
31     }
32
33     /**
34      * create a set containing one object
35      */

36     public BERSet(
37         DEREncodable obj)
38     {
39         super(obj);
40     }
41
42     /**
43      * @param v - a vector of objects making up the set.
44      */

45     public BERSet(
46         DEREncodableVector v)
47     {
48         super(v, true);
49     }
50
51     /**
52      * @param v - a vector of objects making up the set.
53      */

54     BERSet(
55         DEREncodableVector v,
56         boolean needsSorting)
57     {
58         super(v, needsSorting);
59     }
60
61     /*
62      */

63     void encode(
64         DEROutputStream out)
65         throws IOException JavaDoc
66     {
67         if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
68         {
69             out.write(SET | CONSTRUCTED);
70             out.write(0x80);
71
72             Enumeration JavaDoc e = getObjects();
73             while (e.hasMoreElements())
74             {
75                 out.writeObject(e.nextElement());
76             }
77
78             out.write(0x00);
79             out.write(0x00);
80         }
81         else
82         {
83             super.encode(out);
84         }
85     }
86 }
87
Popular Tags