org.tuckey.web.filters.validation
Class ValidationHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.tuckey.web.filters.validation.ValidationHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

Version:
$Revision: 9 $ $Date: 2006-09-20 20:36:12 +1200 (Wed, 20 Sep 2006) $
Author:
Paul Tuckey

Constructor Summary
ValidationHandler(java.lang.String source, java.lang.String url)
          Create a handler using the default xml parser.
ValidationHandler(java.lang.String source, java.lang.String url, java.lang.String xmlParser)
          Create a new Handler using a custom xml parser.
 
Method Summary
 void error(org.xml.sax.SAXParseException ex)
           
 void fatalError(org.xml.sax.SAXParseException ex)
           
static javax.xml.parsers.DocumentBuilderFactory getCustomParserInstance(java.lang.String xmlParser)
          Helper method to get a custom parser.
 ValidationDoctype getDoctype()
           
 java.util.List getErrors()
           
 javax.xml.parsers.DocumentBuilder getParser()
           
 java.lang.String getReportDiv()
           
 java.lang.String[] getSourceAsArrayOfLines()
           
 boolean isValid()
           
 void parse()
          DOM parse the document.
 void warning(org.xml.sax.SAXParseException ex)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationHandler

public ValidationHandler(java.lang.String source,
                         java.lang.String url)
                  throws java.io.FileNotFoundException
Create a handler using the default xml parser.

Throws:
java.io.FileNotFoundException

ValidationHandler

public ValidationHandler(java.lang.String source,
                         java.lang.String url,
                         java.lang.String xmlParser)
                  throws java.io.FileNotFoundException,
                         BadXmlParserException
Create a new Handler using a custom xml parser.

Throws:
java.io.FileNotFoundException
BadXmlParserException
Method Detail

parse

public void parse()
           throws java.io.IOException
DOM parse the document.

Throws:
java.io.IOException

warning

public void warning(org.xml.sax.SAXParseException ex)
Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler

error

public void error(org.xml.sax.SAXParseException ex)
Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler

fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

isValid

public boolean isValid()

getErrors

public final java.util.List getErrors()

getSourceAsArrayOfLines

public java.lang.String[] getSourceAsArrayOfLines()

getDoctype

public ValidationDoctype getDoctype()

getReportDiv

public java.lang.String getReportDiv()
                              throws java.io.IOException
Throws:
java.io.IOException

getParser

public javax.xml.parsers.DocumentBuilder getParser()

getCustomParserInstance

public static javax.xml.parsers.DocumentBuilderFactory getCustomParserInstance(java.lang.String xmlParser)
                                                                        throws BadXmlParserException
Helper method to get a custom parser.

Throws:
BadXmlParserException