@@ -55,10 +55,15 @@ public static void main(final String[] args) throws Exception
5555 encodedSchemaBuffer .flip ();
5656 final IntermediateRepresentation ir = decodeIr (encodedSchemaBuffer );
5757
58+ // From the IR we can create OTF decoders for messages.
59+ final OtfHeaderDecoder headerDecoder = new OtfHeaderDecoder (ir .headerStructure ());
60+ final OtfMessageDecoder messageDecoder
61+ = new OtfMessageDecoder (new OtfGroupSizeDecoder (ir .getType (OtfGroupSizeDecoder .GROUP_SIZE_ENCODING_NAME )),
62+ new OtfVarDataDecoder (ir .getType (OtfVarDataDecoder .VAR_DATA_ENCODING_NAME )));
63+
5864 // Now we have IR we can read the message header
5965 int bufferOffset = 0 ;
6066 final DirectBuffer buffer = new DirectBuffer (encodedMsgBuffer );
61- final OtfHeaderDecoder headerDecoder = new OtfHeaderDecoder (ir .headerStructure ());
6267
6368 final int templateId = headerDecoder .getTemplateId (buffer , bufferOffset );
6469 final int actingVersion = headerDecoder .getTemplateVersion (buffer , bufferOffset );
@@ -68,11 +73,9 @@ public static void main(final String[] args) throws Exception
6873
6974 // Given the header information we can select the appropriate message template to do the decode.
7075 // The OTF Java classes are thread safe so the same instances can be reused across multiple threads.
71- final OtfGroupSizeDecoder groupSizeDecoder = new OtfGroupSizeDecoder (ir .getType (OtfGroupSizeDecoder .GROUP_SIZE_ENCODING_NAME ));
72- final OtfVarDataDecoder varDataDecoder = new OtfVarDataDecoder (ir .getType (OtfVarDataDecoder .VAR_DATA_ENCODING_NAME ));
76+
7377 final List <Token > msgTokens = ir .getMessage (templateId );
7478
75- final OtfMessageDecoder messageDecoder = new OtfMessageDecoder (groupSizeDecoder , varDataDecoder );
7679 bufferOffset = messageDecoder .decode (buffer ,
7780 bufferOffset ,
7881 actingVersion ,
0 commit comments