provided by: 
Originally published at Internet.comIntroduction
In Part 1 of our tutorial, we began discussing how legacy systems usually expect messages in a rigid format, such as EBCDIC (Extended Binary Coded Decimal Interchange Code), and how such messages can be built in Java. Here in Part 2, we'll continue this discussion, with more detail on the BuildMsg.processRequest() and BuildMsg.getMsg() methods, and generating an EBCDIC byte stream using "cp500" encoding.
BuildMsg Class
The BuildMsg class has two critical methods namely processRequest() and getMsg(). The processRequest method constructs the message. The getMsg method returns the message as an EBCDIC byte array.
BuildMsg.processRequest() method
The processRequest method accepts a parameter of the type InputData and uses it to construct the message. The testMsg StringBuffer will hold the message that is built. The set methods for each data item return a string that is appended to the testMsg StringBuffer.
The set methods for each data item (like setDi1 ) will take care of the details of setting up that particular data item. They will also set a flag to indicate whether the data item exists. These flags are used by the method inpDiDefine.setPBitmapFromFlags() to set the bitmap. The bitmap for the message is built dynamically for every message based on the flags...
Read article at Internet.com site