Table of contents

 

In a FAST message template, template units (that is, fields or sequences) can have an optional attribute. If set, the field or sequence is optional, otherwise mandatory.
This attribute has the following implications:

  • If a template unit is mandatory, it must be present in the resulting decoded message (output stream).
  • If a field is optional, it is possible for the field to not appear in the final decoded message (a special encoded NULL representation translates to no-value in the decoded message).

Mandatory fields are required in the decoded message. The following code example shows how you can test this constraint as you iterate over each template field.

offset = dataTypeDecoder.decode(encodedData, offset, templateField);
Object decodedValue = getFieldValue();
if (decodedValue == null) {
    if (isMandatory) {
        throw new RuntimeException(Mandatory field decoded value can not be NULL);
    } else {
        // do nothing
    }
    ...
} 
...