www.sdmetrics.com

com.sdmetrics.app
Class MessageHandler

java.lang.Object
  extended by com.sdmetrics.app.MessageHandler
Direct Known Subclasses:
ConsoleMessageHandler

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
MessageHandler()
           
 
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

MessageHandler

public MessageHandler()
Method Detail

message

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

Parameters:
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.

reportError

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

Parameters:
message - A description of the error that occurred.

reportError

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

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

reportError

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.

Parameters:
problems - The list of problems to report.

finishedComputation

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


www.sdmetrics.com