1 package com.lowagie.bc.asn1; 2 3 import java.io.ByteArrayOutputStream; 4 import java.io.IOException; 5 6 9 public abstract class ASN1Encodable 10 implements DEREncodable 11 { 12 17 public byte[] getEncoded() 18 throws IOException 19 { 20 ByteArrayOutputStream bOut = new ByteArrayOutputStream(); 21 ASN1OutputStream aOut = new ASN1OutputStream(bOut); 22 23 aOut.writeObject(this); 24 25 return bOut.toByteArray(); 26 } 27 28 31 public int hashCode() 32 { 33 return this.getDERObject().hashCode(); 34 } 35 36 39 public boolean equals( 40 Object o) 41 { 42 if ((o == null) || !(o instanceof DEREncodable)) 43 { 44 return false; 45 } 46 47 DEREncodable other = (DEREncodable)o; 48 49 return this.getDERObject().equals(other.getDERObject()); 50 } 51 52 55 public DERObject getDERObject() 56 { 57 return this.toASN1Object(); 58 } 59 60 64 public abstract DERObject toASN1Object(); 65 } 66 | Popular Tags |