Real Time Information Director User Documentation
RTID Extensibility
Hewlett-Packard Company 12 529618 - 001
Converting Data Representations
Sometimes a data element is represented in one way in an IDoc and in another way in the
data store. Examples are numeric values with leading zeros, and date or date-time fields
that are formatted differently from the corresponding SQL date or SQL date-time fields.
In order for the Director to generate outbound documents from the database with the
same format as the inbound documents, you must specify Formatter metadata objects.
Usually you will see the any differences in data representation when you compare
inbound IDocs with outbound IDocs generated by the Dispatcj or Reselect standalone
program. The Reselect program is particularly useful for this kind of test, because it
inserts a document into database, then selects the same document from the database.
When you compare the two documents, you can see where the differences are and what
kind of formatters you need to add. See “Testing the Metadata” for information about the
standalone programs.
Another reason to use formatters is to remove extraneous characters from the input data
before storing the data in the data store. For example, if a database column is defined as
numeric, and the input values contain blank spaces (i.e. 123 9999), you can use the
predefined IDOC.STRIP_BLANKS formatter to remove the blank spaces.
Yet another reason is that you might not always want to insert the entire string in an input
data item. If you wanted to insert only the first ten characters in a string, for example,
you could use the SubString formatter to prescribe that behavior.
Using Formatter Classes
Follow these steps to add formatters to the metadata:
1. Identify the mapping for the XML element that differs in inbound and outbound
documents .
2. Identify an existing formatter in the starting metadata. For example, the
predefined formatter ITEM_NO is defined in IDOC class as:
Formatter ITEM_NO = new LeadingZeros(6);
Other predefined formatters are distinct classes. For example, the
SubStringFormatter class is defined as follows:
public class SubStringFormatter implements Formatter
{
private String separator;
private int size;
public SubStringFormatter(String separator)
{
this.separator = separator;
this.size = 0;
}