public abstract class AbstractProcessingReport extends Object implements ProcessingReport
This abstract class implements all the logic of a processing report. The
only method you need to implement is log(LogLevel,
ProcessingMessage)
, which will implement the actual logging of the message.
When entering this method, the message's log level will already have been set
correctly.
Modifier | Constructor and Description |
---|---|
protected |
AbstractProcessingReport()
Alternate constructor
|
protected |
AbstractProcessingReport(LogLevel logLevel)
Alternate constructor
|
protected |
AbstractProcessingReport(LogLevel logLevel,
LogLevel exceptionThreshold)
Main constructor
|
Modifier and Type | Method and Description |
---|---|
void |
debug(ProcessingMessage message)
Log a message with a level of
LogLevel.DEBUG |
protected void |
dispatch(ProcessingMessage message)
Main dispatch method
|
void |
error(ProcessingMessage message)
Log a message with a level of
LogLevel.ERROR |
void |
fatal(ProcessingMessage message)
Log a message with a level of
LogLevel.FATAL |
LogLevel |
getExceptionThreshold()
Get the exception threshold of this report
|
LogLevel |
getLogLevel()
Get the log level of this report
|
void |
info(ProcessingMessage message)
Log a message with a level of
LogLevel.INFO |
boolean |
isSuccess()
Tell whether the report is a success
|
Iterator<ProcessingMessage> |
iterator() |
abstract void |
log(LogLevel level,
ProcessingMessage message)
The only method to be implemented when extending this class
|
void |
mergeWith(ProcessingReport other)
Merge another report into this report
|
String |
toString() |
void |
warn(ProcessingMessage message)
Log a message with a level of
LogLevel.WARNING |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected AbstractProcessingReport(LogLevel logLevel, LogLevel exceptionThreshold)
logLevel
- the log threshold for this reportexceptionThreshold
- the exception threshold for this reportprotected AbstractProcessingReport(LogLevel logLevel)
This constructor calls AbstractProcessingReport(LogLevel,
LogLevel)
with LogLevel.FATAL
as the second argument.
logLevel
- the log thresholdprotected AbstractProcessingReport()
This constructor calls AbstractProcessingReport(LogLevel,
LogLevel)
with LogLevel.INFO
as the first argument and LogLevel.FATAL
as the second argument.
public final LogLevel getLogLevel()
ProcessingReport
Any message with a log level greater than, or equal to, the result of this method is logged.
getLogLevel
in interface ProcessingReport
public final LogLevel getExceptionThreshold()
ProcessingReport
Any message with a log level greater than, or equal to, the result of
this method raises a ProcessingException
or any subclass.
getExceptionThreshold
in interface ProcessingReport
ProcessingMessage.asException()
public final void debug(ProcessingMessage message) throws ProcessingException
ProcessingReport
LogLevel.DEBUG
It is the responsibility of the implementation to set the log level of the message appropriately.
debug
in interface ProcessingReport
message
- the messageProcessingException
- the level of this message grants that an
exception is thrown insteadProcessingReport.getExceptionThreshold()
,
ProcessingMessage.setLogLevel(LogLevel)
public final void info(ProcessingMessage message) throws ProcessingException
ProcessingReport
LogLevel.INFO
It is the responsibility of the implementation to set the log level of the message appropriately.
info
in interface ProcessingReport
message
- the messageProcessingException
- the level of this message grants that an
exception is thrown insteadProcessingReport.getExceptionThreshold()
,
ProcessingMessage.setLogLevel(LogLevel)
public final void warn(ProcessingMessage message) throws ProcessingException
ProcessingReport
LogLevel.WARNING
It is the responsibility of the implementation to set the log level of the message appropriately.
warn
in interface ProcessingReport
message
- the messageProcessingException
- the level of this message grants that an
exception is thrown insteadProcessingReport.getExceptionThreshold()
,
ProcessingMessage.setLogLevel(LogLevel)
public final void error(ProcessingMessage message) throws ProcessingException
ProcessingReport
LogLevel.ERROR
It is the responsibility of the implementation to set the log level of the message appropriately.
error
in interface ProcessingReport
message
- the messageProcessingException
- the level of this message grants that an
exception is thrown insteadProcessingReport.getExceptionThreshold()
,
ProcessingMessage.setLogLevel(LogLevel)
public final void fatal(ProcessingMessage message) throws ProcessingException
ProcessingReport
LogLevel.FATAL
It is the responsibility of the implementation to set the log level of the message appropriately.
fatal
in interface ProcessingReport
message
- the messageProcessingException
- the level of this message grants that an
exception is thrown insteadProcessingReport.getExceptionThreshold()
,
ProcessingMessage.setLogLevel(LogLevel)
public final boolean isSuccess()
ProcessingReport
A report is considered successful if no messages with a level of
LogLevel.ERROR
or higher have been logged.
isSuccess
in interface ProcessingReport
public abstract void log(LogLevel level, ProcessingMessage message)
Note that the message's log level will have been correctly set. The log level is passed as an argument for convenience.
level
- the level of the messagemessage
- the message itselfprotected final void dispatch(ProcessingMessage message) throws ProcessingException
All messages logged go through this method. According to the report configuration, the message will either be ignored, logged or raise an exception.
message
- the message to logProcessingException
- the message's level and report configuration
require that an exception be thrownpublic Iterator<ProcessingMessage> iterator()
iterator
in interface Iterable<ProcessingMessage>
public final void mergeWith(ProcessingReport other) throws ProcessingException
ProcessingReport
mergeWith
in interface ProcessingReport
other
- the other reportProcessingException
- a message in the other report has a level
granting that an exception be thrownCopyright © 2016. All rights reserved.