org.das2.util.monitor
Class SubTaskMonitor

java.lang.Object
  extended by org.das2.util.monitor.SubTaskMonitor
All Implemented Interfaces:
ProgressMonitor

public class SubTaskMonitor
extends java.lang.Object
implements ProgressMonitor

creates a ProgressMonitor that maps its progress to a parent's progress. For example, if a process takes a progress monitor, but is implemented in two steps that each take a progress monitor, then two subtask monitors can be created to monitor each step, and the client who passed in the monitor will see the whole deal as one process.


Field Summary
 
Fields inherited from interface org.das2.util.monitor.ProgressMonitor
NULL, SIZE_INDETERMINATE
 
Method Summary
 void cancel()
          Notifies the ProgressMonitor that the task being monitored should be canceled.
static SubTaskMonitor create(ProgressMonitor parent, long min, long max)
           
 void finished()
          Notifies the ProgressMonitor that the task being monitored has finished.
 java.lang.String getLabel()
          Return the label string displayed.
 long getTaskProgress()
          Returns the current progress of the monitored task.
 long getTaskSize()
           
 boolean isCancelled()
          Returns true if the operation being tracked should be cancelled.
 boolean isFinished()
          true if the process has indicated that it is finished
 boolean isStarted()
          true if the process has indicated that it has started.
 void setAdditionalInfo(java.lang.String s)
          Deprecated. 
 void setLabel(java.lang.String label)
          Set a consise string that describes the task being performed.
 void setProgressMessage(java.lang.String message)
          Provides additional feedback as to what's going on in the process.
 void setTaskProgress(long position)
          Notifies the ProgressMonitor of a change in the progress of the task.
 void setTaskSize(long taskSize)
          Sets the maximum value for the task progress of this ProgressMonitor.
 void started()
          Notifies the ProgressMonitor that the task being monitored has started.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static SubTaskMonitor create(ProgressMonitor parent,
                                    long min,
                                    long max)

cancel

public void cancel()
Description copied from interface: ProgressMonitor
Notifies the ProgressMonitor that the task being monitored should be canceled. After this method is called, implementations should return true on any subsequent calls to ProgressMonitor.isCancelled() and should throw an IllegalStateException on any subsequent calls to ProgressMonitor.setTaskProgress(long).

Specified by:
cancel in interface ProgressMonitor

finished

public void finished()
Description copied from interface: ProgressMonitor
Notifies the ProgressMonitor that the task being monitored has finished.

Specified by:
finished in interface ProgressMonitor

isFinished

public boolean isFinished()
Description copied from interface: ProgressMonitor
true if the process has indicated that it is finished

Specified by:
isFinished in interface ProgressMonitor

getTaskProgress

public long getTaskProgress()
Description copied from interface: ProgressMonitor
Returns the current progress of the monitored task.

Specified by:
getTaskProgress in interface ProgressMonitor
Returns:
the current progress of the monitored task.

isCancelled

public boolean isCancelled()
Description copied from interface: ProgressMonitor
Returns true if the operation being tracked should be cancelled.

Specified by:
isCancelled in interface ProgressMonitor
Returns:
true if the operation being tracked should be cancelled.

setAdditionalInfo

@Deprecated
public void setAdditionalInfo(java.lang.String s)
Deprecated. 

Description copied from interface: ProgressMonitor
additional information to be displayed alongside the progress. That might be of interest. "85 of 100 (50KB/s)"

Specified by:
setAdditionalInfo in interface ProgressMonitor

setTaskProgress

public void setTaskProgress(long position)
                     throws java.lang.IllegalArgumentException
Description copied from interface: ProgressMonitor
Notifies the ProgressMonitor of a change in the progress of the task.

Specified by:
setTaskProgress in interface ProgressMonitor
Parameters:
position - the current task position
Throws:
java.lang.IllegalArgumentException - if ProgressMonitor.isCancelled() returns true or, possibly if started() has not been called or finished() has been called.

setTaskSize

public void setTaskSize(long taskSize)
Description copied from interface: ProgressMonitor
Sets the maximum value for the task progress of this ProgressMonitor.

Specified by:
setTaskSize in interface ProgressMonitor
Parameters:
taskSize - maximum value for the task progress. A taskSize of -1 indicates the taskSize is indeterminate.

getTaskSize

public long getTaskSize()
Specified by:
getTaskSize in interface ProgressMonitor

started

public void started()
Description copied from interface: ProgressMonitor
Notifies the ProgressMonitor that the task being monitored has started. If the ProgressMonitor is in a cancelled state when this method is called, that ProgressMonitor should be 'uncancelled'.

Specified by:
started in interface ProgressMonitor

isStarted

public boolean isStarted()
Description copied from interface: ProgressMonitor
true if the process has indicated that it has started.

Specified by:
isStarted in interface ProgressMonitor

setLabel

public void setLabel(java.lang.String label)
Description copied from interface: ProgressMonitor
Set a consise string that describes the task being performed. Monitors don't necessarily need to display this label, and this request may be ignored. It is only provided so a process can describe the task that is going on. This is usually set by the client of the process to indicate what service we are waiting for. e.g. "Loading Data"

Specified by:
setLabel in interface ProgressMonitor

getLabel

public java.lang.String getLabel()
Description copied from interface: ProgressMonitor
Return the label string displayed. This is primarily to aid in debugging, and this method need not return the string set by setLabel.

Specified by:
getLabel in interface ProgressMonitor

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setProgressMessage

public void setProgressMessage(java.lang.String message)
Description copied from interface: ProgressMonitor
Provides additional feedback as to what's going on in the process. This message should be set by the service provider, not the client, and refer to the implementation of the task. e.g. "Reading file myData.dat"

Specified by:
setProgressMessage in interface ProgressMonitor
Parameters:
message - the message describing the state of progress.