to.etc.util
Class Progress

java.lang.Object
  extended by to.etc.util.Progress

public class Progress
extends java.lang.Object

A progress reporter utility. A single instance defines progress in user-specified numeric terms (for instance record 12 of 1012312), and gets translated to a percentage. Progress instances can obtain sub-progress parts that are Progress entries all by themselves and can define their work in their terms; they get mapped to the defined part of work in their parent(s).

Author:
Frits Jalvingh Created on Oct 16, 2009

Constructor Summary
Progress(java.lang.String name)
          Top-level progress indicator for a given task.
 
Method Summary
 void cancel()
          Request the action to be cancelled.
 void complete()
           
 Progress createSubProgress(java.lang.String name, double work)
          Create a sub-progress indicator for the specified portion of work.
 java.lang.String getActionPath(int levels)
           
 double getCompletedWork()
           
 double getFraction()
           
 java.lang.String getName()
           
 Progress getParent()
           
 int getPercentage()
           
 Progress getRoot()
          Return the root progress handler; this NEVER returns null - it returns itself if it is the root.
 double getTotalWork()
           
 void increment(double inc)
           
 boolean isCancelled()
           
 void setCompleted(double now)
          Set the amount of work completed.
 void setTotalWork(double work)
          Set the current amount of work.
protected  void updated()
           
protected  boolean updateFromSub()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Progress

public Progress(java.lang.String name)
Top-level progress indicator for a given task.

Method Detail

getRoot

public Progress getRoot()
Return the root progress handler; this NEVER returns null - it returns itself if it is the root.

Returns:

getParent

public Progress getParent()

getName

public java.lang.String getName()

getTotalWork

public double getTotalWork()

getCompletedWork

public double getCompletedWork()

getPercentage

public int getPercentage()

getFraction

public double getFraction()

getActionPath

public java.lang.String getActionPath(int levels)

cancel

public void cancel()
Request the action to be cancelled.


isCancelled

public boolean isCancelled()

setTotalWork

public void setTotalWork(double work)
Set the current amount of work.

Parameters:
work -
name -

setCompleted

public void setCompleted(double now)
Set the amount of work completed. It can only be set to a valid value, and it can only advance, not go back.

Parameters:
now -

complete

public void complete()

increment

public void increment(double inc)

createSubProgress

public Progress createSubProgress(java.lang.String name,
                                  double work)
Create a sub-progress indicator for the specified portion of work.

Returns:

updated

protected void updated()

updateFromSub

protected boolean updateFromSub()