org.jboss.dna.common.monitor
Class ProgressMonitorWrapper

java.lang.Object
  extended by org.jboss.dna.common.monitor.ProgressMonitorWrapper
All Implemented Interfaces:
ProgressMonitor
Direct Known Subclasses:
LoggingProgressMonitor

public class ProgressMonitorWrapper
extends Object
implements ProgressMonitor

The thread safety of this class is determined by the delegate.

Author:
Randall Hauch, John Verhaeg

Constructor Summary
ProgressMonitorWrapper(ProgressMonitor delegate)
           
 
Method Summary
 void beginTask(double totalWork, I18n name, Object... params)
          Called by the Updater to indicate work has started on the task, specifying the total amount of work that this task constitutes.
 ProgressMonitor createSubtask(double subtaskWork)
          Called by the Updater to create a subtask with the given about of work.
 void done()
          Called by the Updater to mark this activity as complete.
 String getActivityName()
          Get the name of the activity.
 Problems getProblems()
           Return the problems encountered during the progress made towards completing the associated activity.
 ProgressStatus getStatus(Locale locale)
          Return the current status of this activity, localized to the specified locale.
 ProgressMonitor getWrappedMonitor()
           
 boolean isCancelled()
          Return whether a request was made by an Observer to cancel this activity.
 boolean isDone()
          Return whether this activity has completed.
 void setCancelled(boolean value)
          Called by an Observer to request the cancellation of this activity, or by the Updater to deny a prior cancellation request (i.e., when the activity completes before the Updater recognizes a cancellation request by an Observer).
 void worked(double work)
          Called by the Updater to report work completed for this task.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressMonitorWrapper

public ProgressMonitorWrapper(ProgressMonitor delegate)
Method Detail

getWrappedMonitor

public ProgressMonitor getWrappedMonitor()

beginTask

public void beginTask(double totalWork,
                      I18n name,
                      Object... params)
Description copied from interface: ProgressMonitor
Called by the Updater to indicate work has started on the task, specifying the total amount of work that this task constitutes.

Specified by:
beginTask in interface ProgressMonitor
Parameters:
totalWork - the total number of work units for the task
name - the name of the task
params - the parameters for localization

createSubtask

public ProgressMonitor createSubtask(double subtaskWork)
Description copied from interface: ProgressMonitor
Called by the Updater to create a subtask with the given about of work. The resulting progress monitor must be started (ProgressMonitor.beginTask(double, I18n, Object...)) and finished (ProgressMonitor.done()).

Specified by:
createSubtask in interface ProgressMonitor
Parameters:
subtaskWork - the number of work units for this subtask
Returns:
the progress monitor for the subtask

done

public void done()
Description copied from interface: ProgressMonitor
Called by the Updater to mark this activity as complete. This method must be called, even if the activity has been cancelled.

Specified by:
done in interface ProgressMonitor

getActivityName

public String getActivityName()
Description copied from interface: ProgressMonitor
Get the name of the activity. This should never change for a progress monitor, and all subtasks should have the same name.

Specified by:
getActivityName in interface ProgressMonitor
Returns:
the activity's name

getStatus

public ProgressStatus getStatus(Locale locale)
Description copied from interface: ProgressMonitor
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.

Specified by:
getStatus in interface ProgressMonitor
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

getProblems

public Problems getProblems()

Return the problems encountered during the progress made towards completing the associated activity.

Specified by:
getProblems in interface ProgressMonitor
Returns:
the list of problems
See Also:
ProgressMonitor.getProblems()

isCancelled

public boolean isCancelled()
Description copied from interface: ProgressMonitor
Return whether a request was made by an Observer to cancel this activity.

Specified by:
isCancelled in interface ProgressMonitor
Returns:
true if this activity has been requested to be cancelled.

isDone

public boolean isDone()
Return whether this activity has completed.

Specified by:
isDone in interface ProgressMonitor
Returns:
true if this activity has completed.
See Also:
ProgressMonitor.isDone()

setCancelled

public void setCancelled(boolean value)
Description copied from interface: ProgressMonitor
Called by an Observer to request the cancellation of this activity, or by the Updater to deny a prior cancellation request (i.e., when the activity completes before the Updater recognizes a cancellation request by an Observer).

Specified by:
setCancelled in interface ProgressMonitor
Parameters:
value - true if requesting the activity be cancelled.

worked

public void worked(double work)
Description copied from interface: ProgressMonitor
Called by the Updater to report work completed for this task.

Specified by:
worked in interface ProgressMonitor
Parameters:
work - the number of work units that have been worked


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.