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));