Package net.sf.basedb.util
Class ChainedProgressReporter
java.lang.Object
net.sf.basedb.util.ChainedProgressReporter
- All Implemented Interfaces:
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: 2015-06-04 13:33:43 +0200 (to, 04 jun 2015) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private final ProgressReporter
private String
private float
private int
-
Constructor Summary
ConstructorDescriptionCreate a new chained progress reporter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Append a message to the previous one.void
Display a progress message.void
setMessagePrefix
(String prefix) Set a message prefix that is pre-pended to message before it is sent to the master progress reporter.void
setRange
(int start, int end) Set the range to use for the percentage values.
-
Field Details
-
master
-
start
private int start -
end
private int end -
scale
private float scale -
messagePrefix
-
-
Constructor Details
-
ChainedProgressReporter
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:
-
-
Method Details
-
display
Description copied from interface:ProgressReporter
Display a progress message.- Specified by:
display
in interfaceProgressReporter
- Parameters:
percent
- How many percent of the task that is completed or -1 if not knownmessage
- A message, or null
-
append
Description copied from interface:ProgressReporter
Append a message to the previous one.- Specified by:
append
in interfaceProgressReporter
- Parameters:
message
- The message
-
setRange
public void setRange(int start, int end) Set the range to use for the percentage values. When thedisplay(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 valueend
- End value.
-
setMessagePrefix
Set a message prefix that is pre-pended to message before it is sent to the master progress reporter.- Since:
- 3.6
-