Designing Custom Encoders

Matching Data Patterns

One of the parsing techniques that can be applied to the decoding of an input data stream is that of matching a specific byte pattern within a data sequence. You can accomplish this in a Custom Encoder by using the Match and Align field-node properties, when the Node Type is either delimited or fixedLength. During the decode operation, a field is successfully matched if it complies with the value of the Match property, interpreted according to the value of the Align property, as set for that field.

Defining Byte Patterns

The value you enter for the Match property defines the byte pattern for the data you want to match. As an example, a value of abc has been entered into the value field shown in the following figure. This provides a reference for the Alignment property, as shown in the next section.

If the Node Type property is set to fixedLength, and the Fixed Length Type property is specified as determined by regex match, the Alignment property is automatically set to regex and the regular expression (regex) must be entered into the Match value field.

Selecting the No Match check box reverses the situation, resulting in a match if the field contents (data) are not equal to the byte pattern entered in the Match field.

Figure 4 Match Property

Figure described in content.

Specifying Pattern Alignment

The align property supplements the match property, specifying criteria on which to base the match. The default value is blind; if this is specified, the match property has no meaning.

Figure 5 Align Property Menu

Figure described in content.

Table 7 Align Parameter Options

Option 

Description 

blind 

Always performs a match (pass-through). Any value set for the Match property is ignored. This is the default value.

exact 

When an input byte sequence exactly matches the specified byte pattern (for example, [abc]), the decode method matches the field to the input byte sequence.

begin 

When the leading bytes of an input byte sequence match the value set for the Match property (for example, [abc......]), the decode method matches the field to the input byte sequence.

final 

When the trailing bytes of an input byte sequence match the value set for the Match property (for example, [......abc]), the decode method matches the field to the input byte sequence.

inter 

When the input byte sequence contains a byte pattern that includes the value set for the Match property, (for example, [...abc...]), the decode method matches the field to the input byte sequence.

super 

When an input byte sequence is a subsequence of the value set for the Match property (for example, [bc]), the decode method matches the field to the input byte sequence.

oneof 

If the value set for the Match property is a repeating pattern of the form <separator><value>... (for example, [\mon\wed\fri]), and the input byte sequence contains a byte pattern that matches one of the <value> entries (for example, [wed]), the decode method matches the field to the input byte sequence.

regex 

When an input byte sequence exactly matches the regular expression specified in the Match property, the decode method matches the field to the input byte sequence. The Alignment property is automatically set to regex when the Fixed Length Type property is specified as determined by regex match.


Note –

The value entered for the match property is interpreted as a Latin1 string, rather than following the specified encoding.