com.raritantechnologies.xml
Class XMLResultFormatter

java.lang.Object
  extended bycom.raritantechnologies.xml.XMLResultFormatter
All Implemented Interfaces:
IConfigurable, IFieldFormatter

public class XMLResultFormatter
extends java.lang.Object
implements IFieldFormatter, IConfigurable

Implementation of IFieldFormatter that uses the ProgrammableSAXFilter to extract tags from an IResult field containing XML, and sets fields on the IResult from tag names, and/or tag text of contained XML tags.

Typically used with the FieldCollectorHandler.

XML Configuration Template:
  <FieldFormatter class="com.raritantechnologies.xml.XMLResultFormatter" 
                     xmlField="[ the name of the field containing XML to extract from]" >

    <FieldCollector handlerClass="[ class of com.raritantechnologies.xml.IHandler ]"
                       nestedResultField="[ optional name of nested result to put handler data ]" >

    </FieldCollector>

  </FieldFormatter>
 

Developed by Raritan Technologies .

Author:
Jim Nicholson

Field Summary
 
Fields inherited from interface com.raritantechnologies.searchApp.IFieldFormatter
TEMPLATE
 
Constructor Summary
XMLResultFormatter()
           
 
Method Summary
 java.lang.String formatField(java.lang.String fieldVal)
          Reformats a field value.
 java.lang.String formatField(java.lang.String sessionID, java.lang.String fieldVal)
          Reformats a field value.
 void formatResult(IResult res, java.lang.String xmlString)
           
 void formatResultField(IResult res)
          Formats a result field "in place".
 void formatResultField(java.lang.String sessionID, IResult res)
          Formats a result field "in place", incorporating session context.
 java.lang.String getConfigurationXML()
           
 java.lang.String getConfigurationXML(java.lang.String configurationTemplate)
           
 java.lang.String getFieldName()
          Returns the name of the result field that this formatter can reformat.
 void initialize(org.w3c.dom.Element elem)
          Perform housekeeping and setup required for formatting results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLResultFormatter

public XMLResultFormatter()
Method Detail

formatResultField

public void formatResultField(IResult res)
Description copied from interface: IFieldFormatter
Formats a result field "in place".

Specified by:
formatResultField in interface IFieldFormatter
Parameters:
res - The result object that is to be formatted.

formatResultField

public void formatResultField(java.lang.String sessionID,
                              IResult res)
Description copied from interface: IFieldFormatter
Formats a result field "in place", incorporating session context.

Specified by:
formatResultField in interface IFieldFormatter
Parameters:
sessionID - The session key needed to lookup any session content stored in the session data cache.
res - The result object that is to be formatted.

formatResult

public void formatResult(IResult res,
                         java.lang.String xmlString)
Parameters:
res -
xmlString -

getFieldName

public java.lang.String getFieldName()
Description copied from interface: IFieldFormatter
Returns the name of the result field that this formatter can reformat.

Specified by:
getFieldName in interface IFieldFormatter

formatField

public java.lang.String formatField(java.lang.String fieldVal)
Description copied from interface: IFieldFormatter
Reformats a field value.

Specified by:
formatField in interface IFieldFormatter
Parameters:
fieldVal - The field value to be reformatted.
Returns:
The reformatted field value.

formatField

public java.lang.String formatField(java.lang.String sessionID,
                                    java.lang.String fieldVal)
Description copied from interface: IFieldFormatter
Reformats a field value.

Specified by:
formatField in interface IFieldFormatter
Parameters:
sessionID - The session key needed to lookup any session content stored in the session data cache.
fieldVal - The field value to be reformatted.
Returns:
The reformatted field value.

initialize

public void initialize(org.w3c.dom.Element elem)
Perform housekeeping and setup required for formatting results. Creates and initializes content handlers to parse XML fields and store them in the result set.

Specified by:
initialize in interface IFieldFormatter
See Also:
IConfigurable.initialize(org.w3c.dom.Element)

getConfigurationXML

public java.lang.String getConfigurationXML()
Specified by:
getConfigurationXML in interface IFieldFormatter

getConfigurationXML

public java.lang.String getConfigurationXML(java.lang.String configurationTemplate)
Specified by:
getConfigurationXML in interface IFieldFormatter