1    package org.bouncycastle.asn1;
2    
3    import java.io.*;
4    
5    public class ASN1OutputStream
6        extends DEROutputStream
7    {
8        public ASN1OutputStream(
9            OutputStream    os)
10       {
11           super(os);
12       }
13   
14       public void writeObject(
15           Object    obj)
16           throws IOException
17       {
18           if (obj == null)
19           {
20               writeNull();
21           }
22           else if (obj instanceof DERObject)
23           {
24               ((DERObject)obj).encode(this);
25           }
26           else if (obj instanceof DEREncodable)
27           {
28               ((DEREncodable)obj).getDERObject().encode(this);
29           }
30           else
31           {
32               throw new IOException("object not ASN1Encodable");
33           }
34       }
35   }
36