Configuring

The SBE decoder can be configured to address various aspects of its functionality. Settings are passed through the DecoderSettings class object.

Custom composite classes

Handling of custom composites requires using of user-defined Java classes. These classes can be passed via ByteDecoderFactory methods, or using the settings.

Value narrowing

Value narrowing is a conversion from wide integer number to the narrrow number or between signed and unsigned values. For instance, from 4-byte integer to 2-byte integer, or between long and unsigned long, etc. This conversion appears during read or write operation.

Write narrowing

Please follow the Value Narrowing for details.

NarrowingOnWrite: DecoderSettings.setEnableNarrowingOnWrite and DecoderSettings.enableNarrowingOnWrite.

This option enables or disables write narrowing itself. Default value is false.

ValidateNarrowingOnWrite: DecoderSettings.setValidateNarrowingOnWrite and DecoderSettings.validateNarrowingOnWrite.

This option additionally enables or disables validating of the narrowing operation. Default value is false.

Read narrowing

Please follow the Value Narrowing for details.

NarrowingOnRead: DecoderSettings.setEnableNarrowingOnRead and DecoderSettings.enableNarrowingOnRead.

This option enables or disables read narrowing itself. Default value is false.

ValidateNarrowingOnRead: DecoderSettings.setValidateNarrowingOnRead and DecoderSettings.validateNarrowingOnRead.

This option additionally enables or disables validating of the narrowing operation. Default value is false.

Null data return

NullDataReturn: DecoderSettings.setEnableNullDataReturn and DecoderSettings.enableNullDataReturn.

This option controls ability to return null by field getters.

By default, all getters (IFieldSet.getShort, IFieldSet.getString, etc) returns null when the SBE value means empty data.

This behavior can be changed using the option. When the option is true getters throw exception if the SBE value is an empty value.

Range checking

ValidateValueRanges: DecoderSettings.setValidateValueRanges and DecoderSettings.validateValueRanges.

This parameter controls the operation of checking whether a value is within its range. The range can be specified in the SBE template using the minValue and maxValue attributes (both are optional).

If this option is true:

  • The input value is checked during writing (field setters);
  • Data coming from the wire level is checked during reading (field getters).

If the value is out of the range, an exception is thrown.

Default value is false.

Custom class loader

ParentLoader: DecoderSettings.setParentLoader and DecoderSettings.getParentLoader.

This parameters allows to specify class loader that will be used as parent class loader for generated classes. Default value is null that means system class loader.

Default configurations

Two default presets are avaialable.

Default configuration. This preset is compatible with older version of the SBE decoder. The DecoderSettings gets it by default.

Full control configuration. This set of settings provides configuration to implement full control of written and read values. This preset can be obtained by the DecoderSettings.createFullControlSettings call.

The table below describes differences between these sets of settings.

Settings name Default configuration Full control
validateValueRanges false true
enableNullDataReturn true false
enableNarrowingOnWrite false true
validateNarrowingOnWrite false true
enableNarrowingOnRead false true
validateNarrowingOnRead false true