ca.macewan.lmsreporter.api
Class AnalysisEvent

java.lang.Object
  extended byjava.util.EventObject
      extended byca.macewan.lmsreporter.api.AnalysisEvent
All Implemented Interfaces:
Serializable

public class AnalysisEvent
extends EventObject

The event type sent by Analyzer objects to AnalysisListener objects. The events are used to signal that an anlysis has started or finished, the level of progress inbetween, and whether or not an error occurred. Additionally, an Analyzer object can request the display of a supplementary user interface element while the analysis is in progress.

Version:
0.1
Author:
Erwin Veugelers
See Also:
Serialized Form

Field Summary
static double PROGRESS_MAX
          The maximum value of analysis progress.
static double PROGRESS_MIN
          The minimum value of analysis progress.
static int TYPE_ERROR
          The event type signaling an error occurred in the analysis.
static int TYPE_FINISHED
          The event type signaling the analysis finished.
static int TYPE_PROGRESS
          The event type signaling the level of progress of the analysis.
static int TYPE_REQUEST_UI_DISPLAY
          The event type signaling the analysis requests a supplementary user interface element to be displayed.
static int TYPE_STARTED
          The event type signaling the analysis started.
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
AnalysisEvent(Analyzer source)
          The event constructor.
 
Method Summary
 Analyzer getAnalyzer()
          Returns the source of the event as an Analyzer object.
 Component getComponent()
          Gets the component to be displayed.
 Throwable getError()
          Gets the error that occurred in the analysis.
 String getInfo()
          Gets an information message to be displayed to the user in conjunction with this event.
 double getProgress()
          Gets the level of progress for the analysis.
 int getType()
          Gets the type of this event.
 void setComponent(Component c)
          Sets the component to be displayed when sending the event as type TYPE_REQUEST_UI_DISPLAY.
 void setError(Throwable t)
          Sets the error that occurred in the analysis.
 void setInfo(String information)
          Sets an information message to be displayed to the user in conjunction with this event.
 void setProgress(double progress)
          Sets the level of progress for the analysis.
 void setType(int type)
          Sets the event type.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_STARTED

public static final int TYPE_STARTED
The event type signaling the analysis started.

See Also:
Constant Field Values

TYPE_FINISHED

public static final int TYPE_FINISHED
The event type signaling the analysis finished.

See Also:
Constant Field Values

TYPE_PROGRESS

public static final int TYPE_PROGRESS
The event type signaling the level of progress of the analysis.

See Also:
Constant Field Values

TYPE_ERROR

public static final int TYPE_ERROR
The event type signaling an error occurred in the analysis.

See Also:
Constant Field Values

TYPE_REQUEST_UI_DISPLAY

public static final int TYPE_REQUEST_UI_DISPLAY
The event type signaling the analysis requests a supplementary user interface element to be displayed.

See Also:
Constant Field Values

PROGRESS_MIN

public static final double PROGRESS_MIN
The minimum value of analysis progress.

See Also:
Constant Field Values

PROGRESS_MAX

public static final double PROGRESS_MAX
The maximum value of analysis progress.

See Also:
Constant Field Values
Constructor Detail

AnalysisEvent

public AnalysisEvent(Analyzer source)
The event constructor.

Parameters:
source - The Analyzer object generating the event.
Method Detail

getAnalyzer

public Analyzer getAnalyzer()
Returns the source of the event as an Analyzer object.

Returns:
The Analyzer object that generated the event.

setType

public void setType(int type)
Sets the event type.

Parameters:
type - The event type. Should be one of:

getType

public int getType()
Gets the type of this event.

Returns:
The event type. Should be one of:

setProgress

public void setProgress(double progress)
Sets the level of progress for the analysis.

Parameters:
progress - A double between PROGRESS_MIN and PROGRESS_MAX.

getProgress

public double getProgress()
Gets the level of progress for the analysis.

Returns:
A double between PROGRESS_MIN and PROGRESS_MAX.

setError

public void setError(Throwable t)
Sets the error that occurred in the analysis.

Parameters:
t - The error, as a Throwable object. Typically this should be a checked exception (as opposed to an error or a runtime exception) but the event class makes no restrictions.

getError

public Throwable getError()
Gets the error that occurred in the analysis.

Returns:
The error, as a Throwable object. Typically this should be a checked exception (as opposed to an error or a runtime exception) but the event class makes no restrictions.

setInfo

public void setInfo(String information)
Sets an information message to be displayed to the user in conjunction with this event.

Parameters:
information - The message to be set.

getInfo

public String getInfo()
Gets an information message to be displayed to the user in conjunction with this event.

Returns:
The information message.

setComponent

public void setComponent(Component c)
Sets the component to be displayed when sending the event as type TYPE_REQUEST_UI_DISPLAY.

Parameters:
c - The component to be displayed. All the application does is show a javax.swing.JOptionPane dialog with your component as the message. Any user interaction (other than closing the dialog) has to be handled by your own listeners. The component is only guaranteed to be retained as long as the event type is equal to TYPE_REQUEST_UI_DISPLAY.

getComponent

public Component getComponent()
Gets the component to be displayed. Note: If the event type is not equal to TYPE_REQUEST_UI_DISPLAY, this method will likely return null.

Returns:
The component to be displayed.