Home | History | Annotate | Download | only in asn1
      1 package org.bouncycastle.asn1;
      2 
      3 import java.io.IOException;
      4 
      5 public abstract  class ASN1Object
      6     extends DERObject
      7 {
      8     /**
      9      * Create a base ASN.1 object from a byte stream.
     10      *
     11      * @param data the byte stream to parse.
     12      * @return the base ASN.1 object represented by the byte stream.
     13      * @exception IOException if there is a problem parsing the data.
     14      */
     15     public static ASN1Object fromByteArray(byte[] data)
     16         throws IOException
     17     {
     18         ASN1InputStream aIn = new ASN1InputStream(data);
     19 
     20         return (ASN1Object)aIn.readObject();
     21     }
     22 
     23     public final boolean equals(Object o)
     24     {
     25         if (this == o)
     26         {
     27             return true;
     28         }
     29 
     30         return (o instanceof DEREncodable) && asn1Equals(((DEREncodable)o).getDERObject());
     31     }
     32 
     33     public abstract int hashCode();
     34 
     35     abstract void encode(DEROutputStream out) throws IOException;
     36 
     37     abstract boolean asn1Equals(DERObject o);
     38 }
     39