Real Time Information Director User Documentation
RTID Metadata Language
Hewlett-Packard Company 44 529618-002
Formatter Classes
Formatter classes convert data from the IDoc document format (or a custom format) to
the format required by the data store, or vice versa. For example, certain IDoc elements
are stored in the data store using numeric types but are expressed in the IDoc with a fixed
number of positions, using leading zeros.
A formatter’s unformat operation converts the data, as it appears in the inbound
message, to the format required by the data store. For example, the unformat operation of
the LeadingZeros formatter removes leading zeros from an inbound message.
A formatter’s format operation converts the data, as it appears in the data store, to the
format expected in the outbound message. For example, the format operation of the
LeadingZeros formatter pads the string with leading zeros.
In general, each formatter supports conversion in both directions. However, you may
define a formatter that converts data in only one direction.
Specifying Formatters in Your Metadata
You can pass a Formatter object as an optional parameter to any FieldElement or subclass
of FieldElement. That is to say, each subclass of FieldElement has an overloaded
constructor that takes a Formatter as the final parameter.
Formatters that perform specific types of conversions are all subclasses of a class named
Formatter. LeadingZeros(int size) is one example.
Various commonly used formatters are statically constructed in the IDoc class, but you
can also pass references to formatters constructed elsewhere or to a new formatter
constructed in-line.
Examples:
The following metadata excerpt makes extensive use of formatters. (Most documents
require few, if any formatters.) The example comes from the LOIPRO01 IDoc, which
represents production orders. The FREIZ field element is always three digits long and
often requires leading zeros. The LeadingZeros formatter is constructed in-line using the
new statement.
Many other elements are date or time items that also require formatters. Those
formatters, DASHED_DATE and TIME, are constructed in the IDoc class.
new FieldElement("FREIZ", "REL_PERIOD_IN_DA", new LeadingZeros(3)),
new FieldElement("FTRMI", "ACTUAL_RELEASE_DT", IDOC.DASHED_DATE),
new FieldElement("FTRMS", "SCHEDULED_RELEASE_DT", IDOC.DASHED_DATE),
new FieldElement("GAMNG", "TOTAL_ORDER_QT"),
new FieldElement("GETRI", "CONFIRMED_ORDER_FINISH_DT", IDOC.DASHED_DATE),
new FieldElement("GEUZI", "CONFIRMED_ORDER_FINISH_TM", IDOC.TIME),