Table of contents

 

This operator specifies the number of chars to remove and chars to append to the previous value. That is, the output value is obtained by combining the previous value - 'n' chars (where 'n' is an int from the input message) + decoded field value from input encoded message (the tail value).
For this operator, the tail value is optional.
This operator can be applied to data type string and byte vector, both defined later.

This diagram shows the tail operator's decoding algorithm:

Decoding algorithm of fields with Tail Operator

Picture 3.14 - "Decoding algorithm of fields with Tail Operator"

An implementation of this algorithm:

public int decode(byte[] encodedData, int offset, PresenceMap presenceMap, OutputMessage message) {
    if (presenceMap.isNextPMapBitSet()) {
        offset = dataTypeDecoder.decode(encodedData, offset, templateField);
        Object decodedValue = getFieldValue();
        if (decodedValue != null) {
            if (getPreviousValue() == null) {
                Object prevValue = getInitialValue();
                if (prevValue == null) {
                    prevValue = getFieldBaseValue();
                }
                setPreviousValue(prevValue);
            }
            calculateCombineValue();
            decodedValue = getFieldValue();
            message.addValue(tagId, decodedValue);
            setPreviousValue(decodedValue);
        } else {
            if (isMandatory) {
    			logger.logError("Mandatory field decoded value can not be NULL");
            } else {
                setPreviousValue(null);
            }
        }
    } else {
        Object prevValue = getPreviousValue();
        if (prevValue != null) {
            message.addValue(tagId, prevValue);
        } else {
            if (isMandatory) {
                logger.logError("Mandatory field decoded value can not be NULL");
            }
        }
    }
    return offset; 
}   
 
public void reset() {
    // The field delivers previous value from the undefinite status
    setPreviousValue(getInitialValue()); 
}
 
public boolean isPMapBitExist() {
    // Tail fields require presence map bit
    return true; 
}
 
public boolean isFieldNullable() {
    // If isMandatory false the Delta field could has the null representation
    //of field value and does not apear in the output fix message
    return !isMandatory;
}