com.raritantechnologies.xml.sax.filter.handlers
Class FieldCollectorHandler

java.lang.Object
  extended bycom.raritantechnologies.xml.sax.filter.handlers.FieldCollectorHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, IConfigurable, IHandler

public class FieldCollectorHandler
extends java.lang.Object
implements IHandler

FieldCollector is a content handler for ProgrammableSAXFilter that stores fields from an XML record into a Map. Used by XMLResultFormatter.

XML Configuration Template:
    <FieldCollector handlerClass="com.raritantechnologies.xml.sax.filter.handlers.FieldCollectorHandler"
                       recordTag="[ name of Tag to retrieve fields from ]" />
 

Developed by Raritan Technologies .

Author:
Jim Nicholson

Field Summary
protected static boolean DEBUG
           
 
Constructor Summary
FieldCollectorHandler()
          Create a new handler with default values.
FieldCollectorHandler(java.util.Map fieldMap)
          Create a new handler, specifying the Map which will hold the results of the parse operation.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Stuff those values into the HashMap
 void endDocument()
          End parsing operations
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
          Clean up and maybe go home.
 void endPrefixMapping(java.lang.String prefix)
          Rid ourselves of one of those pesky namespace mappings.
 java.lang.String getCurrentXPath()
          Get the current XPath location.
 java.util.Map getFieldMap()
           
 org.xml.sax.Locator getLocator()
           
 void ignorableWhitespace(char[] arg0, int arg1, int arg2)
          Ignore whitespace
 void init()
           
 void initialize(org.w3c.dom.Element elem)
          Set up the configuration from the config file.
 boolean isComplete()
          Flag to determine if SAX parsing completed without problems.
 void processingInstruction(java.lang.String arg0, java.lang.String arg1)
          Ignore processingInstructions
 void setDocumentLocator(org.xml.sax.Locator newLocator)
          Set the locator for this SAX document
 void setFieldMap(java.util.Map fieldMap)
          Set the java.util.Map object to hold field/value mappings.
 void skippedEntity(java.lang.String arg0)
          Ignore entities we don't care about
 void startDocument()
          Begin parsing operations
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          Find and store some fields.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Save any namespace mappings found in case someone is interested in them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
See Also:
Constant Field Values
Constructor Detail

FieldCollectorHandler

public FieldCollectorHandler()
Create a new handler with default values. The object returned by "fieldMap" will be a java.util.HashMap unless it is reset by a call to setFieldMap before the parser is invoked.


FieldCollectorHandler

public FieldCollectorHandler(java.util.Map fieldMap)
Create a new handler, specifying the Map which will hold the results of the parse operation.

Parameters:
fieldMap - - the java.util.Map object to hold field/value pairs.
Method Detail

init

public void init()
Specified by:
init in interface IHandler

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator newLocator)
Set the locator for this SAX document

Specified by:
setDocumentLocator in interface IHandler
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Begin parsing operations

Specified by:
startDocument in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
End parsing operations

Specified by:
endDocument in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endDocument()

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Save any namespace mappings found in case someone is interested in them.

Specified by:
startPrefixMapping in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Rid ourselves of one of those pesky namespace mappings.

Specified by:
endPrefixMapping in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endPrefixMapping(java.lang.String)

getLocator

public org.xml.sax.Locator getLocator()
Returns:
Returns the locator.

getCurrentXPath

public java.lang.String getCurrentXPath()
Get the current XPath location.

Returns:
a String representing the XPath to the current element being processed.

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Find and store some fields.

Specified by:
startElement in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Clean up and maybe go home.

Specified by:
endElement in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Stuff those values into the HashMap

Specified by:
characters in interface IHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.characters(char[], int, int)

ignorableWhitespace

public void ignorableWhitespace(char[] arg0,
                                int arg1,
                                int arg2)
                         throws org.xml.sax.SAXException
Ignore whitespace

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.ignorableWhitespace(char[], int, int)

processingInstruction

public void processingInstruction(java.lang.String arg0,
                                  java.lang.String arg1)
                           throws org.xml.sax.SAXException
Ignore processingInstructions

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

skippedEntity

public void skippedEntity(java.lang.String arg0)
                   throws org.xml.sax.SAXException
Ignore entities we don't care about

Specified by:
skippedEntity in interface org.xml.sax.ContentHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.skippedEntity(java.lang.String)

isComplete

public boolean isComplete()
Description copied from interface: IHandler
Flag to determine if SAX parsing completed without problems.

Specified by:
isComplete in interface IHandler
Returns:
Returns the complete.

getFieldMap

public java.util.Map getFieldMap()
Specified by:
getFieldMap in interface IHandler
Returns:
Returns the fieldMap.

setFieldMap

public void setFieldMap(java.util.Map fieldMap)
Set the java.util.Map object to hold field/value mappings.

Specified by:
setFieldMap in interface IHandler
Parameters:
fieldMap - The fieldMap to set.

initialize

public void initialize(org.w3c.dom.Element elem)
Set up the configuration from the config file.

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