CHOICE
The ASN.1 CHOICE type is converted to a Java class that extends the Asn1Choice run-time base class. This base class contains protected member variables to hold the choice element object and a selector value to specify which item in the CHOICE was chosen. Methods are generated to get and set the base class members.
The compiler generates sequential identification constants for each of the defined elements in the CHOICE construct. The format used is the element names converted to all uppercase characters and preceded by an underscore. The constants represent the values returned by the base class getChoiceID method can therefore be used to determine what type of choice element was received in a decode operation.
A series of set_<element> methods are generated for setting the element value. In these declarations, <element> would be replaced with the actual element names. This is the only way an element value can be set for encoding; these methods ensure a consistent setting of both the element identifier and object reference values.
To access the value of a generated CHOICE object, the getChoiceID and getElement methods within the base class are used. This is generally done with an if or switch statement as follows:
Asn1BMPString element; if (aliasAddress.getChoiceID() == AliasAddress._H323_ID) { element = (Asn1BMPString) aliasAddress.getElement(); }
Objective Systems, Inc.102 Pickering Way, Suite #506Exton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |