IBM WebSphere Multichannel Bank Transformation Toolkit, Version 7.1

Field formatters

Field formatters convert between data field objects and their string representation. FieldFormat is the abstract base class. The following table lists the concrete formatter subclasses:
Table 1. Concrete field formatter classes
Class Purpose
StringFormat Formats a data field as a string and unformats a string into a data field object. StringFormat is the simplest field formatter. You can set attributes so that the formatter returns the string with all upper case letters, all lower case letters, or unchanged.

For example, a StringFormat has the following attributes set:
  • formatAs="uppercase"
  • unformatAs="lowercase"
A data field with a string value of: "This is a string." The format method returns the following string: "THIS IS A STRING."

If you unformat the string, the data field has the following value: this is a string.
IntegerFormat Formats and unformats an integer from one to eight bytes in size. The unformat method updates the data field's value with a:
  • Byte object if the number is one byte in size.
  • Short object if the number is two bytes in size.
  • Integer object if the number is three or four bytes in size.
  • Long object if the number is five to eight bytes insize.
You can set attributes so that the formatter returns the data field with or without sign and in big-endian (host) or little-endian (PC) byte ordering.

For example, a IntegerFormat has the following attributes set:
  • size="4"
  • signRule="yes"
  • byteOrdering="pc"
A data field with an integer value of: -1024

The format method returns the following string: "00 FC FF FF" (hexadecimal values)

If you unformat the string, the data field has the following value: -1024
BinaryIntegerString Format Formats and unformats a string of number characters. When unformatting, this formatter returns the string's binary representation in a chain of bytes.

You can set attributes so that the formatter returns the data field with big-endian (host) or little-endian (PC) byte ordering.

For example, a BinaryIntegerStringFormat has the following attributes set:
  • size="4"
  • signRule="yes"
  • byteOrdering="pc"
  • unformattedSize="8"
A data field with a string value of: "-1024"

The format method returns the following string: "00 FC FF FF" (hexadecimal values)

If you unformat the string, the data field has the following value: "-0001024"
NumericStringFormat Formats and unformats a string of number characters.

You can set attributes so that the formatter returns the data field with or without decimals, with or without a thousands separator, and with or without sign representation. You can also specify the number of decimal places and the characters to use for decimal separation, the thousands separator, and the sign representation.

For example, a NumericStringFormat has the following attributes set:
  • decPlaces="2"
  • decimalSepChar="."
  • thousandsSepChar=","
  • signRule="prefix"
A data field with a string value of: "12345678.9"

The format method returns the following string: "1,234,568.90"

If you unformat the string, the data field has the following value: "12345678.9"
PackedFormat Formats integers or floats into a one byte string representation and unformats a one byte string representation into a two byte integer or float.

You can set an attribute to specify the number of decimal places. For example, a PackedFormat has the following attributes set:
  • decPlaces="2"
A data field with a float value of: -1024.5

The format method returns the following string: "01 02 45 0D" (hexadecimal values)

If you unformat the string, the data field has the following value: -1024.5
PackedDateFormat Formats a Date object into a one byte string representation and unformats a one byte string representation into a two byte Date object. 

For example, a PackedDateFormat formats a data field with a Date object value of: Fri Apr 24 10:00:00 GMT+03:00 1998

The format method returns the following string: "240498" (hexadecimal values)

If you unformat the string, the data field has the following value: Fri Apr 24 10:00:00 GMT+03:00 1998
FloatFormat Formats and unformats a floating point number. The size of its representation is float (4 bytes) or double precision (8 bytes).

You can set attributes so that the formatter returns the data field with big-endian (host) or little-endian (PC) byte ordering.

For example, a FloatFormat has the following attributes set:
  • size="double"
  • byteOrdering="pc"

A data field with a float value of: -1024.5

The format method returns the following string: "00 00 00 00 00 02 90 C0" (hexadecimal values)

If you unformat the string, the data field has the following value: -1024.5
DateFormat Formats or unformats a Date object.

You can set attributes so that the formatter returns the data field with or without a separator, the year with either two or four digits, and a specific day-month-year ordering. You can also specify the separator character.

For example, a DateFormat has the following attributes set:
  • fourDigYear="yes"
  • ordering="mdy"
  • sep="/"
A data field with a Date object value of: Fri Apr 24 10:00:00 GMT+03:00 1998

The format method returns the following string: "04/24/1998"

If you unformat the Date's string representation, the data field has the following value: Fri Apr 24 1998. Note that the string representation of the Date object retains the time information even though the string returned by format does not.
TimeFormat Formats or unformats a time in the Date object.

You can set attributes so the formatter returns the data field with or without a separator, return the time in 12 or 24 hour format, and return the time with or without seconds. You can also specify the separator character and the strings to represent AM and PM.

For example, a DateFormat has the following attributes set:
  • hrs="12"
  • amString="a.m."
  • pmString="p.m."
  • useSep="yes"
  • sep=":"
A data field with a Date object value of: Fri Apr 24 10:00:00 GMT+03:00 1998

The format method returns the following string: "06:05:00 p.m."

If you unformat the Date's string representation, the data field has the following value: Fri Apr 24 10:00:00 GMT+03:00 1998 Note that the string representation of the Date object retains the date information even though the string returned by format does not.

These formatter classes may apply decorators to the formatted strings.



Feedback