2002/03/21 01:19:32
[org.ibex.core.git] / src / org / bouncycastle / asn1 / DERBoolean.java
diff --git a/src/org/bouncycastle/asn1/DERBoolean.java b/src/org/bouncycastle/asn1/DERBoolean.java
new file mode 100644 (file)
index 0000000..4fce317
--- /dev/null
@@ -0,0 +1,37 @@
+package org.bouncycastle.asn1;
+
+import java.io.*;
+
+public class DERBoolean
+    extends DERObject
+{
+    byte         value;
+
+    public DERBoolean(
+        byte[]       value)
+    {
+        this.value = value[0];
+    }
+
+    public DERBoolean(
+        boolean     value)
+    {
+        this.value = (value) ? (byte)0xff : (byte)0;
+    }
+
+    public boolean isTrue()
+    {
+        return (value != 0);
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException
+    {
+        byte[]  bytes = new byte[1];
+
+        bytes[0] = value;
+
+        out.writeEncoded(BOOLEAN, bytes);
+    }
+}