Hilbert II - Version 0.03.04

org.qedeq.kernel.xml.parser
Class SaxDefaultHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.qedeq.kernel.xml.parser.SaxDefaultHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class SaxDefaultHandler
extends DefaultHandler

Default SAX handler. Delegates SAX events to a AbstractSimpleHandler which could also delegate events to other AbstractSimpleHandlers.

Before anything is parsed the method setExceptionList(SyntaxExceptionList) must be called.

Version:
$Revision: 1.25 $

Constructor Summary
SaxDefaultHandler()
          Constructor.
 
Method Summary
 void changeHandler(AbstractSimpleHandler newHandler, String elementName, SimpleAttributes attributes)
          Change current handler to new one.
 void characters(char[] ch, int start, int length)
           
 SAXParseException createSAXParseException(Exception e)
          Wraps exception in new SAXParseException including parsing position information.
 SAXParseException createSAXParseException(String message)
          Creates new SAXParseException including parsing position information.
 void endDocument()
           
 void endElement(String uri, String localName, String qName)
           
 int getLevel()
          Get current level.
 void setBasisDocumentHandler(AbstractSimpleHandler handler)
          Set basis handler for documents.
 void setDocumentLocator(Locator locator)
          Receive a Locator object for document events.
 void setExceptionList(SyntaxExceptionList errorList)
          Set parse exception list.
 void setUrl(URL url)
          Set file that is parsed.
 void startDocument()
           
 void startElement(String uri, String localName, String qName, Attributes amap)
           
 
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
 

Constructor Detail

SaxDefaultHandler

public SaxDefaultHandler()
Constructor.

Method Detail

setExceptionList

public final void setExceptionList(SyntaxExceptionList errorList)
Set parse exception list. This list collects occurring parsing errors.

Parameters:
errorList - Collect errors here.

setDocumentLocator

public final void setDocumentLocator(Locator locator)
Receive a Locator object for document events. Store the locator for use with other document events.

Parameters:
locator - A locator for all SAX document events.
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator), Locator

setBasisDocumentHandler

public final void setBasisDocumentHandler(AbstractSimpleHandler handler)
Set basis handler for documents.

Parameters:
handler - Basis handler for documents. This handler might also pass control to another handler via the AbstractSimpleHandler.changeHandler(AbstractSimpleHandler, String, SimpleAttributes) method.

startDocument

public final void startDocument()
                         throws SAXException
Throws:
SAXException

endDocument

public final void endDocument()
                       throws SAXException
Throws:
SAXException

startElement

public final void startElement(String uri,
                               String localName,
                               String qName,
                               Attributes amap)
                        throws SAXException
Throws:
SAXException

endElement

public final void endElement(String uri,
                             String localName,
                             String qName)
                      throws SAXException
Throws:
SAXException

characters

public final void characters(char[] ch,
                             int start,
                             int length)

changeHandler

public final void changeHandler(AbstractSimpleHandler newHandler,
                                String elementName,
                                SimpleAttributes attributes)
                         throws SyntaxException
Change current handler to new one. The new handler is initialized by calling AbstractSimpleHandler.init(). The new handler also gets a AbstractSimpleHandler.startElement(String, SimpleAttributes) event. The current handler is stacked. After the new handler gets the appropriate endElement event, the control is switched back to the old handler.

The switch back is also done, if the tag level gets back to the same number. That means if for example the new handler starts with the <banana> tag, the old handler is restored when the misspelled </bnana> tag occurs:

 <banana>
      <one />
      <two >
          <one />
          <one />
      </two >
 </bnana>
 

Parameters:
newHandler - This handler gets the new events.
elementName - Element name.
attributes - Element attributes.
Throws:
SyntaxException - New Handler detected a semantic problem.

getLevel

public final int getLevel()
Get current level.

Returns:
Current level.

createSAXParseException

public final SAXParseException createSAXParseException(Exception e)
Wraps exception in new SAXParseException including parsing position information.

Parameters:
e - Exception to wrap.
Returns:
Exception to throw.

createSAXParseException

public final SAXParseException createSAXParseException(String message)
Creates new SAXParseException including parsing position information.

Parameters:
message - Problem description.
Returns:
Exception to throw.

setUrl

public final void setUrl(URL url)
Set file that is parsed.

Parameters:
url - This file is parsed.

Hilbert II - Version 0.03.04

©left GNU General Public Licence
All Rights Reserved.