Class MessageHandler

  extended by com.sdmetrics.app.MessageHandler
Direct Known Subclasses:

public abstract class MessageHandler
extends java.lang.Object

Class to report progress messages and errors during (lengthy) operations such as metric calculations.

There are three types of messages:

  1. Progress messages
    The main purpose of progress messages is logging and to periodically let the user know that the application is still alive during lengthy operations. They do not contain important information that requires user action or confirmation. Progress messages are typically shown on the screen / written to the console.
  2. Error messages
    Error messages are generated when a requested operation cannot be perform and has to be canceled. In interactive applications, error messages are usually shown in error dialogs and require user confirmation.
  3. Notification of completion
    These inform the owner of the message handler that a lengthy operation has been completed successfully. This is useful when the metrics calculation is performed asynchronously, e.g., to maintain a responsive GUI.

Constructor Summary
Method Summary
 void finishedComputation()
          Notifies the owner of handler that the operation has completed successfully.
abstract  void message(java.lang.String message, int progress)
          Reports a calculation progress message.
abstract  void reportError(java.util.List<Problem> problems)
          Reports a list of errors.
 void reportError(java.lang.String message)
          Reports a single error.
 void reportError(java.lang.String message, java.lang.Throwable t)
          Reports a single error caused by an exception.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public MessageHandler()
Method Detail


public abstract void message(java.lang.String message,
                             int progress)
Reports a calculation progress message.

message - Describes the calculation currently being performed. If the string is null, the currently shown message remains the same, only the progress indicator is to be updated.
progress - Integer between 0 and 100 indicating the progress (100=finished). If progress is negative, the currently shown progress remains the same, only the message is to be updated.


public final void reportError(java.lang.String message)
Reports a single error.

message - A description of the error that occurred.


public final void reportError(java.lang.String message,
                              java.lang.Throwable t)
Reports a single error caused by an exception.

message - A description of the operation being performed when the exception was raised.
t - The exception (or, in rare cases, java.lang.Error)


public abstract void reportError(java.util.List<Problem> problems)
Reports a list of errors. Recoverable errors need not be reported immediately, but can be collected and reported en bloc at the end of the operation.

problems - The list of problems to report.


public void finishedComputation()
Notifies the owner of handler that the operation has completed successfully.