salsa.corpora.xmlparser
Class CorpusHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by salsa.corpora.xmlparser.CorpusHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

This handles events of the CorpusParser. It tells the parser how to properly read in a SalsaXML file into the Corpus data structure.

Author:
Fabian Shirokov

Constructor Summary
CorpusHandler()
          Zero-argumented default constructor.
 
Method Summary
 void characters(char[] c, int start, int length)
          This method is called when some text is found in the XML file.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qualName)
          This overrides DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String).
 Corpus getCorpus()
          This returns the Corpus that has been read out of the XML file.
 void startDocument()
          This method is called when the XML document starts.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qualName, org.xml.sax.Attributes atts)
          This overrides DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes).
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CorpusHandler

public CorpusHandler()
Zero-argumented default constructor.

Method Detail

characters

public void characters(char[] c,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
This method is called when some text is found in the XML file. It adds or assigns the text to the currently active element.

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

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qualName)
                throws org.xml.sax.SAXException
This overrides DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String). This method is called when the parser has found a closing element tag.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - a String with the namespace URI, empty if parser factory is not namespace aware (default)
localName - a String with the local name (without prefix), empty if parser factory is not namespace aware (default)
qualName - a String with the qualified (with prefix) name, or the empty string if qualified names are not available
Throws:
org.xml.sax.SAXException - if an error occurs, possibly wrapping another exception

getCorpus

public Corpus getCorpus()
This returns the Corpus that has been read out of the XML file.


startDocument

public void startDocument()
This method is called when the XML document starts. By now, nothing happens in this method.

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

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qualName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
This overrides DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes). This method is called when the parser has found an opening element tag. It initializes new objects and assigns them to their superordinating elements. For example, it creates a new Head and assigns it to the Corpus.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - a String with the namespace URI, empty if parser factory is not namespace aware (default)
localName - a String with the local name (without prefix), empty if parser factory is not namespace aware (default)
qualName - a String with the qualified (with prefix) name, or the empty string if qualified names are not available
atts - Attributes attached to the element, empty if there are no attributes
Throws:
org.xml.sax.SAXException - if an error occurs, possibly wrapping another exception