com.raritantechnologies.searchApp.formatters
Class RegExprFieldFormatter

java.lang.Object
  extended bycom.raritantechnologies.searchApp.formatters.RegExprFieldFormatter
All Implemented Interfaces:
IConfigurable, IFieldFormatter

public class RegExprFieldFormatter
extends java.lang.Object
implements IFieldFormatter

Uses a regular expression processor to format field(s) of an IResult. Can be configured with more than one input pattern, the first pattern that matches the result field value will be used to reformat the field.

XML Configuration Template:

Formatter sets value of "fieldName" to output of regular expression processing using "inPattern" and "outPattern".

   <Formatter 
      fieldID="fieldName" 
      formatterClass="com.raritantechnologies.searchApp.formatters.RegExprFieldFormatter" 
      inPattern="(*)\\s\\d\\d:\\d\\d:\\d\\d$" 
      outPattern="$1" />

   Can also have one or more patterns - the first pattern that matches the field value will be used to
   reformat the field:

   <Formatter 
      fieldID="fieldName" 
      formatterClass="com.raritantechnologies.searchApp.formatters.RegExprFieldFormatter" >

     <!-- one or more Pattern elements: -->
     <Pattern inPattern="[ Input RegExpr pattern ]"
                 outPattern="[ output Reg Expr pattern ]"
                 checkPattern="[ matching pattern ]" >

        <!-- optional StringFilter to apply to output of Regular Expression processing -->
        <StringFilter class="[ class of com.raritantechnologies.utils.filter.IStringFilter ]" >
          <!-- configuration parameters of IStringFilter -->
        </StringFilter>
     </Pattern>
  
     <!-- another Pattern element etc... -->

   </Formatter>

 

Developed by Raritan Technologies .

Author:
Ted Sullivan

Field Summary
 
Fields inherited from interface com.raritantechnologies.searchApp.IFieldFormatter
TEMPLATE
 
Constructor Summary
RegExprFieldFormatter()
           
RegExprFieldFormatter(java.lang.String fieldName, java.lang.String inPattern, java.lang.String outPattern)
           
 
Method Summary
 java.lang.String formatField(java.lang.String fieldVal)
          returns formatted string by using Regular Expression transformation on the first matching pattern.
 java.lang.String formatField(java.lang.String sessionID, java.lang.String fieldVal)
          Reformats a field value.
 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 initElem)
          Initializes the formatter from configuration XML element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegExprFieldFormatter

public RegExprFieldFormatter()

RegExprFieldFormatter

public RegExprFieldFormatter(java.lang.String fieldName,
                             java.lang.String inPattern,
                             java.lang.String outPattern)
Method Detail

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

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.

formatField

public java.lang.String formatField(java.lang.String fieldVal)
returns formatted string by using Regular Expression transformation on the first matching pattern.

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 initElem)
Description copied from interface: IFieldFormatter
Initializes the formatter from configuration XML element.

Specified by:
initialize in interface IFieldFormatter

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