2.17.2: 2011-06-17

net.sf.basedb.util
Class ChainedProgressReporter

java.lang.Object
  extended by net.sf.basedb.util.ChainedProgressReporter
All Implemented Interfaces:
ProgressReporter

public class ChainedProgressReporter
extends Object
implements ProgressReporter

An implementation of the ProgressReporter interface that chains to another progress reporter while recalculating the percentage values. This class is useful when you call several methods in a row that each of them outputs progress messages between 0 and 100 percent. Use this progress reporter to change the scale so that the first method output values between 0 and 20, the next between 20 and 50, and so on.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2010-04-29 13:33:19 +0200 (Thu, 29 Apr 2010) $

Field Summary
private  int end
           
private  ProgressReporter master
           
private  float scale
           
private  int start
           
 
Constructor Summary
ChainedProgressReporter(ProgressReporter master)
          Create a new chained progress reporter.
 
Method Summary
 void append(String message)
          Append a message to the previous one.
 void display(int percent, String message)
          Display a progress message.
 void setRange(int start, int end)
          Set the range to use for the percentage values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

master

private final ProgressReporter master

start

private int start

end

private int end

scale

private float scale
Constructor Detail

ChainedProgressReporter

public ChainedProgressReporter(ProgressReporter master)
Create a new chained progress reporter. All calls to this progress reporter will be propagated to the master progress reporter after the percentage value has been recalculated to be within the specified range.

Parameters:
master - The master progress reporter
See Also:
setRange(int, int)
Method Detail

display

public void display(int percent,
                    String message)
Description copied from interface: ProgressReporter
Display a progress message.

Specified by:
display in interface ProgressReporter
Parameters:
percent - How many percent of the task that is completed or -1 if not known
message - A message, or null

append

public void append(String message)
Description copied from interface: ProgressReporter
Append a message to the previous one.

Specified by:
append in interface ProgressReporter
Parameters:
message - The message

setRange

public void setRange(int start,
                     int end)
Set the range to use for the percentage values. When the display(int, String) method is invoked the percentage value is recalculated to be within the specified range before the master progress reporter is invoked. Ie. 0 --> start and 100 --> end.

Parameters:
start - Start value
end - End value.

2.17.2: 2011-06-17