The ASN.1 BIT STRING type is converted to a Java class that extends the Asn1BitString run-time class. This base class encapsulates the following two public member variables:
public int numbits; public byte[] value;
These describe the bit string to be encoded or decoded.
The following shows the basic mapping from ASN.1 type to Java class definition:
ASN.1 Production
<name> ::= BIT STRING
Generated Java class:
public class <name> extends Asn1BitString { public <name> () { super(); } public <name> (int numbits_, byte[] data) { super (numbits_, data); } public <name> (boolean[] bitValues) { super (bitValues); } public <name> (String value_) throws Asn1ValueParseException { super (value_); } }
This shows the class generated for a simple BIT STRING assignment. If a tagged or constrained type is specified, specific encode and decode methods will be generated as well.
The constructors generated for this type provide additional options for populating the member variables in the base class. In addition to passing the string using the numbits and data arguments to specify a bit string in native format, the string can be specified as an array of boolean values or as a string. The string form expects the string to be passed in the ASN.1 value notation format for either a binary string (i.e., 'xxxx'B) or a hexadecimal string (i.e., 'xxxx'H).