Populating Generated Variables for Encoding

Populating generated types for encoding can be done in most cases either through the constructors or by assigning object references to public member variables.

Constructors are provided for most generated types to allow direct population of the encapsulated member variable(s) on initialization. The exception to this is for classes generated for SEQUENCE OF types. In that case, the constructors only allow the size of an array to be specified – population of the array elements must be done manually.

All of the base run-time classes except Asn1Null contain public member variables. In practically all cases there is a single variable called mValue that is of the base type that needs to be populated. For example, the Asn1Integer base class contains the following item:

   public long mValue;

So, for the following assignment:

   X ::= INTEGER(0..255)

you may populate a variable of this type either using the constructor:

   X x = new X (25);

or via direct access of the member variable:

   X x = new X ();
   x.mValue = 25;

The only primitive type that does not have a single member called mValue to represent its value is BIT STRING. The Asn1BitString class also contains a second variable called numbits to specify the number of bits in the string.