Using FormatFacade

Although the other BTT components are bound tightly with the formatter components in previous releases of BTT, you can use the new formatter component directly.
Following is an example of how to use FormatFacade in other BTT components:
public class FormatFacade {
	  public static byte[] formatContext(String formatID, Context ctx)
		     	 throws FormatterException {
		    ReadAdapter adapter = new ContextReadAdapter(ctx);
		    FormatElement format = FormatFactory.getFormatElement(formatID);
	      Message message = format.format(adapter);
		    return message.toBytes();
	}
	  public static void unformatContext(String formatID, byte[] data,
			     Context ctx) throws FormatterException {
		    WriteAdapter adapter = new ContextWriteAdapter(ctx);
		    FormatElement format = FormatFactory.getFormatElement(formatID);
		    format.unformat(new Message(data), adapter);
	}
}