Public Member Variables

The next section of the file would be public member variables. In our example above, no member variables are present. This is because INTEGER is a primitive type, so the member variable in which the integer value is stored can be found in the Asn1Integer base class from which this class is derived. This is true for all primitive types – the value will be contained within the run-time base class.

Constructed types will contain public member variables to represent the elements that make up the type. For example, the following SEQUENCE production:

   Name ::= [APPLICATION 1] IMPLICIT SEQUENCE {
      givenNameIA5String,
      initial IA5String,
      familyNameIA5String
   }

will result in the following public member variables being added to the generated class:

   public Asn1IA5String givenName;
   public Asn1IA5String initial;
   public Asn1IA5String familyName;

Note that the member variables are public. They were declared this way to make access easier. A trade-off existed between ease-of-use and secure encapsulation. The ease-of-use approach was chosen because it was felt that the repeated use of get/set methods within deeply nested structures would be too clumsy and bulky in most applications. Therefore, the variables were made public to make the encapsulated values easier to set and retrieve. Consistency checks have been added in some methods to make sure values of the correct types are specified for these elements. These checks are discussed in the sections on the specific constructed types.