com.a7soft.examxml
Class ExamXMLHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.a7soft.examxml.ExamXMLHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

The ExamXML base class for SAX2 event handlers.


Method Summary
 void characters(char[] ch, int start, int length)
          Parser calls this for each text part in a document.
 void endDocument()
          Parser calls this once after parsing a document.
 void endElement(java.lang.String namespace, java.lang.String localName, java.lang.String qName)
          Parser calls this for each element in a document.
static ExamXMLHandler getInstance(java.lang.String logFile)
          Creates if necessary and returns the instance of the ExamXMLHandler object.
 Element loadXML(org.xml.sax.InputSource source)
          Loads the XML document and returns the root XML element.
 void setDocumentLocator(org.xml.sax.Locator loc)
          Sets the XML document locator
 void setFeatures()
          Sets the SAXParser features and properties.
 void startDocument()
          Parser calls this once at the beginning of a document.
 void startElement(java.lang.String namespace, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Parser calls this for each element in a document.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ExamXMLHandler getInstance(java.lang.String logFile)
Creates if necessary and returns the instance of the ExamXMLHandler object.

Parameters:
logFile - the log file name
Returns:
the ExamXMLHandler instance

setFeatures

public void setFeatures()
Sets the SAXParser features and properties.


loadXML

public Element loadXML(org.xml.sax.InputSource source)
Loads the XML document and returns the root XML element.

Parameters:
source - the InputSource, containing the content to be parsed
Returns:
the root Element of the XML document

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Parser calls this once at the beginning of a document.

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - if a parsing error occurs

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Parser calls this once after parsing a document.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - if there is a parsing problem

startElement

public void startElement(java.lang.String namespace,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Parser calls this for each element in a document.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespace - the namespace URI
localName - the local name of the element
qName - the qualified name of the element
attrs - the attributes of the element
Throws:
org.xml.sax.SAXException - if a parsing error occurs

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Parser calls this for each text part in a document.

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 namespace,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Parser calls this for each element in a document.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
namespace - the namespace URI
localName - the local name of the element
qName - the qualified name of the element
Throws:
org.xml.sax.SAXException - if a parsing error occurs

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator loc)
Sets the XML document locator

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
Parameters:
loc - Locator