com.calitha.xml
Class SimpleErrorHandler

java.lang.Object
  extended by com.calitha.xml.SimpleErrorHandler
All Implemented Interfaces:
ErrorHandler

public class SimpleErrorHandler
extends Object
implements ErrorHandler

This class represents an error handler for XML parsers with a simple to use API.

The error handlers stores warnings, errors and fatal errors encountered by the parser.

Author:
Robert van Loenhout

Constructor Summary
SimpleErrorHandler()
          Creates a new error handler.
 
Method Summary
 void clear()
          Clears all fatal errors, errors and warnings.
 boolean containsError()
          Determines if any errors are stored.
 boolean containsFatalError()
          Determines if any fatal errors are stored
 boolean containsWarning()
          Determines if any warnings are stored.
 void error(SAXParseException exception)
          Store an exception caused by an error.
 void fatalError(SAXParseException exception)
          Store an exception caused by a fatal error.
 SAXParseException[] getErrors()
          Gets the errors that are stored so far.
 SAXParseException[] getFatalErrors()
          Gets the fatal errors that are stored so far.
 SAXParseException getFirstProblem()
          Gets the first problem, either a warning, error or fatal error, that was encountered by a parser.
 SAXParseException[] getWarnings()
          Gets the warnings that are stored so far.
 boolean isValid()
          Determines if no error or fatal error is stored.
 String toString()
          Returns a string containing all stored problems.
 void warning(SAXParseException exception)
          Store an exception caused by a warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleErrorHandler

public SimpleErrorHandler()
Creates a new error handler.

Method Detail

warning

public void warning(SAXParseException exception)
             throws SAXException
Store an exception caused by a warning.

Specified by:
warning in interface ErrorHandler
Parameters:
exception - parse exception
Throws:
SAXException

error

public void error(SAXParseException exception)
           throws SAXException
Store an exception caused by an error.

Specified by:
error in interface ErrorHandler
Parameters:
exception - parse exception
Throws:
SAXException

fatalError

public void fatalError(SAXParseException exception)
                throws SAXException
Store an exception caused by a fatal error.

Specified by:
fatalError in interface ErrorHandler
Parameters:
exception - parse exception
Throws:
SAXException

getWarnings

public SAXParseException[] getWarnings()
Gets the warnings that are stored so far.

Returns:
warnings

getErrors

public SAXParseException[] getErrors()
Gets the errors that are stored so far.

Returns:
errors

getFatalErrors

public SAXParseException[] getFatalErrors()
Gets the fatal errors that are stored so far.

Returns:
fatal errors

clear

public void clear()
Clears all fatal errors, errors and warnings.


getFirstProblem

public SAXParseException getFirstProblem()
Gets the first problem, either a warning, error or fatal error, that was encountered by a parser.

Returns:
first problem

containsWarning

public boolean containsWarning()
Determines if any warnings are stored.

Returns:
true if there are warnings

containsError

public boolean containsError()
Determines if any errors are stored.

Returns:
true if there are errors

containsFatalError

public boolean containsFatalError()
Determines if any fatal errors are stored

Returns:
if any fatal errors are stored

isValid

public boolean isValid()
Determines if no error or fatal error is stored.

Returns:
true if there are no errors and fatal errors

toString

public String toString()
Returns a string containing all stored problems.

Overrides:
toString in class Object
Returns:
string representing all problems