org.optimizationservices.oscommon.util
Class CommonErrorHandler

java.lang.Object
  extended by org.optimizationservices.oscommon.util.CommonErrorHandler
All Implemented Interfaces:
org.xml.sax.ErrorHandler

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

The CommonErrorHandler class is derived from the SAX DefaultHandler class and provides common ways to handle warning, error, and fatalerror.

Since:
OS1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin
See Also:
DefaultHandler

Field Summary
 java.lang.String errorMessage
          errorMessage holds the error message if any.
 java.lang.String warningMessage
          warningMessage holds the warning message if any.
 
Constructor Summary
CommonErrorHandler()
           
 
Method Summary
 void error(org.xml.sax.SAXParseException e)
          Handle notification of a recoverable error.
 void fatalError(org.xml.sax.SAXParseException e)
          Handle notification of a non-recoverable error.
 boolean hasError()
           
 boolean hasWarning()
           
static void main(java.lang.String[] argv)
          main for test purposes.
 void warning(org.xml.sax.SAXParseException e)
          Handle notification of a warning.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorMessage

public java.lang.String errorMessage
errorMessage holds the error message if any.


warningMessage

public java.lang.String warningMessage
warningMessage holds the warning message if any.

Constructor Detail

CommonErrorHandler

public CommonErrorHandler()
Method Detail

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Handle notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation such as a validity constraint. The implemented behavior is to print the xml style error message and set the error flag true.

The SAX parser will continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser will report a fatal error.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
exception - The error information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException, ErrorHandler.error(org.xml.sax.SAXParseException)

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Handle notification of a non-recoverable error.

This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation, such as a well-formedness constraint.The implemented behavior is to print the xml style error message and set the fatalError flag true.

The application will assume that the document is unusable after the parser has invoked this method, and will continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
exception - The error information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException, ErrorHandler.fatalError(org.xml.sax.SAXParseException)

warning

public void warning(org.xml.sax.SAXParseException e)
             throws org.xml.sax.SAXException
Handle notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The implemented behavior is to print the xml style warning message and set the warning flag true.

The SAX parser will continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
e - The warning information encapsulated in a SAX parse exception.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
SAXParseException, ErrorHandler.warning(org.xml.sax.SAXParseException)

hasError

public boolean hasError()
Returns:
whether there is an error or fatalError in parsing.

hasWarning

public boolean hasWarning()
Returns:
whether there is a warning in parsing.

main

public static void main(java.lang.String[] argv)
main for test purposes.

Parameters:
argv - command line arguments.