Populating Generated Choice Structures for Encoding

The only way a CHOICE construct can be populated for encoding is by using one the generated Set_<element> methods. It is necessary to do it this way because the base class contains two protected member variables (choiceID and element) that must be set consistently. This is the only instance of a mapped type where the mapped element values do not have public access.

The following demonstrates setting a variable of the TestChoice structure defined above to use the first option:

   TestChoice testChoice = new TestChoice ();
   testChoice.Set_a (new Asn1Integer (222));