fi.iki.hsivonen.xml.checker
Class Checker

java.lang.Object
  extended by fi.iki.hsivonen.xml.checker.Checker
All Implemented Interfaces:
ContentHandler
Direct Known Subclasses:
DebugChecker, NormalizationChecker, SignificantInlineChecker, TableChecker, TextContentChecker

public abstract class Checker
extends Object
implements ContentHandler

The abstract base class for SAX-based content checkers that listen to the ContentHandler events and emit errors and warnings to an ErrorHandler.

Always delegates ignorableWhitespace() to characters(). The other ContentHandler methods here are stubs that do nothing. Subclasses, therefore, never need to call the superclass methods.

Version:
$Id: Checker.java,v 1.6 2006/11/29 18:13:32 hsivonen Exp $
Author:
hsivonen

Field Summary
private  ErrorHandler errorHandler
           
private  Locator locator
           
 
Constructor Summary
Checker()
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
          Calls reset().
 void endElement(String uri, String localName, String qName)
           
 void endPrefixMapping(String prefix)
           
 void err(String message)
          Emit an error.
 Locator getDocumentLocator()
          Returns the locator.
 ErrorHandler getErrorHandler()
          Returns the errorHandler.
 void ignorableWhitespace(char[] ch, int start, int length)
          Calls characters().
 void processingInstruction(String target, String data)
           
 void reset()
          Does nothing.
 void setDocumentLocator(Locator locator)
           
 void setErrorHandler(ErrorHandler errorHandler)
          Sets the errorHandler.
 void skippedEntity(String name)
           
 void startDocument()
          Calls reset().
 void startElement(String uri, String localName, String qName, Attributes atts)
           
 void startPrefixMapping(String prefix, String uri)
           
 void warn(String message)
          Emit a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorHandler

private ErrorHandler errorHandler

locator

private Locator locator
Constructor Detail

Checker

public Checker()
Constructor.

Method Detail

warn

public void warn(String message)
          throws SAXException
Emit a warning. The locator is used.

Parameters:
message - the warning message
Throws:
SAXException - if something goes wrong

err

public void err(String message)
         throws SAXException
Emit an error. The locator is used.

Parameters:
message - the error message
Throws:
SAXException - if something goes wrong

reset

public void reset()
Does nothing. Subclasses are expected to override this method with an implementation that clears the state of the checker and releases objects the checker might hold references to.


getErrorHandler

public ErrorHandler getErrorHandler()
Returns the errorHandler.

Returns:
the errorHandler

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Sets the errorHandler.

Parameters:
errorHandler - the errorHandler to set

getDocumentLocator

public Locator getDocumentLocator()
Returns the locator.

Returns:
the locator

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)

startDocument

public void startDocument()
                   throws SAXException
Calls reset().

Specified by:
startDocument in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.startDocument()

endDocument

public void endDocument()
                 throws SAXException
Calls reset().

Specified by:
endDocument in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.endDocument()

ignorableWhitespace

public final void ignorableWhitespace(char[] ch,
                                      int start,
                                      int length)
                               throws SAXException
Calls characters().

Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.ignorableWhitespace(char[], int, int)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.characters(char[], int, int)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.endPrefixMapping(java.lang.String)

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.skippedEntity(java.lang.String)

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)