org.jboss.dna.common.monitor
Class SubProgressMonitor

java.lang.Object
  extended by org.jboss.dna.common.monitor.SubProgressMonitor
All Implemented Interfaces:
ProgressMonitor

@NotThreadSafe
public class SubProgressMonitor
extends java.lang.Object
implements ProgressMonitor

Author:
Randall Hauch

Constructor Summary
SubProgressMonitor(ProgressMonitor parent, double subtaskTotalInParent)
           
 
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.
 ProgressMonitor getParent()
           
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubProgressMonitor

public SubProgressMonitor(ProgressMonitor parent,
                          double subtaskTotalInParent)
Method Detail

getActivityName

public 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.

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

getParent

public ProgressMonitor getParent()
Returns:
parent

beginTask

public 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.

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)
Create a subtask with the given about of work. The resulting 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()
Mark this task as being completed. This method must be called for the task to be properly completed.

Specified by:
done in interface ProgressMonitor

isCancelled

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

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

setCancelled

public 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.

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

worked

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

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

getStatus

public 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.

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


Copyright © 2008. All Rights Reserved.