com.adventnet.utilities.xml.sax
Class ErrorHandlerImpl

java.lang.Object
  extended by com.adventnet.utilities.xml.sax.ErrorHandlerImpl
All Implemented Interfaces:
org.xml.sax.ErrorHandler

public class ErrorHandlerImpl
extends java.lang.Object
implements org.xml.sax.ErrorHandler

An implementation of the org.xml.sax.ErrorHandler interface.

This ErrorHandler implementation logs the error messages generated while parsing the XML file to a logger.

If an application requires to log errors generated while parsing an XML file, this class can be set as an ErrorHandler using the setErrorHandler method of the parser.


Field Summary
(package private)  Log log
           
 
Constructor Summary
ErrorHandlerImpl()
          Creates an error handler that logs messages to the default logger.
ErrorHandlerImpl(java.lang.String loggerName)
          Creates an error handler that logs messages to the specified logger.
 
Method Summary
 void error(org.xml.sax.SAXParseException e)
          Logs the error message with Debug Level: ERROR
 void fatalError(org.xml.sax.SAXParseException e)
          Logs the error message with Debug Level: FATAL
 boolean isWriteToFile()
          Determines whether to write to log file or not.
 void setWriteToFile(boolean writeToFile)
          Enables writing to a log file.
 void warning(org.xml.sax.SAXParseException e)
          Logs the error message with Debug Level: WARN
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

Log log
Constructor Detail

ErrorHandlerImpl

public ErrorHandlerImpl()
Creates an error handler that logs messages to the default logger.


ErrorHandlerImpl

public ErrorHandlerImpl(java.lang.String loggerName)
Creates an error handler that logs messages to the specified logger.

Parameters:
loggerName - Specify the name of the logger to be used
Method Detail

setWriteToFile

public void setWriteToFile(boolean writeToFile)
Enables writing to a log file.

Parameters:
writeToFile - The boolean value that specifies whether to write to the log file. When this is false, error messages are shown in the console.

isWriteToFile

public boolean isWriteToFile()
Determines whether to write to log file or not.

Returns:
boolean true if writing to log file is enabled, false otherwise.

error

public void error(org.xml.sax.SAXParseException e)
Logs the error message with Debug Level: ERROR

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
e - The SAXParseException that occured while parsing the XML.

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Logs the error message with Debug Level: FATAL

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
e - The SAXParseException that occured while parsing the XML.
Throws:
org.xml.sax.SAXException - when a Fatal error is encountered and can not proceed further.

warning

public void warning(org.xml.sax.SAXParseException e)
Logs the error message with Debug Level: WARN

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
e - The SAXParseException that occured while parsing the XML.