Following additional code is generated for type definition when the -tables command line option is used. The code generated to support table constraints is intended for use only in compiler-generated code. Therefore, it is not necessary for the average user to understand the mappings in order to use the product. The information presented here is informative only to provide a better understanding of how the compiler handles table constraints.
Additional equals() method will be generated for Sequence, Set, Sequence Of, Set Of or Choice types if required for table constraint processing. This method will be an implementation of Asn1Type.equals() virtual method. These methods are used by the generated code to verify that data in a generated structure to be encoded (or data that has just been decoded) matches the table constraint values.
An additional table constraint check method is also generated for each type that contains table constraints. These functions have the following prototypes:
BER/DER:
void checkTC (boolean decode);
PER:
void checkTC (boolean decode, boolean aligned);
The decode argument is used to decide if this method is to used for encoding or decoding. The aligned argument is for PER and specified whether aligned or unaligned encoding/decoding is in effect.
The purpose of these methods is to verify that the fixed values within the table constraints are what they should be and to encode or decode the open type fields using the encoder or decoder methods from the Asn1Type objects assigned to the given table row. Calls to these functions are automatically built into the standard encode or decode functions for the given type. They should be considered hidden functions not for use within an application that uses the API.
The checkTC method will have different logic for relative and simple table constraints. The logic to invoke this method is as follows:
On the encode side:
Relative Table Constraint:
The table constraint key is searched in the object set array to find the class object for the data in the populated type variable to be encoded.
If the key element value is NOT found and the table constraint object set is extensible, the checkTC method will do no further processing (i.e. a value field match will not be performed). The user will have had to populate the type field using an Asn1OpenType object in order for it to be decoded because the generated table contains no information on how to encode the value.
If the key element value is found, the method will verify all fixed type values match what is defined in the key row of the object set and will also verify that the type of any variable type fields matches the expected type.
If the key element value is not found in the table (or object set) and the objectset is NOT extensible, then a table constraint violation exception will be thrown.
Simple Table Constraint:
The checkTC method will verify that all of the fixed type values match what is defined in the table constraint object set. If the element value does not exist in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.
After the checkTC method call, the normal encode logic is performed.
For decoding, the logic is reversed:
The normal decode logic is performed first to populate the standard and open type fields in the generated structure. After that, the checkTC method is invoked to perform following table constraint checks:
Relative Table Constraint:
The table constraint key is searched in the object set array to find the class object for the data in the populated type variable to be encoded.
If the key element value is NOT found and the table constraint object set is extensible, the checkTC method will do no further processing (i.e. a value field match will not be performed) and the variable type fields will be stored as open types (i.e. as instances of Java Asn1OpenType classes). The user will be responsible for further decoding of the open type value.
If the key element value is found, the checkTC method will verify all fixed type values match what is defined in the key row of the object set and will fully decode all type fields according to the key row type and store the resulting decoded type in the ASN1Type fields.
If the key element value is NOT found in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.
Simple Table Constraint:
This function will verify all the fixed type values match what is defined in the table constraint object set. If an element value does not exist in the table (or object set) and the object set is NOT extensible, then a table constraint violation exception will be thrown.