Runtime tools : Core components : Formatters : Tasks : Handling binary message : Formatting a JavaBean into binary message : Defining a Formatter definition
  
Defining a Formatter definition
The formatter definition is in the same structure of the corresponding JavaBean. Following is the formatter definition:
<format.xml>
  <format id="PersonFormat">
    <record>
      <fString dataName="name" encoding="cp937"/>
      <selfLength/>
      <fInteger dataName="age" byteOrdering="host"/>
      <selfLength/>
    </record>
  </format>
</format.xml>
Where:
The tag <format id="PersonFormat"> is the root element of the formatter. The Java code finds this definition by the value of id, that is PersonFormat.
Tag <record> is a representation of Person in the formatter definition. Data that can hold a set of fields is defined as <record>.
Tag <fString dataName="name" encoding="cp937"/> knows how to parse an array of bytes into a Java String. fString uses cp937 and puts the parsed data into field name of type Person.
Tag <selfLength/> knows how to handle the length indicator in the binary message.
Tag <fInteger dataName="age" byteOrdering="host"/> knows how to parse an array of bytes into an integer. fInteger parses the bytes in big-endian byte ordering, and puts the parsed data into the field age of type Person.
Go up to
Formatting a JavaBean into binary message