org.jboss.dna.common.monitor
Interface ProgressMonitor

All Known Implementing Classes:
LoggingProgressMonitor, NullProgressMonitor, ProgressMonitorWrapper, SimpleProgressMonitor, SubProgressMonitor

public interface ProgressMonitor

A basic progress monitor that facilitates the monitoring of an activity.

The progress of each activity is started when beginTask(double, I18n, Object...) is called, continues with a mixture of work (worked(double)) and subtasks (createSubtask(double)), and finishes when the activity is completed (done()) or cancelled (setCancelled(boolean)).

Author:
Randall Hauch

Method Summary
 void beginTask(double totalWork, I18n name, java.lang.Object... params)
          Start work on the task, specifying the total amount of work that this task constitutes.
 ProgressMonitor createSubtask(double subtaskWork)
          Create a subtask with the given about of work.
 void done()
          Mark this task as being completed.
 java.lang.String getActivityName()
          Get the name of the activity.
 ProgressStatus getStatus(java.util.Locale locale)
          Return the current status of this activity, localized to the specified locale.
 boolean isCancelled()
          Returned whether this activity has been cancelled.
 void setCancelled(boolean value)
          Set the cancelled state of this activity.
 void worked(double work)
          Report work completed for this task.
 

Method Detail

getActivityName

java.lang.String getActivityName()
Get the name of the activity. This should never change for a progress monitor, and all subtasks should have the same name.

Returns:
the activity's name

beginTask

void beginTask(double totalWork,
               I18n name,
               java.lang.Object... params)
Start work on the task, specifying the total amount of work that this task constitutes.

Parameters:
totalWork - the total number of work units for the task
name - the name of the task
params - the parameters for localization

worked

void worked(double work)
Report work completed for this task.

Parameters:
work - the number of work units that have been worked

createSubtask

ProgressMonitor createSubtask(double subtaskWork)
Create a subtask with the given about of work. The resulting monitor must be started (beginTask(double, I18n, Object...)) and finished (done()).

Parameters:
subtaskWork - the number of work units for this subtask
Returns:
the progress monitor for the subtask

done

void done()
Mark this task as being completed. This method must be called for the task to be properly completed.


setCancelled

void setCancelled(boolean value)
Set the cancelled state of this activity. Cancelling the activity must be considered a request that can be denied by setting the cancelled state to false.

Parameters:
value - true if requesting the activity be cancelled.

isCancelled

boolean isCancelled()
Returned whether this activity has been cancelled.

Returns:
true if this activity has been requested to be cancelled, or false otherwise.

getStatus

ProgressStatus getStatus(java.util.Locale locale)
Return the current status of this activity, localized to the specified locale. This method returns an immutable but consistent snapshot of the status for this activity. Note that if this instance is a subtask, this method returns the status of the subtask.

Parameters:
locale - the locale in which the status is to be represented; if null, the default locale will be used
Returns:
the status of this activity


Copyright © 2008. All Rights Reserved.