public class ErrorReportImpl extends Object implements ErrorHandler, ErrorReport
ErrorReport
interface.
This implementation also supports the SAX error handler interface,
so it can be used with other parsers as well.
If this error report is used with an OpenXML parser, the parser will
use the error report facility to extend the SAX error handler with
two features. It will skip warning reporting if they are not
desired by this error report, and it will report the level of errors.
When used with a SAX parser, all errors will be reported at the
default ErrorReport.GENERAL
level.
ErrorReport
,
ErrorHandler
CONTENT, FATAL, GENERAL, PROCESSING, REPORT_ALL_ERRORS, REPORT_NOTHING, REPORT_WITH_WARNING, STOP_AT_CONTENT, STOP_AT_FATAL, STOP_AT_FIRST_ERROR, STOP_AT_NO_ERROR, STOP_AT_PROCESSING, STOP_AT_VALIDITY, STOP_AT_WELL_FORMED, VALIDITY, WARNING, WELL_FORMED
Constructor and Description |
---|
ErrorReportImpl()
Create a new error reporter with the report level
ErrorReport.REPORT_ALL_ERRORS and the stop level ErrorReport.STOP_AT_NO_ERROR . |
ErrorReportImpl(int stopAtLevel,
int reportLevel)
Create a new error reporter with the specified report level and
stop level.
|
Modifier and Type | Method and Description |
---|---|
void |
error(SAXParseException except) |
void |
fatalError(Exception except)
Report a fatal exception derived from an exception.
|
void |
fatalError(SAXParseException except) |
protected String |
formatLocation(Object location)
Given the location returns a suitably formatted string.
|
protected String |
formatMessage(org.openxml.parser.ErrorReportEntry error)
Given the error record returns a suitably formatted string.
|
int |
getCount()
Returns the number of errors contained in this report.
|
int |
getErrorLevel(int index)
Returns the error level of the numbered error.
|
SAXException |
getException(int index)
Returns the error's exception.
|
SAXException |
getLastException()
Return the last error exception.
|
String |
getLastMessage()
Return the last error as formatted message.
|
String |
getMessage(int index)
Returns formatted error message.
|
boolean |
isReporting(int errorLevel)
True if errors in this level are to be reported.
|
SAXException[] |
listExceptions(int fromErrorLevel)
Returns a list of error exceptions.
|
String[] |
listMessages(int fromErrorLevel)
Returns a list of error messages.
|
void |
reportError(int errorLevel,
Node node,
SAXException except)
Report a processing error at the specified level.
|
protected void |
reportError(int errorLevel,
Object location,
SAXException except)
Internal error reporting method.
|
void |
reportError(int errorLevel,
SAXException except)
Report a parse error at the specified level.
|
void |
reportError(int errorLevel,
String location,
SAXException except)
Report a processing error at the specified level.
|
void |
warning(SAXParseException except) |
public ErrorReportImpl()
ErrorReport.REPORT_ALL_ERRORS
and the stop level ErrorReport.STOP_AT_NO_ERROR
.
The application uses this to report all errors for the purpose of
bug fixing, but assumes that the application can recover and
continue in spite of errors.public ErrorReportImpl(int stopAtLevel, int reportLevel)
ErrorReport.STOP_AT_NO_ERROR
, ErrorReport.REPORT_WITH_WARNING
:
Parsing and locating errors in the document; all errors and
warnings are reported at the end.
ErrorReport.STOP_AT_NO_ERROR
, ErrorReport.REPORT_ALL_ERRORS
:
Working with user interaction; will attempt to report all errors
for purpose of bug fixing, but assumes that the application can
go on until the user stops it.
ErrorReport.STOP_AT_FIRST_ERROR
, ErrorReport.REPORT_NOTHING
:
Working non-interactive: there should be no problem, if there is,
processing stops and the last error is reported.
stopAtLevel
- The error level at which to stop processing and
throw an exceptionreportLevel
- The error levels to reportpublic void warning(SAXParseException except) throws SAXException
warning
in interface ErrorHandler
SAXException
public void error(SAXParseException except) throws SAXException
error
in interface ErrorHandler
SAXException
public void fatalError(SAXParseException except) throws SAXException
fatalError
in interface ErrorHandler
SAXException
public void reportError(int errorLevel, String location, SAXException except) throws SAXException
ErrorReport
reportError
in interface ErrorReport
errorLevel
- The error level to reportlocation
- The location at which the error occuredexcept
- The exception to be reportedSAXException
- Will throw the exception if set to stop at
this error levelpublic void reportError(int errorLevel, Node node, SAXException except) throws SAXException
ErrorReport
reportError
in interface ErrorReport
errorLevel
- The error level to reportnode
- The document tree node at which the error occuredexcept
- The exception to be reportedSAXException
- Will throw the exception if set to stop at
this error levelpublic void reportError(int errorLevel, SAXException except) throws SAXException
ErrorReport
reportError
in interface ErrorReport
errorLevel
- The error level to reportexcept
- The exception to be reportedSAXException
- Will throw the exception if set to stop at
this error levelpublic void fatalError(Exception except) throws SAXException
ErrorReport
fatalError
in interface ErrorReport
except
- The exception to be reported as fatalSAXException
- The exception is reported and thrown as this
SAX exceptionpublic boolean isReporting(int errorLevel)
ErrorReport
isReporting
in interface ErrorReport
public int getCount()
ErrorReport
getCount
in interface ErrorReport
public int getErrorLevel(int index)
ErrorReport
getErrorLevel
in interface ErrorReport
index
- The error message numberpublic SAXException getException(int index)
ErrorReport
SAXException
exception, SAXParseException
if the error was generated by a parser.getException
in interface ErrorReport
index
- The error message numberpublic String getMessage(int index)
ErrorReport
getMessage
in interface ErrorReport
index
- The error message numberpublic SAXException getLastException()
ErrorReport
getLastException
in interface ErrorReport
public String getLastMessage()
ErrorReport
getLastMessage
in interface ErrorReport
public String[] listMessages(int fromErrorLevel)
ErrorReport
ErrorReport.WARNING
.listMessages
in interface ErrorReport
fromErrorLevel
- Return only errors of this or higher
error levelpublic SAXException[] listExceptions(int fromErrorLevel)
ErrorReport
ErrorReport.WARNING
.listExceptions
in interface ErrorReport
fromErrorLevel
- Return only errors of this or higher
error levelprotected void reportError(int errorLevel, Object location, SAXException except) throws SAXException
errorLevel
- The level of the reported errorlocation
- Object that describes location at which error occuredexcept
- The error's exceptionSAXException
protected String formatMessage(org.openxml.parser.ErrorReportEntry error)
formatLocation(java.lang.Object)
.
The following parameters are used in formatting the message:
formatLocation(java.lang.Object)
)
error
- The error recordprotected String formatLocation(Object location)
Locator
or SAXException
,
the location in the source document is returned in a suitable
format; if the location is a DOM node, its location in the
document tree is returned; if the location is a string, or a
null, it is returned as is.
The following parameters are used in formatting the location in the source document:
HTML/HEAD/TITLE/#text
location
- The location objectPhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.