Runtime components : Core components : Formatters : Tasks : Handling binary message : Formatting a JavaBean into binary message : Unformating binary message
  
Unformating binary message
Following is the sample code for how to unformatting binary message into the JavaBean Person.
public static void main(String[] args) throws Exception {
//Read btt.xml from the default package in class-path
InitManager.reset("jar:///btt.xml");
//Create a instance of Person, left the field data blank
Person person = new Person();
//Get the defined format element by id "PersonFormat"
FormatElement format = FormatFactory.getFormatElement("PersonFormat");
//Create a WriteAdapter for person
WriteAdapter write = new JavaWriteAdapter(person);
//Prepare binary message
byte[] bytes = HexCodecUtil.decodeHex("06C785969987850400000012".toCharArray());
Message message = new Message(bytes);
//Perform unformat procedure
format.unformat(message, write);

System.out.println("====Unformat Result====");
System.out.println("name:" + person.getName());
System.out.println("age :" + person.getAge());
}
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.
====Unformat Result====
name:George
age :18
Go up to
Formatting a JavaBean into binary message