Runtime components : Core components : Formatters : Tasks : Handling binary message : Formatting a JavaBean into binary message : Formatting a Java Object into binary message
  
Formatting a Java Object into binary message
This section describes how to convert an instance of Person into binary message. Following is the sample code:
public static void main(String[] args) throws Exception {
InitManager.reset("jar:///format/config/abc.xml");
//Prepare person populate data into its fields
Person person = new Person();
person.setName("George. Wilhelm. T");
person.setAge(57);
//Get the defined format element by id "PersonFormat"
FormatElement format = FormatFactory.getFormatElement("PersonFormat");
//Create a ReadAdapter for person
ReadAdapter read = new JavaReadAdapter(person);
//Perform unformat action
Message msg = format.format(read);

System.out.println("====Format Result====");
System.out.println(msg);
}
If you run this main method, you can get the following result in the console:
Read BTT configuration from : "jar:///btt.xml"
Initialize BTT Component: traces
Initialize BTT Component: traces [Success]
Initialize BTT Component: format
Initialize BTT Component: format [Success]
2 BTT Components initialized.
====Format Result====
12C785969987854B40E68993888593944B40E30400000039
In 12C785969987854B40E68993888593944B40E30400000039, 12 indicates that the following 18 bytes is a field for George. Wilhelm. T.
Go up to
Formatting a JavaBean into binary message