1package org.bouncycastle.asn1; 2 3import java.io.IOException; 4 5/** 6 * A NULL object. 7 */ 8public abstract class ASN1Null 9 extends ASN1Primitive 10{ 11 /** 12 * @deprecated use DERNull.INSTANCE 13 */ 14 // BEGIN android-changed 15 /*package*/ ASN1Null() 16 { 17 } 18 // END android-changed 19 20 public static ASN1Null getInstance(Object o) 21 { 22 if (o instanceof ASN1Null) 23 { 24 return (ASN1Null)o; 25 } 26 27 if (o != null) 28 { 29 try 30 { 31 return ASN1Null.getInstance(ASN1Primitive.fromByteArray((byte[])o)); 32 } 33 catch (IOException e) 34 { 35 throw new IllegalArgumentException("failed to construct NULL from byte[]: " + e.getMessage()); 36 } 37 catch (ClassCastException e) 38 { 39 throw new IllegalArgumentException("unknown object in getInstance(): " + o.getClass().getName()); 40 } 41 } 42 43 return null; 44 } 45 46 public int hashCode() 47 { 48 return -1; 49 } 50 51 boolean asn1Equals( 52 ASN1Primitive o) 53 { 54 if (!(o instanceof ASN1Null)) 55 { 56 return false; 57 } 58 59 return true; 60 } 61 62 abstract void encode(ASN1OutputStream out) 63 throws IOException; 64 65 public String toString() 66 { 67 return "NULL"; 68 } 69} 70