com.github.fge.jsonschema.core.report
Class AbstractProcessingReport

java.lang.Object
  extended by com.github.fge.jsonschema.core.report.AbstractProcessingReport
All Implemented Interfaces:
ProcessingReport, Iterable<ProcessingMessage>
Direct Known Subclasses:
ConsoleProcessingReport, DevNullProcessingReport, ListProcessingReport

public abstract class AbstractProcessingReport
extends Object
implements ProcessingReport

Base implementation of a processing report

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.


Constructor Summary
protected AbstractProcessingReport()
          Alternate constructor
protected AbstractProcessingReport(LogLevel logLevel)
          Alternate constructor
protected AbstractProcessingReport(LogLevel logLevel, LogLevel exceptionThreshold)
          Main constructor
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractProcessingReport

protected AbstractProcessingReport(LogLevel logLevel,
                                   LogLevel exceptionThreshold)
Main constructor

Parameters:
logLevel - the log threshold for this report
exceptionThreshold - the exception threshold for this report

AbstractProcessingReport

protected AbstractProcessingReport(LogLevel logLevel)
Alternate constructor

This constructor calls AbstractProcessingReport(LogLevel, LogLevel) with LogLevel.FATAL as the second argument.

Parameters:
logLevel - the log threshold

AbstractProcessingReport

protected AbstractProcessingReport()
Alternate constructor

This constructor calls AbstractProcessingReport(LogLevel, LogLevel) with LogLevel.INFO as the first argument and LogLevel.FATAL as the second argument.

Method Detail

getLogLevel

public final LogLevel getLogLevel()
Description copied from interface: ProcessingReport
Get the log level of this report

Any message with a log level greater than, or equal to, the result of this method is logged.

Specified by:
getLogLevel in interface ProcessingReport
Returns:
the log level

getExceptionThreshold

public final LogLevel getExceptionThreshold()
Description copied from interface: ProcessingReport
Get the exception threshold of this report

Any message with a log level greater than, or equal to, the result of this method raises a ProcessingException or any subclass.

Specified by:
getExceptionThreshold in interface ProcessingReport
Returns:
the exception threshold
See Also:
ProcessingMessage.asException()

debug

public final void debug(ProcessingMessage message)
                 throws ProcessingException
Description copied from interface: ProcessingReport
Log a message with a level of LogLevel.DEBUG

It is the responsibility of the implementation to set the log level of the message appropriately.

Specified by:
debug in interface ProcessingReport
Parameters:
message - the message
Throws:
ProcessingException - the level of this message grants that an exception is thrown instead
See Also:
ProcessingReport.getExceptionThreshold(), ProcessingMessage.setLogLevel(LogLevel)

info

public final void info(ProcessingMessage message)
                throws ProcessingException
Description copied from interface: ProcessingReport
Log a message with a level of LogLevel.INFO

It is the responsibility of the implementation to set the log level of the message appropriately.

Specified by:
info in interface ProcessingReport
Parameters:
message - the message
Throws:
ProcessingException - the level of this message grants that an exception is thrown instead
See Also:
ProcessingReport.getExceptionThreshold(), ProcessingMessage.setLogLevel(LogLevel)

warn

public final void warn(ProcessingMessage message)
                throws ProcessingException
Description copied from interface: ProcessingReport
Log a message with a level of LogLevel.WARNING

It is the responsibility of the implementation to set the log level of the message appropriately.

Specified by:
warn in interface ProcessingReport
Parameters:
message - the message
Throws:
ProcessingException - the level of this message grants that an exception is thrown instead
See Also:
ProcessingReport.getExceptionThreshold(), ProcessingMessage.setLogLevel(LogLevel)

error

public final void error(ProcessingMessage message)
                 throws ProcessingException
Description copied from interface: ProcessingReport
Log a message with a level of LogLevel.ERROR

It is the responsibility of the implementation to set the log level of the message appropriately.

Specified by:
error in interface ProcessingReport
Parameters:
message - the message
Throws:
ProcessingException - the level of this message grants that an exception is thrown instead
See Also:
ProcessingReport.getExceptionThreshold(), ProcessingMessage.setLogLevel(LogLevel)

fatal

public final void fatal(ProcessingMessage message)
                 throws ProcessingException
Description copied from interface: ProcessingReport
Log a message with a level of LogLevel.FATAL

It is the responsibility of the implementation to set the log level of the message appropriately.

Specified by:
fatal in interface ProcessingReport
Parameters:
message - the message
Throws:
ProcessingException - the level of this message grants that an exception is thrown instead
See Also:
ProcessingReport.getExceptionThreshold(), ProcessingMessage.setLogLevel(LogLevel)

isSuccess

public final boolean isSuccess()
Description copied from interface: ProcessingReport
Tell whether the report is a success

A report is considered successful if no messages with a level of LogLevel.ERROR or higher have been logged.

Specified by:
isSuccess in interface ProcessingReport
Returns:
a boolean

log

public abstract void log(LogLevel level,
                         ProcessingMessage message)
The only method to be implemented when extending this class

Note that the message's log level will have been correctly set. The log level is passed as an argument for convenience.

Parameters:
level - the level of the message
message - the message itself

dispatch

protected final void dispatch(ProcessingMessage message)
                       throws ProcessingException
Main dispatch method

All messages logged go through this method. According to the report configuration, the message will either be ignored, logged or raise an exception.

Parameters:
message - the message to log
Throws:
ProcessingException - the message's level and report configuration require that an exception be thrown

iterator

public Iterator<ProcessingMessage> iterator()
Specified by:
iterator in interface Iterable<ProcessingMessage>

mergeWith

public final void mergeWith(ProcessingReport other)
                     throws ProcessingException
Description copied from interface: ProcessingReport
Merge another report into this report

Specified by:
mergeWith in interface ProcessingReport
Parameters:
other - the other report
Throws:
ProcessingException - a message in the other report has a level granting that an exception be thrown

toString

public final String toString()
Overrides:
toString in class Object