1 17 18 package org.apache.geronimo.util.asn1; 19 20 import java.io.IOException ; 21 22 27 public abstract class ASN1TaggedObject 28 extends DERObject 29 { 30 int tagNo; 31 boolean empty = false; 32 boolean explicit = true; 33 DEREncodable obj = null; 34 35 static public ASN1TaggedObject getInstance( 36 ASN1TaggedObject obj, 37 boolean explicit) 38 { 39 if (explicit) 40 { 41 return (ASN1TaggedObject)obj.getObject(); 42 } 43 44 throw new IllegalArgumentException ("implicitly tagged tagged object"); 45 } 46 47 53 public ASN1TaggedObject( 54 int tagNo, 55 DEREncodable obj) 56 { 57 this.explicit = true; 58 this.tagNo = tagNo; 59 this.obj = obj; 60 } 61 62 72 public ASN1TaggedObject( 73 boolean explicit, 74 int tagNo, 75 DEREncodable obj) 76 { 77 if (obj instanceof ASN1Choice) 78 { 79 this.explicit = true; 80 } 81 else 82 { 83 this.explicit = explicit; 84 } 85 86 this.tagNo = tagNo; 87 this.obj = obj; 88 } 89 90 public boolean equals( 91 Object o) 92 { 93 if (o == null || !(o instanceof ASN1TaggedObject)) 94 { 95 return false; 96 } 97 98 ASN1TaggedObject other = (ASN1TaggedObject)o; 99 100 if (tagNo != other.tagNo || empty != other.empty || explicit != other.explicit) 101 { 102 return false; 103 } 104 105 if(obj == null) 106 { 107 if(other.obj != null) 108 { 109 return false; 110 } 111 } 112 else 113 { 114 if(!(obj.equals(other.obj))) 115 { 116 return false; 117 } 118 } 119 120 return true; 121 } 122 123 public int hashCode() 124 { 125 int code = tagNo; 126 127 if (obj != null) 128 { 129 code ^= obj.hashCode(); 130 } 131 132 return code; 133 } 134 135 public int getTagNo() 136 { 137 return tagNo; 138 } 139 140 149 public boolean isExplicit() 150 { 151 return explicit; 152 } 153 154 public boolean isEmpty() 155 { 156 return empty; 157 } 158 159 166 public DERObject getObject() 167 { 168 if (obj != null) 169 { 170 return obj.getDERObject(); 171 } 172 173 return null; 174 } 175 176 abstract void encode(DEROutputStream out) 177 throws IOException ; 178 } 179 | Popular Tags |