iaik.asn1
Class BOOLEAN

java.lang.Object
  |
  +--iaik.asn1.ASN1Object
        |
        +--iaik.asn1.BOOLEAN
All Implemented Interfaces:
Cloneable

public class BOOLEAN
extends ASN1Object

This class implements the native ASN.1 type "BOOLEAN". BOOLEAN is a simple non-string ASN.1 type represented by the UNIVERSAL TAG number 1. Possible values are TRUE and FALSE.

For supplying a Java boolean value when creating a new BOOLEAN object, an application shall use the corresponding BOOLEAN(boolean value) constructor, e.g:

 boolean value = true;
 BOOLEAN asn1Boolean = new BOOLEAN(boolean_value);
 
When calling the getValue method for getting the inherent value from an ASN.1 BOOLEAN instance, a Java object of type Boolean is returned:
 Boolean boolValue = (Boolean)asn1Boolean.getValue();
 boolean value = boolValue.booleanValue();
 
DER en/decoding generally is done by means of the several methods of the DerCoder class; decoding alternatively may be performed by using the DerInputStream utility.

Version:
File Revision 18
See Also:
ASN1Object, ASN

Field Summary
static BOOLEAN FALSE
          The BOOLEAN constant FALSE.
static BOOLEAN TRUE
          The BOOLEAN constant TRUE.
 
Fields inherited from class iaik.asn1.ASN1Object
asnType, constructed, encode_listener, indefinite_length, isStringType, stream_mode
 
Constructor Summary
protected BOOLEAN()
          Creates an empty object.
  BOOLEAN(boolean value)
          Creates a new ASN.1 BOOLEAN object for the given Java boolean value.
 
Method Summary
protected  void decode(int length, InputStream is)
          Decodes a BOOLEAN value from the given InputStream.
protected  void encode(OutputStream os)
          DER encodes this BOOLEAN ASN1Object and writes the result to the given output stream.
 Object getValue()
          Returns the value of this BOOLEAN as a Java object of type Boolean.
 void setValue(Object value)
          Sets the value of this BOOLEAN.
 String toString()
          Returns a string that represents the contents of this BOOLEAN ASN.1 object.
 
Methods inherited from class iaik.asn1.ASN1Object
addComponent, addEncodeListener, clone, countComponents, encodeObject, getAsnType, getComponentAt, indefiniteLength, isA, isConstructed, isStringType, setIndefiniteLength
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRUE

public static final BOOLEAN TRUE
The BOOLEAN constant TRUE.

FALSE

public static final BOOLEAN FALSE
The BOOLEAN constant FALSE.
Constructor Detail

BOOLEAN

protected BOOLEAN()
Creates an empty object.

BOOLEAN

public BOOLEAN(boolean value)
Creates a new ASN.1 BOOLEAN object for the given Java boolean value.
Parameters:
value - the boolean value this BOOLEAN object should represent
Method Detail

getValue

public Object getValue()
Returns the value of this BOOLEAN as a Java object of type Boolean.
Overrides:
getValue in class ASN1Object
Returns:
the value of this BOOLEAN as a Boolean object

setValue

public void setValue(Object value)
Sets the value of this BOOLEAN. The supplied value has to be a Java object of type Boolean.
Overrides:
setValue in class ASN1Object
Parameters:
value - the Java Boolean value to be set for this BOOLEAN object

encode

protected void encode(OutputStream os)
               throws IOException
DER encodes this BOOLEAN ASN1Object and writes the result to the given output stream. This is a protected method and will not be used by an application for DER encoding a BOOLEAN object. An application will call one of the encode methods of the DerCoder class for performing the encoding, and the DerCoder internally will call this encode method.
Overrides:
encode in class ASN1Object
Parameters:
os - the output stream to which to write the data
Throws:
IOException - if an I/O error occurs while writing to the stream

decode

protected void decode(int length,
                      InputStream is)
               throws IOException,
                      CodingException
Decodes a BOOLEAN value from the given InputStream. The given input stream carries DER encoded data, and the next length bytes to be read represent the value of an ASN.1 object of type BOOLEAN.

This is a protected method and will not be used by an application for decoding a DER encoded BOOLEAN. An application will call one of the decode methods of the DerCoder class for performing the decoding. The DerCoder then determines the number of bytes (length) occupied by the value of this BOOLEAN object and internally calls this decode method for actually reading the value.

Overrides:
decode in class ASN1Object
Parameters:
length - the already decoded length, i.e. number of the bytes representing the value of the BOOLEAN to be decoded; since a BOOLEAN value only will occupy one byte, length has to be 1
is - the input stream from which the DER encoded data is read in
Throws:
IOException - if there is a problem with the InputStream
CodingException - if some decodeding error occurs, e.g. the supplied length is not equal to 1

toString

public String toString()
Returns a string that represents the contents of this BOOLEAN ASN.1 object.
Overrides:
toString in class ASN1Object
Returns:
the string representation

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK