public class ProgressHandlerWithTotal extends ProgressHandler
This class provides functionality for tracking progress and logging progress updates with a given total count of elements. It supports scenarios where progress tracking and logging are needed during tasks such as batch processing or iterative operations.
FIXME: Currently, this class is unrelated to GUI progress handling classes. Consider merging functionality in the future.
Example usage with message to a Logger:
phwt = ProgressHandlerWithTotal(cTotal, 300, 500, 600)
loop ...
-- Handle an entry.
phwt.tickAndProgressToLog(log)
end
Example usage with custom progress display:
phwt = ProgressHandlerWithTotal(cTotal, 300, 500, 600)
loop ...
-- Handle an entry.
if phwt.tick() then
say 'Handled 'phwt.getCountHandled()' entries; 'L10n.formatDecimal(Double.valueOf(phwt.getPercent()), '0')'% done, estimated time to go 'L10n.formatTimespan(Long.valueOf(phwt.getTodoTime() * 1000), 'HH:mm:ss')'...'
end
Constructor and Description |
---|
ProgressHandlerWithTotal(long _countTotal)
Initializes a `ProgressHandlerWithTotal` instance.
|
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval) |
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval,
int _roundTo) |
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval,
int _roundTo,
int _maxUpdateDelay) |
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval,
int _roundTo,
int _maxUpdateDelay,
long _estimationBaseTotal) |
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval,
int _roundTo,
int _maxUpdateDelay,
long _estimationBaseTotal,
java.lang.String _defaultThingsDesc) |
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval,
int _roundTo,
int _maxUpdateDelay,
long _estimationBaseTotal,
java.lang.String _defaultThingsDesc,
org.apache.log4j.Logger _defaultLogger) |
ProgressHandlerWithTotal(long _countTotal,
int _updateInterval,
int _roundTo,
int _maxUpdateDelay,
long _estimationBaseTotal,
java.lang.String _defaultThingsDesc,
org.apache.log4j.Logger _defaultLogger,
java.lang.String _defaultLogPrefix) |
ProgressHandlerWithTotal(long _countTotal,
java.lang.String _defaultThingsDesc)
Initializes a `ProgressHandlerWithTotal` instance with a total count and a default description of the elements being handled,
using default values for update interval (15 seconds), roundTo (100 elements), maxUpdateInterval (20 seconds) and estimationBaseTotal (-1).
|
ProgressHandlerWithTotal(long _countTotal,
java.lang.String _defaultThingsDesc,
org.apache.log4j.Logger _defaultLogger) |
ProgressHandlerWithTotal(long _countTotal,
java.lang.String _defaultThingsDesc,
org.apache.log4j.Logger _defaultLogger,
java.lang.String _defaultLogPrefix) |
Modifier and Type | Method and Description |
---|---|
long |
getCountTotal() |
long |
getEstimationBaseHandled() |
long |
getEstimationBaseTotal() |
org.apache.log4j.Level |
getLogLevel()
Returns the current log level.
|
java.lang.String |
getMessage(java.lang.String thingsDesc)
Returns a standard progress message (FIXME in english only) with all the
info from the current state of this
ProgressHandler . |
java.lang.String |
getMessage(java.lang.String thingsDesc,
boolean forFinalResult) |
java.lang.String |
getMessage(java.lang.String thingsDesc,
boolean forFinalResult,
java.lang.String logPrefix) |
double |
getPercent() |
java.lang.String |
getPercentDefaultFormatted() |
long |
getTodoTime() |
void |
setCountTotal(long $1) |
void |
setEstimationBaseTotal(long $2) |
boolean |
tick()
Must be called for every handled element.
|
boolean |
tick(long incrementEstimationBase) |
finalResultToLog, finalResultToLog, finalResultToLog, finalResultToLog, finalResultToLog, finalResultToLog, finalResultToLog, getCountHandled, getDefaultLogger, getDefaultLogPrefix, getDefaultThingsDesc, getRunningTime, getStartedAt, isDone, printFinalResult, printFinalResult, printFinalResult, printFinalResult, printFinalResult, printProgress, printProgress, printProgress, printProgress, progressToLog, progressToLog, progressToLog, progressToLog, setCountHandled, setDefaultLogger, setDefaultLogPrefix, setDefaultThingsDesc, setLogLevel, tick, tickAndPrintProgress, tickAndPrintProgress, tickAndPrintProgress, tickAndPrintProgress, tickAndProgressToLog, tickAndProgressToLog, tickAndProgressToLog, tickAndProgressToLog
public ProgressHandlerWithTotal(long _countTotal)
_countTotal
- the total number of elements to be handled._updateInterval
- interval in which progress notifications should be given, in seconds (defaults to 15)._roundTo
- progress notifications are only given if the number of handled elements is a multiple of this (defaults to 100)._maxUpdateInterval
- maximum time in seconds to wait until a progress notification is shown; if this time has passed,
a notification will be given, no matter if a "_roundTo compatible value" is reached or not. This can
be used to ensure notifications are shown periodically even if progress is extremely slow. If 0,
this feature will be deactivated. Defaults to 20._estimationBaseTotal
- the total number that shall be used for calculating the estimated remaining time to complete. Defaults to -1._defaultThingsDesc
- a description of the elements being handled. Can be null._defaultLogger
- the default logger to output messages too; will be used by the output methods that can take a logger
as parameter if none is given; may be null_defaultLogPrefix
- a default prefix to prepend to log messages; will be used if no prefix argument is
given to the methods which can take one; may be nullpublic ProgressHandlerWithTotal(long _countTotal, int _updateInterval)
public ProgressHandlerWithTotal(long _countTotal, int _updateInterval, int _roundTo)
public ProgressHandlerWithTotal(long _countTotal, int _updateInterval, int _roundTo, int _maxUpdateDelay)
public ProgressHandlerWithTotal(long _countTotal, int _updateInterval, int _roundTo, int _maxUpdateDelay, long _estimationBaseTotal)
public ProgressHandlerWithTotal(long _countTotal, int _updateInterval, int _roundTo, int _maxUpdateDelay, long _estimationBaseTotal, java.lang.String _defaultThingsDesc)
public ProgressHandlerWithTotal(long _countTotal, int _updateInterval, int _roundTo, int _maxUpdateDelay, long _estimationBaseTotal, java.lang.String _defaultThingsDesc, org.apache.log4j.Logger _defaultLogger)
public ProgressHandlerWithTotal(long _countTotal, int _updateInterval, int _roundTo, int _maxUpdateDelay, long _estimationBaseTotal, java.lang.String _defaultThingsDesc, org.apache.log4j.Logger _defaultLogger, java.lang.String _defaultLogPrefix)
public ProgressHandlerWithTotal(long _countTotal, java.lang.String _defaultThingsDesc)
_countTotal
- the total number of elements to be handled._defaultThingsDesc
- a description of the elements being handled._defaultLogger
- the default logger to output messages too; will be used by the output methods that can take a logger
as parameter if none is given; may be nullpublic ProgressHandlerWithTotal(long _countTotal, java.lang.String _defaultThingsDesc, org.apache.log4j.Logger _defaultLogger)
public ProgressHandlerWithTotal(long _countTotal, java.lang.String _defaultThingsDesc, org.apache.log4j.Logger _defaultLogger, java.lang.String _defaultLogPrefix)
public long getEstimationBaseHandled()
public boolean tick()
ProgressHandler
tick
in class ProgressHandler
public boolean tick(long incrementEstimationBase)
public org.apache.log4j.Level getLogLevel()
ProgressHandler
getLogLevel
in class ProgressHandler
public java.lang.String getMessage(java.lang.String thingsDesc)
ProgressHandler
ProgressHandler
.getMessage
in class ProgressHandler
thingsDesc
- a string with the name of the "things" currently
handled; used in the messageProgressHandler
public java.lang.String getMessage(java.lang.String thingsDesc, boolean forFinalResult)
getMessage
in class ProgressHandler
public java.lang.String getMessage(java.lang.String thingsDesc, boolean forFinalResult, java.lang.String logPrefix)
getMessage
in class ProgressHandler
public java.lang.String getPercentDefaultFormatted()
public double getPercent()
public long getTodoTime()
public long getCountTotal()
public void setCountTotal(long $1)
public long getEstimationBaseTotal()
public void setEstimationBaseTotal(long $2)
Copyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.