@MinDoc(copyright="Copyright 2001 - 2005, 2009 A. Weinert", author="Albrecht Weinert", version="V.33", lastModified="27.03.2021", usage="use in XML applications", purpose="an error handler for XML parser, base of other handlers") public class ParseErrorHandler extends Object implements ErrorHandler
reThrow
) tries to go on in spite of
errors.de.frame4j
,
SAXHandler
Modifier and Type | Field and Description |
---|---|
int |
errorCount
The counter for errors.
|
int |
fatalCount
The counter for fatal errors.
|
protected PrintWriter |
log
Output for errors and warnings.
|
protected String |
name
Denomination of the input.
|
protected boolean |
reThrow
Throw exceptions after counting and logging (again).
|
int |
warningCount
The counter for warnings.
|
Constructor and Description |
---|
ParseErrorHandler(CharSequence name,
PrintWriter log,
boolean reThrow)
An error handler by name, XML-input and report output.
|
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
appRep(StringBuilder bastel,
String typ,
SAXParseException err)
Make / append a line containing a parse error report.
|
void |
error(SAXParseException err)
Handling an error.
|
void |
fatalError(SAXParseException err)
Handling a fatal Error.
|
String |
getName()
Denomination of the input.
|
void |
init(CharSequence name,
boolean reThrow)
Initialise an error handler giving the XML input a name.
|
void |
report()
Summarised report.
|
void |
reportErrors()
Summarised report, only in case of warnings or errors.
|
String |
toString()
State as String.
|
StringBuilder |
toStringBuilder(StringBuilder bastel)
Summarised report.
|
void |
warning(SAXParseException err)
Handling a warning.
|
public int errorCount
public int warningCount
public int fatalCount
protected String name
protected final PrintWriter log
protected boolean reThrow
error(SAXParseException)
and
fatalError(SAXParseException)
re-throw the
SAXParseException
s passed to them (again).warning(SAXParseException)
never does
that.public ParseErrorHandler(CharSequence name, PrintWriter log, boolean reThrow)
ErrorHandler
object is made named according to the parameter
name
or "...".log
the parameter log
is taken if not
null and the (decorated) normal output (System.out) otherwise.name
- the handler's or the input's name (stripped from surrounding
white space; null or empty is taken as "..."log
- destination for reportsreThrow
- if true error exceptions are thrown (again) and not just
reportedinit(CharSequence, boolean)
public final String getName()
public void init(CharSequence name, boolean reThrow)
name
and reThrow
to the
parameter values and resets all error counters and else.ParseErrorHandler
without any
problems or throwaway objects.name
- the handler's or the input's name (stripped from surrounding
white space; null or empty is taken as "..."reThrow
- if true error exceptions are thrown (again) and not just
reportedTextHelper.trimUq(CharSequence, String)
public void fatalError(SAXParseException err) throws SAXParseException
log
.fatalError
in interface ErrorHandler
SAXParseException
- the err
provided will be (re-) thrown
if reThrow
is trueappRep(StringBuilder, String, SAXParseException)
public static StringBuilder appRep(StringBuilder bastel, String typ, SAXParseException err)
typ
(usually "error", "fatal"
or "warning") and substantial informations gathered from
err
.bastel
- The StringBuilder to append to; if null it will be made with
91 characters starting capacitytyp
- the message type: error warning or elseerr
- the exception describing the XML parse errorpublic void error(SAXParseException err) throws SAXParseException
log
a one line message will be output, containing also the
line and column denotation got from err
.error
in interface ErrorHandler
SAXParseException
- the err
provided will be (re-) thrown
if reThrow
is trueappRep(StringBuilder, String, SAXParseException)
public void warning(SAXParseException err)
log
a one line message will be output, containing also the
line and column denotation got from err
.warning
in interface ErrorHandler
public void report()
log
a multi-line report, made by
toStringBuilder(StringBuilder)
, will be output including the
so far error / warning counts.reportErrors()
public void reportErrors()
log
a multi-line report, made by
toStringBuilder(StringBuilder)
, will be output including the
so far error / warning counts only if such events occurred.toStringBuilder(StringBuilder)
public StringBuilder toStringBuilder(StringBuilder bastel)
StringBuilder
bastel will be a multi-line report
containing also the so far error / warning counts.
bastel
- The StringBuilder to append to; if null it will be made with
91 characters starting capacity