2.10.1: 2009-03-24

net.sf.basedb.clients.migrate
Class ProgressThread

java.lang.Object
  extended by net.sf.basedb.clients.migrate.ProgressThread
All Implemented Interfaces:
Runnable

public class ProgressThread
extends Object
implements Runnable

This class provides methods for displaying the progress of a transfer. At a set interval the thread checks whether it's counter has increased, if so progress is printed to standard output.

Version:
2.0
Author:
Gregory
Last modified
$Date: 2008-09-11 22:05:50 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  boolean active
          True if this thread is active.
private  int counter
           
private  int duration
          Total duration between start and stop in milliseconds
private  int endCount
          Progress counter limit.
private  String itemType
          The itemType that is transfered
private  int lastOutputCounter
          Last counter printed to standard output.
private  String OUT_FORMAT
          printf format for an output
(package private)  Thread progress
          This progress thread
private  boolean unused
          True if thread hasn't been started.
private  int updateInterval
          Number of milliseconds to wait before trying to display the progress.
 
Constructor Summary
ProgressThread(int endCount, String itemType)
           
 
Method Summary
 void decrease()
          Decrease the value of the counter by one.
 void display()
          If the progress is active this method prints out status of the progress to standard output.
 void increase()
          Increase the counter by one.
 void increase(int i)
          Increase the counter by i.
private  void printDate()
          Prints date without linebreak.
 void run()
           
 void start()
          Starts progress
 void stop()
          Stops the current progress.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

endCount

private int endCount
Progress counter limit. E.g. number of items to transfer.


counter

private int counter

lastOutputCounter

private int lastOutputCounter
Last counter printed to standard output.


active

private boolean active
True if this thread is active.


unused

private boolean unused
True if thread hasn't been started. One progress object can only be used started and stopped once.


updateInterval

private int updateInterval
Number of milliseconds to wait before trying to display the progress.


OUT_FORMAT

private final String OUT_FORMAT
printf format for an output

See Also:
Constant Field Values

duration

private int duration
Total duration between start and stop in milliseconds


progress

Thread progress
This progress thread


itemType

private String itemType
The itemType that is transfered

Constructor Detail

ProgressThread

ProgressThread(int endCount,
               String itemType)
Parameters:
endCount - Total number of items that will be transfered
Method Detail

start

public void start()
Starts progress


run

public void run()
Specified by:
run in interface Runnable

decrease

public void decrease()
Decrease the value of the counter by one.


increase

public void increase()
Increase the counter by one.


increase

public void increase(int i)
Increase the counter by i.


display

public void display()
If the progress is active this method prints out status of the progress to standard output. Showing Items, Done, Percent Item/s and ETA.


stop

public void stop()
Stops the current progress. Stopped progress threads cannot be activated again.


printDate

private void printDate()
Prints date without linebreak.


2.10.1: 2009-03-24