KickJava   Java API By Example, From Geeks To Geeks.

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


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 BERSequence
24     extends DERSequence
25 {
26     /**
27      * create an empty sequence
28      */

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

36     public BERSequence(
37         DEREncodable obj)
38     {
39         super(obj);
40     }
41
42     /**
43      * create a sequence containing a vector of objects.
44      */

45     public BERSequence(
46         DEREncodableVector v)
47     {
48         super(v);
49     }
50
51     /*
52      */

53     void encode(
54         DEROutputStream out)
55         throws IOException JavaDoc
56     {
57         if (out instanceof ASN1OutputStream || out instanceof BEROutputStream)
58         {
59             out.write(SEQUENCE | CONSTRUCTED);
60             out.write(0x80);
61
62             Enumeration JavaDoc e = getObjects();
63             while (e.hasMoreElements())
64             {
65                 out.writeObject(e.nextElement());
66             }
67
68             out.write(0x00);
69             out.write(0x00);
70         }
71         else
72         {
73             super.encode(out);
74         }
75     }
76 }
77
Popular Tags