org.histpop.server.wrappers
Class DDIParser2

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.histpop.server.wrappers.DDIParser2
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class DDIParser2
extends org.xml.sax.helpers.DefaultHandler

This class is responsible for parsing the DDI XML input DDIParser2 is a SAX parser. The input file is treated as a series of events. Each time the parser encounters an event, a call-back method is invoked. At present this parser only implements the startElement endElement and character callback methods. When a startElement tag is encountered, a new DDINode object is created which wraps up any attributes of the tag, along with its full path. When character text inside a node is encountered, a new DDINode object is created which wraps up this text. Thus for elements containing data, two DDINode objects are produced, one containing the attributes, and the other containing the data. This is a quick fix: it is inefficient and causes other problems. The trouble is, if you postpone generation of the node until any character data has been processed, the elemens will be generated in the wrong order if there are sub elements.


Constructor Summary
DDIParser2(DDIParserController controller)
          Create a new parser, using the controller supplied
 
Method Summary
 void characters(char[] buf, int offset, int len)
          Called when text within a tag is detected
 void endDocument()
          Called on document end
 void endElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName)
          Called when a tag is closed
 void parse(java.io.InputStream ddixml)
          The parse method is the main entry point for the DDI import package.
 void startDocument()
          Called on document start
 void startElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Called when a new tag is opened
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DDIParser2

public DDIParser2(DDIParserController controller)
Create a new parser, using the controller supplied

Method Detail

parse

public void parse(java.io.InputStream ddixml)
The parse method is the main entry point for the DDI import package.

Parameters:
ddixml - the ddi file to load

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Called on document start

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Called on document end

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String sName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Called when a new tag is opened

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String sName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Called when a tag is closed

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws org.xml.sax.SAXException
Called when text within a tag is detected

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException