IBM WebSphere Multichannel Bank Transformation Toolkit, Version 7.1

Decorators

A decorator modifies a formatted string to make it readable by other applications, services, or formatter without requiring a modification to the formatter that formats or unformats the string. Examples of these modifications include adding a delimiter character, compressing the string, or adding an identifier. Each type of decorator performs a different modification. The following table lists the decorators provided by the toolkit and what each one does: 
Table 1. Concrete decorator classes
Class Purpose
CodeSetTranslator Modifies the strings using the specified code page.

For example, a CodeSetTranslater decorator has the following attributes set:
  • to="Cp037"
A data field with a string value of: "12345"

The decorated string is: "F1 F2 F3 F4 F5"

The undecorated string is "12345"
Delimiter Appends a delimiter character after a formatted string.

For example, a Delimiter decorator has the following attributes set:
  • delimChar="@"
A data field with a string value of: "this is a string"

The decorated string is: "this is a string@"

The undecorated string is "this is a string"
FixedLength Adjusts a formatted string to a fixed length by either truncating it or by padding and justifying it.

For example, a FixedLength decorator has the following attributes set:
  • length="20"
  • justify="left"
  • padChar="#"
A data field with a string value of: "this is a string"

The decorated string is: "this is a string####"

The undecorated string is "this is a string"
MaximumLength Truncates the string if it is over the specified length. If the string is under the specified length, the decorator does not modify it.

For example, a MaximumLength decorator has the following attributes set:
  • length="12"
  • justify="left"
  • padChar="#"
A data field with a string value of: "this is a string"

The decorated string is: "this is a st"

The undecorated string is "this is a st"
Identifier Prefixes or appends one character to the formatted string. For example, an Identifier decorator has the following attributes set:
  • idChar="#"
A data field with a string value of: "this is a string"

The decorated string is: "#this is a string"

The undecorated string is "this is a string"
SelfLength Prefixes the length (as an unsigned integer or as a string) of the formatted string. Instance variables specify the size of the integer, its byte ordering, and whether it counts itself when calculating the length.

For example, a SelfLength decorator has the following attributes set:
  • size="2"
  • byteOrdering="host"
  • lengthIncluded="yes"
A data field with a string value of: "this is a string"

The decorated string is: "00 12 74 68 69 73 ... " (hexadecimal values up to 18 bytes)

The undecorated string is "this is a string"
CheckNullDecorator Handles conversions between strings and data elements when either the string is an empty string or the data element has a null value. Because it does not throw an exception, apply this formatter on data elements and strings when you do not know whether they will be empty or not.

For example, when the CheckNullDecorator unformats an empty string, the value, it returns is null.  When the CheckNullDecorator formats a data field with a null value, the CheckNullDecorator returns an empty string. If the string is a non-empty string or the data element has a value, the CheckNullDecorator does nothing. Typically, another formatter or decorator in the conversion process performs the conversion of non-empty strings and data elements that have a value. If this decorator is being applied in conjunction with other formatters, this decorator must be the first formatter applied.
Compress Compresses and decompresses the data field contents by using the Deflater and Inflater classes in the java.util.zip package.

Each decorator has its own set of instance variables to control how it modifies the formatted strings.  The formatted strings are modified by the addDecoration() and removeDecoration() methods.



Feedback