If a property takes an object as its value, the data loader must convert that object to a string to include it in an output record. The PropertyFormatter interface defines methods for performing this conversion.

By default, the data loaders use the implementation class atg.endeca.index.formatter.EndecaPropertyFormatter. This class invokes the object’s getLong() method for numbers or getTime() method for dates; for booleans, it converts the value to the String “0” (false) or “1” (true). For other objects, it calls the object’s toString() method.

You can write your own implementations of PropertyFormatter that use custom logic for performing the conversion. The simplest way to do this is to subclass EndecaPropertyFormatter.

In an EndecaIndexingOutputConfig definition file, you can specify a custom property formatter by using the formatter attribute. For example, suppose you have a Nucleus component named /mystuff/MyPropertyFormatter, of a custom class that implements the PropertyFormatter interface. You can specify it in the definition file like this:

<property name="price" formatter="/MyStuff/MyPropertyFormatter"/>

The value of the formatter attribute is the absolute path of the Nucleus component. To simplify coding of the definition file, you can map PropertyFormatter Nucleus components to simple names, and use those names as the values of formatter attributes. For example, if you map the /mystuff/MyPropertyFormatter component to the name myFormatter, the above tag becomes:

<property name="price" formatter="myFormatter"/>

You can perform this mapping by setting the formatterMap property of the IndexingOutputConfig component. This property is a Map in which the keys are the names and the values are PropertyFormatter Nucleus components that the names represent.

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices