public class LoggingProgressMonitor extends Object implements ProgressMonitor
ProgressMonitor
which may be used to log to a Log
messages about about the progression of a lengthy task.Modifier and Type | Field and Description |
---|---|
Log |
log
The log used to log the information.
|
protected int |
stepCount |
protected String |
stepMessage |
Constructor and Description |
---|
LoggingProgressMonitor(Log log,
String stepMessage)
Constructs a progress monitor parameterized using specified values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
message(String message,
Console.MessageType messageType)
Invoked by the lengthy task to give this monitor information about the
step being executed.
|
void |
start()
Invoked by the lengthy task to inform this monitor that the execution
of the task has started.
|
boolean |
step(int step)
Invoked by the lengthy task to inform this monitor each time a new step
is about to be executed.
|
boolean |
stepCount(int stepCount)
Invoked by the lengthy task to inform this monitor about the total
numbers of steps comprising the task.
|
protected String |
stepMessage(int step) |
void |
stop()
Invoked by the lengthy task to inform this monitor that the execution
of the task has stopped, whatever the reason (success, canceled,
error).
|
public final Log log
protected String stepMessage
protected int stepCount
public LoggingProgressMonitor(Log log, String stepMessage)
log
- the log used to log the informationstepMessage
- the message used for each invocation of step(int)
(the full message is thus:
"stepMessage step/stepCount")
May be null
.public void start()
ProgressMonitor
This method is guaranteed to be invoked once before any other method.
start
in interface ProgressMonitor
public boolean message(String message, Console.MessageType messageType)
ProgressMonitor
This method may be invoked any number of times (including 0), at any
time, between ProgressMonitor.start()
and ProgressMonitor.stop()
.
message
in interface ProgressMonitor
message
- message containing information about the step being
executedmessageType
- type of message.
May be null
which is equivalent to INFO.false
if this monitor wants to cancel the lengthy
task; true
otherwisepublic boolean stepCount(int stepCount)
ProgressMonitor
This method is guaranteed to be invoked once before any invocation
of ProgressMonitor.step(int)
. Therefore the simplest sequence of invocations is:
start stepCount step step ... step stop
Note that in the above example, ProgressMonitor.message(java.lang.String, com.xmlmind.util.Console.MessageType)
is never invoked.
stepCount
in interface ProgressMonitor
stepCount
- total numbers of steps comprising the lengthy task.
This number is computed once for all. A negative value means that this
number cannot be determined.false
if this monitor wants to cancel the lengthy
task; true
otherwisepublic boolean step(int step)
ProgressMonitor
step
in interface ProgressMonitor
step
- current step. First step is step 0. Last step is step
stepCount-1, when stepCount is strictly positive.false
if this monitor wants to cancel the lengthy
task; true
otherwiseprotected String stepMessage(int step)
public void stop()
ProgressMonitor
This method is guaranteed to be invoked once when ProgressMonitor.start()
has
also been invoked. No other method will be invoked after that.
stop
in interface ProgressMonitor