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 |
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 |
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()
ProcessingReportAny message with a log level greater than, or equal to, the result of this method is logged.
getLogLevel in interface ProcessingReportpublic final LogLevel getExceptionThreshold()
ProcessingReportAny message with a log level greater than, or equal to, the result of
this method raises a ProcessingException or any subclass.
getExceptionThreshold in interface ProcessingReportProcessingMessage.asException()public final void debug(ProcessingMessage message) throws ProcessingException
ProcessingReportLogLevel.DEBUG
It is the responsibility of the implementation to set the log level of the message appropriately.
debug in interface ProcessingReportmessage - 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
ProcessingReportLogLevel.INFO
It is the responsibility of the implementation to set the log level of the message appropriately.
info in interface ProcessingReportmessage - 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
ProcessingReportLogLevel.WARNING
It is the responsibility of the implementation to set the log level of the message appropriately.
warn in interface ProcessingReportmessage - 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
ProcessingReportLogLevel.ERROR
It is the responsibility of the implementation to set the log level of the message appropriately.
error in interface ProcessingReportmessage - the messageProcessingException - the level of this message grants that an
exception is thrown insteadProcessingReport.getExceptionThreshold(),
ProcessingMessage.setLogLevel(LogLevel)public final boolean isSuccess()
ProcessingReportA report is considered successful if no messages with a level of
LogLevel.ERROR or higher have been logged.
isSuccess in interface ProcessingReportpublic 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
ProcessingReportmergeWith in interface ProcessingReportother - the other reportProcessingException - a message in the other report has a level
granting that an exception be thrownCopyright © 2013. All Rights Reserved.