2003/02/12 06:21:04
[org.ibex.core.git] / src / org / bouncycastle / asn1 / DERTaggedObject.java
index 4ec0310..ba69412 100644 (file)
@@ -8,26 +8,8 @@ import java.io.*;
  * rules (as with sequences).
  */
 public class DERTaggedObject
-    extends DERObject
+    extends ASN1TaggedObject
 {
-    int             tagNo;
-    boolean         empty = false;
-    boolean         explicit = true;
-    DEREncodable    obj = null;
-
-    /**
-     * This creates an empty tagged object of tagNo (ie. zero length).
-     *
-     * @param tagNo the tag number for this object.
-     */
-    public DERTaggedObject(
-        int     tagNo)
-    {
-        this.explicit = true;
-        this.tagNo = tagNo;
-        this.empty = true; 
-    }
-
     /**
      * @param tagNo the tag number for this object.
      * @param obj the tagged object.
@@ -36,13 +18,11 @@ public class DERTaggedObject
         int             tagNo,
         DEREncodable    obj)
     {
-        this.explicit = true;
-        this.tagNo = tagNo;
-        this.obj = obj;
+               super(tagNo, obj);
     }
 
     /**
-     * @param explicit true if the object is explicitly tagged.
+     * @param explicit true if an explicitly tagged object.
      * @param tagNo the tag number for this object.
      * @param obj the tagged object.
      */
@@ -51,29 +31,17 @@ public class DERTaggedObject
         int             tagNo,
         DEREncodable    obj)
     {
-        this.explicit = explicit;
-        this.tagNo = tagNo;
-        this.obj = obj;
-    }
-
-    public int getTagNo()
-    {
-        return tagNo;
-    }
-
-    public boolean isExplicit()
-    {
-        return explicit;
-    }
-
-    public boolean isEmpty()
-    {
-        return empty;
+               super(explicit, tagNo, obj);
     }
 
-    public DERObject getObject()
+    /**
+     * create an implicitly tagged object that contains a zero
+     * length sequence.
+     */
+    public DERTaggedObject(
+        int             tagNo)
     {
-        return obj.getDERObject();
+        super(false, tagNo, new DERSequence());
     }
 
     void encode(
@@ -92,7 +60,7 @@ public class DERTaggedObject
 
             if (explicit)
             {
-                out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bOut.toByteArray());
+                out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bytes);
             }
             else
             {