<kColl id="format"> <field id="extFile" value="format.xml" /> <field id="initializer" value="com.ibm.btt.base.FormatInitializer" /> <field id="Format61RootTagName" value="format"/> <kColl id="classTable"> </kColl> </kColl> <kColl id="format61"> <field id="initializer" value="com.ibm.btt.format.FormatInitializer" /> <field id="extFile" value="format.xml" /> <kColl id="classTable"> <field id="format" value="com.ibm.btt.format.impl.FormatDefine" /> <field id="record" value="com.ibm.btt.format.impl.RecordFormat" /> <field id="fInteger" value="com.ibm.btt.format.impl.IntegerFormat" /> <field id="fString" value="com.ibm.btt.format.impl.StringFormat" /> <field id="fHexDelim" value="com.ibm.btt.format.impl.HexDelimiter" /> <field id="refFmt" value="com.ibm.btt.format.impl.ReferenceFormat" /> <field id="iColl" value="com.ibm.btt.format.impl.IndexedFormat" /> <field id="fixedLength" value="com.ibm.btt.format.impl.FixedLength" /> <field id="delim" value="com.ibm.btt.format.impl.Delimiter" /> </kColl> </kColl>
In this example, externalizer in the old formatter component creates the a FormatAdapter when the root tag is format.
Then you need to define FormatElement in the way of new formatter component. The root tag is different with the old formatter. In the old formatter component, the root tag can only be fmtDef. But in the new formatter component, you can configure the root tag in classTable.
<?xml version="1.0"?> <format.xml> <format id="sampleFmt"> <record> <fString dataName="f1" /> <delim delimChar="#" /> <fString dataName="f2" /> <delim delimChar="#" /> </record> </format> </format.xml>
com.ibm.btt.base.FormatElement format = (com.ibm.btt.base.FormatElement) com.ibm.btt.base.FormatElement.readObject("sampleFmt"); Context ctx = ContextFactory.createContext("testCtx"); String str1 = format.format(ctx);
In this way, the format instance is created from FormatElement. FormatElement.readObject("sampleFmt") is an instance of com.ibm.btt.format.impl.FormatAdapter. FormatAdapter extends com.ibm.btt.base.FormatElement and it delegates all the logic to the new formatter component.