As with the data elements, you may need to create new formatters. In
this step, you look at the operation flows and the data elements,
and determine whether any new formatters are required for sending
data to the host. Also in this step, you create a set of record formatters
for exchanging information between the client and the server.
For the Base Sample Application, in addition to the new data element
you defined before, you will also need to define a new format or decorator to send data to the host. When it is creating the send format for an operation that sends
a string (HostBuff) to the host buffer (the buffer from which the
host will read), the format must append the field value to the field identifier
to create the output string that is placed in the host buffer. Since no existing format does this, you can do the following:
- Create a new data format
- Create a new decorator
You can use only the first option when all the data fields that
belong to the data entities to be formatted are of the same type. For instance, if all the data fields that had to be formatted into the host buffer were strings, you could build a new class derived from StringFormat, and override
the format method to add the field identifier before the field value.
This approach is not appropriate for the Base Sample Application,
because all the data entities to be sent to the host, including those of the HostField type, have elements of different types. For example, the Date data field contains a Date object.
You will need to create both a new data format (to format the strings) and
a new decorator (to format the other types). The Base Sample Application
uses the following format and decorator when formatting the data to
be sent to the host:
- fHostString: This class extends StringFormat. It works
with HostField instances of type String. In the formatting process, it adds the contents of the hostIdentifier
attribute of the HostField instance plus the equals sign to the string
value of the instance. The unformat process does the opposite. The decorator implemented
in the fHostDecorator class does the same for any type of data, not
just for strings.
- fHostDecorator: This class extends FormatDecorator. It
adds and removes a decorator, which is the contents of the hostIdentifier
attribute of the HostField instance plus the equals sign.
Next, you must create the list of record formatters required for
exchanging information between the client and the server. As mentioned in the step where you identified operation flows,
each client operation must define a format to transfer data to the
server operation, and each server operation must define a format to
transfer data back to the client operation. These formatters use Req and Rep to designate whether the format for the client/server
operation is a request or a reply.
The following records formatters are used in the Base Sample Application
(the names used in the implementation are shown in parentheses):
- Startup Request (startupReqFmt)
- Customer Search Request (customerSearchReqFmt)
- Customer Search Reply (customerSearchRepFmt)
- Withdrawal Request (withdrawalReqFmt)
- Withdrawal Reply (withdrawalRepFmt)
- Deposit Request (depositReqFmt)
- Deposit Reply (depositRepFmt)
- Account Statement Request (accountStatementReqFmt)
- Account Statement Reply (accountStatementRepFmt)
On the server side, you must define, for each operation, the specific
record formatters for accessing the host.
The following are used in the Base Sample Application (they are
identified by adding Send (send) or Rec (receive) to the host communication formatters):
- Customer Search Send (customerSearchSendFmt)
- Customer Search Receive (customerSearchRecFmt)
- Withdrawal Send (withdrawalSendFmt)
- Withdrawal Receive (withdrawalRecFmt)
- Deposit Send (depositSendFmt)
- Deposit Receive (depositRecFmt)
- Account Statement Send (accountStatementSendFmt)
- Account Statement Receive (accountStatementRecFmt)
You must also define a format for writing to the Electronic Journal
before sending a transaction to the host, and another for writing
to the Electronic Journal after receiving a reply from the host. The Base Sample Application uses the following Hashtable formatters that come with the toolkit:
- Send Journal (preSendJournalFmt)
- Receive Journal (afterRecJournalFmt)
For all formatters, you must create a detailed definition of
the complete record that refers to each data element and its specific field format, delimiters,
and decorators.
This is how the definition of the Send format for the Customer
Search operation looks in the generated XML file.
The following table shows the complete list of data fields and formatters required for the Base
Sample Application:
Table 1. Required data fields and formattersData fields |
Data type in the client |
Data type in the server |
Format C/S req/rep |
Format host send/rec |
Format journal |
Date |
DataField |
HostField |
fDate |
fDate+fHostDecor |
|
AccountNumber |
DataField |
HostField |
fString |
fHostString |
|
AccountBalance |
DataField |
DataField |
fString |
fString |
|
MaxAmount |
DataField |
DataField |
fFloat |
fFloat |
|
CustomerId |
DataField |
HostField |
fString |
fHostString |
|
CustomerName |
DataField |
DataField |
fString |
fString |
|
TrxId |
Constant |
Constant |
Constant |
Constant |
|
Amount |
DataField |
HostField |
fFloat |
fFloat+fHostDecor |
|
BranchId |
DataField |
HostField |
fString |
B |
|
AccountList |
iColl |
iColl |
iColl |
iColl |
|
Account |
kColl |
kColl |
kColl |
kColl |
|
AccountNumber |
DataField |
DataField |
fString |
fString |
|
Type |
DataField |
DataField |
fString |
fString |
|
Name |
DataField |
DataField |
fString |
fString |
|
Balance |
DataField |
DataField |
fString |
fString |
|
accountStatement Details |
iColl |
iColl |
iColl |
iColl |
|
OpnDate |
DataField |
DataField |
fString |
fString |
|
OpnDescription |
DataField |
DataField |
fString |
fString |
|
OpnAmount |
DataField |
DataField |
fString |
fString |
|
OpnBalance |
DataField |
DataField |
fString |
fString |
|
TID |
DataField |
DataField |
|
fString |
fObject |
UserId |
DataField |
DataField |
|
fString |
fObject |
TrxReplyCode |
DataField |
DataField |
fString |
fString |
fObject |
TrxErrorMessage |
DataField |
DataField |
fString |
fString |
fObject |
HostBuff |
DataField |
DataField |
|
fString |
fObject |