Table of contents

 

According to the FAST specification, the template defines the following internal entities:

  • Template Field
  • Template Sequence

Each is represented by TemplateUnit in the following java interface:

public interface TemplateUnit {
 
    public int decode(byte[] encodedData, int offset, 
                      PresenceMap presenceMap, OutputMessage message);
 
    public void reset();
}

The purpose of the reset() method is to return Template Unit object to the initial (pre-decoding) state.

The Message Template itself consists of set of fields is also represented by TemplateUnit.

public class MessageTemplate implements TemplateUnit {
    private TemplateUnit[] templateFields;
    public int decode(byte[] encodedData, int offset, 
                      PresenceMap presenceMap, OutputMessage message) {
        for (TemplateUnit templateField : templateFields) {
            offset = templateField.decode(buffer, offset, presenceMap, message);
        }
        return 0;
    }
 
    public void reset() {
        for (TemplateUnit templateField : templateFields) {
            templateField.reset();
        }
    }
}

 Before we continue, there are several FAST message template concepts to introduce: