Populating generated variables for encoding can be done in most cases either through the object constructors or directly by assigning an object reference to a public member variable.
Constructors are provided for most generated types to allow direct population of the encapsulated member variable(s) on initialization. The exception is the classes generated for SEQUENCE OF or SET OF. These 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;
Therefore, population of any class variable derived from INTEGER can be done by adding.mValue to the end of the lefthand side of the assignment and an integer value on the right. So for the following assignment:
X ::= INTEGER
A variable of the type can either be populated using the constructor with the following statement:
X x = new X (25);
or via direct access of the member variable as follows:
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. In this case, the Asn1BitString class contains a second variable called numbits to specify the number of bits in the string.