Table of contents

 

The delta operator combines the incoming value in the encoded message with the previous value. So if the last decoded value came to 150 (for an integer field) and the incoming value within the encoded message is -5, then the output value is 145.
The diagram below illustrates this operator's algorithm.

Decoding algorithm of fields with Delta Operator

Picture 3.12 - "Decoding algorithm of fields with Delta Operator"

Code example of this algorithm:

public int decode(byte[]encodedData, int offset, PresenceMap presenceMap, OutputMessage message) {
    offset = dataTypeDecoder.decode(encodedData, offset, templateField);
    if (getFieldValue() != null) {
        if (getPreviousValue() != null) {
            calculateDeltaFieldValue();
            Object fieldValue = getFieldValue();
            message.addValue(tagId, fieldValue);
            setPreviousValue(fieldValue);
        } else {
            throw new RuntimeException("Mandatory decoded field can not be NULL");
        }
    } else {
        if (isMandatory) {
            throw new RuntimeException("Mandatory field decoded value can not be NULL");
        }
    }
    return offset;
}
 
public void reset() { 
    // This functionality delivers previous value from the undefinite status      
    Object prevValue = getInitialValue();     
    if (prevValue == null) {         
        prevValue = getFieldBaseValue();
    }     
    setPreviousValue(prevValue); 
}  
 
public boolean isPMapBitExist() {     
    // Delta fields not require presence map bit.      
    //In any casy it should be in encoded message     
    return false; 
}  
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; 
}