net.firstpartners.rp.back.extractor.xml
Class SaxXMLBuilder

java.lang.Object
  extended by org.xml.sax.HandlerBase
      extended by net.firstpartners.rp.back.extractor.xml.SaxXMLBuilder
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class SaxXMLBuilder
extends org.xml.sax.HandlerBase

XML Sax - builder

Version:
1.3
Author:
Firstpartners.net

Field Summary
private  java.io.CharArrayWriter contents
          Buffer for collecting data from the "characters" SAX event
(package private)  IXMLController controller
          XML-Controller
 
Constructor Summary
SaxXMLBuilder(IXMLController control)
          Creates a builder that forwards the SAX events to the given handler and use the specified controller to handle the tokens
 
Method Summary
 void characters(char[] buf, int start, int length)
          When the parser encounters plain text (not XML elements), it calls this method, which accumulates them in a string buffer
 void endDocument()
          Calls the method with the same name of the handler object
 void endElement(java.lang.String name)
          Calls the method with the same name of the handler object after calling the controller to handle the process content
 void error(org.xml.sax.SAXParseException exception)
          This method is called when errors occur
 void fatalError(org.xml.sax.SAXParseException exception)
          This method is called when non-recoverable errors occur
 void processingInstruction(java.lang.String target, java.lang.String data)
          Calls the method when processing instruction is read it
 void setDocumentLocator(org.xml.sax.Locator locator)
          Calls the method with the same name of the handler object passing the given locator as parameter.
 void startDocument()
          Calls the method with the same name of the handler object
 void startElement(java.lang.String name, org.xml.sax.AttributeList attributes)
          Calls the method with the same name of the controller object or creates a DOM Element node depending on the value of the wantDOM flag.
 void warning(org.xml.sax.SAXParseException exception)
          This method is called when warnings occur
 
Methods inherited from class org.xml.sax.HandlerBase
ignorableWhitespace, notationDecl, resolveEntity, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controller

IXMLController controller
XML-Controller


contents

private java.io.CharArrayWriter contents
Buffer for collecting data from the "characters" SAX event

Constructor Detail

SaxXMLBuilder

public SaxXMLBuilder(IXMLController control)
Creates a builder that forwards the SAX events to the given handler and use the specified controller to handle the tokens

Parameters:
control - Controller of the application
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Calls the method with the same name of the handler object passing the given locator as parameter.

Specified by:
setDocumentLocator in interface org.xml.sax.DocumentHandler
Overrides:
setDocumentLocator in class org.xml.sax.HandlerBase
Parameters:
locator - The SAX Locator object

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Calls the method with the same name of the handler object

Specified by:
startDocument in interface org.xml.sax.DocumentHandler
Overrides:
startDocument in class org.xml.sax.HandlerBase
Throws:
org.xml.sax.SAXException - Error reported by the handler's method

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Calls the method with the same name of the handler object

Specified by:
endDocument in interface org.xml.sax.DocumentHandler
Overrides:
endDocument in class org.xml.sax.HandlerBase
Throws:
org.xml.sax.SAXException - Error reported by the handler's method

startElement

public void startElement(java.lang.String name,
                         org.xml.sax.AttributeList attributes)
                  throws org.xml.sax.SAXException
Calls the method with the same name of the controller object or creates a DOM Element node depending on the value of the wantDOM flag.

Specified by:
startElement in interface org.xml.sax.DocumentHandler
Overrides:
startElement in class org.xml.sax.HandlerBase
Parameters:
name - The element's name
attributes - The element's attributes
Throws:
org.xml.sax.SAXException - Error reported by the controller's method

endElement

public void endElement(java.lang.String name)
                throws org.xml.sax.SAXException
Calls the method with the same name of the handler object after calling the controller to handle the process content

Specified by:
endElement in interface org.xml.sax.DocumentHandler
Overrides:
endElement in class org.xml.sax.HandlerBase
Parameters:
name - The element's name
Throws:
org.xml.sax.SAXException - Error reported by the handler's method

characters

public void characters(char[] buf,
                       int start,
                       int length)
When the parser encounters plain text (not XML elements), it calls this method, which accumulates them in a string buffer

Specified by:
characters in interface org.xml.sax.DocumentHandler
Overrides:
characters in class org.xml.sax.HandlerBase
Parameters:
buf - Buffer
start - Start position
length - Length position

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Calls the method when processing instruction is read it

Specified by:
processingInstruction in interface org.xml.sax.DocumentHandler
Overrides:
processingInstruction in class org.xml.sax.HandlerBase
Parameters:
target - The target of the processing instruction.
data - The data of the processing instruction.
Throws:
org.xml.sax.SAXException - Error reported by the handler's method

warning

public void warning(org.xml.sax.SAXParseException exception)
This method is called when warnings occur

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.HandlerBase
Parameters:
exception - SAXException in the warning process

error

public void error(org.xml.sax.SAXParseException exception)
This method is called when errors occur

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.HandlerBase
Parameters:
exception - SAXException in the error process

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
This method is called when non-recoverable errors occur

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.HandlerBase
Parameters:
exception - SAXException in the fatalError exception
Throws:
org.xml.sax.SAXException - Error reported by the controller's method