- java.lang.Object
-
- com.sun.tools.xjc.ErrorReceiver
-
- All Implemented Interfaces:
ErrorListener
,ErrorListener
,ErrorHandler
- Direct Known Subclasses:
ConsoleErrorReporter
,ErrorReceiverFilter
public abstract class ErrorReceiver extends Object implements ErrorHandler, ErrorListener
Implemented by the driver of the compiler engine to handle errors found during the compiliation.This class implements
ErrorHandler
so it can be passed to anywhere whereErrorHandler
is expected.However, to make the error handling easy (and make it work with visitor patterns nicely), none of the methods on thi class throws
SAXException
. Instead, when the compilation needs to be aborted, it throwsAbortException
, which is unchecked.This also implements the externally visible
ErrorListener
so that we can reuse our internal implementation for testing and such.- Author:
- Kohsuke Kawaguchi ([email protected])
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ErrorReceiver()
Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
debug(String msg)
Reports a debug message to users.void
error(Exception e)
void
error(String msg, Exception e)
void
error(Locator loc, String msg)
void
error(Locator loc, String msg, Exception e)
abstract void
error(SAXParseException exception)
abstract void
fatalError(SAXParseException exception)
protected String
getLocationString(SAXParseException e)
Returns the human readable string representation of theLocator
part of the specifiedSAXParseException
.abstract void
info(SAXParseException exception)
Reports verbose messages to users.void
pollAbort()
This method will be invoked periodically to allowAbortException
to be thrown, especially when this is driven by some kind of GUI.void
warning(Locator loc, String msg)
abstract void
warning(SAXParseException exception)
-
-
-
Method Detail
-
error
public final void error(Locator loc, String msg)
- Parameters:
loc
- can be null if the location is unknown
-
error
public void error(Exception e)
-
warning
public final void warning(Locator loc, String msg)
- Parameters:
loc
- can be null if the location is unknown
-
error
public abstract void error(SAXParseException exception) throws AbortException
- Specified by:
error
in interfaceErrorHandler
- Specified by:
error
in interfaceErrorListener
- Specified by:
error
in interfaceErrorListener
- Throws:
AbortException
-
fatalError
public abstract void fatalError(SAXParseException exception) throws AbortException
- Specified by:
fatalError
in interfaceErrorHandler
- Specified by:
fatalError
in interfaceErrorListener
- Specified by:
fatalError
in interfaceErrorListener
- Throws:
AbortException
-
warning
public abstract void warning(SAXParseException exception) throws AbortException
- Specified by:
warning
in interfaceErrorHandler
- Specified by:
warning
in interfaceErrorListener
- Specified by:
warning
in interfaceErrorListener
- Throws:
AbortException
-
pollAbort
public void pollAbort() throws AbortException
This method will be invoked periodically to allowAbortException
to be thrown, especially when this is driven by some kind of GUI.- Throws:
AbortException
-
info
public abstract void info(SAXParseException exception)
Reports verbose messages to users. This method can be used to report additional non-essential messages. The implementation usually discards them unless some specific debug option is turned on.- Specified by:
info
in interfaceErrorListener
- Specified by:
info
in interfaceErrorListener
-
debug
public final void debug(String msg)
Reports a debug message to users.- See Also:
info(SAXParseException)
-
getLocationString
protected final String getLocationString(SAXParseException e)
Returns the human readable string representation of theLocator
part of the specifiedSAXParseException
.- Returns:
- non-null valid object.
-
-