ASN1Null.java revision e6bf3e8dfa2804891a82075cb469b736321b4827
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 // BEGIN android-changed 12 /*package*/ ASN1Null() 13 { 14 } 15 // END android-changed 16 17 public static ASN1Null getInstance(Object o) 18 { 19 if (o instanceof ASN1Null) 20 { 21 return (ASN1Null)o; 22 } 23 24 if (o != null) 25 { 26 try 27 { 28 return ASN1Null.getInstance(ASN1Primitive.fromByteArray((byte[])o)); 29 } 30 catch (IOException e) 31 { 32 throw new IllegalArgumentException("failed to construct NULL from byte[]: " + e.getMessage()); 33 } 34 catch (ClassCastException e) 35 { 36 throw new IllegalArgumentException("unknown object in getInstance(): " + o.getClass().getName()); 37 } 38 } 39 40 return null; 41 } 42 43 public int hashCode() 44 { 45 return -1; 46 } 47 48 boolean asn1Equals( 49 ASN1Primitive o) 50 { 51 if (!(o instanceof ASN1Null)) 52 { 53 return false; 54 } 55 56 return true; 57 } 58 59 abstract void encode(ASN1OutputStream out) 60 throws IOException; 61 62 public String toString() 63 { 64 return "NULL"; 65 } 66} 67