public class ProgressHandler
extends java.lang.Object
FIXME Currently has nothing to do with the GUI progress classes; maybe the functionality could be merged later.
Example code with message to a Logger:
ph = ProgressHandler( 300, 500, 600 )
loop ...
-- Handle an entry.
ph.tickAndProgressToLog( log )
end
Example code with own progress display:
ph = ProgressHandler( 300, 500, 600 )
loop ...
-- Handle an entry.
if ph.tick() then
say 'Handled 'getCountHandled()' entries'; running time 'L10n.formatTimespan( Long.valueOf( getRunningTime() * 1000 ), 'HH:mm:ss' )'...'
end
Constructor and Description |
---|
ProgressHandler() |
ProgressHandler(int _updateInterval) |
ProgressHandler(int _updateInterval,
int _roundTo) |
ProgressHandler(int _updateInterval,
int _roundTo,
int _maxUpdateDelay) |
ProgressHandler(int _updateInterval,
int _roundTo,
int _maxUpdateDelay,
org.apache.log4j.Level _logLevel) |
Modifier and Type | Method and Description |
---|---|
void |
finalResultToLog(org.apache.log4j.Logger log)
Convenience method that outputs a standard final result message (from
getMessage() ) to the given Logger (Level INFO). |
void |
finalResultToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc) |
void |
finalResultToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc,
java.lang.String logPrefix) |
void |
finalResultToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc,
java.lang.String logPrefix,
boolean evenWhenNoPreviousOutput) |
long |
getCountHandled()
Returns the current count handled.
|
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) |
long |
getRunningTime() |
java.util.Date |
getStartedAt() |
boolean |
isDone() |
void |
printFinalResult()
Convenience method that outputs a standard final result message (from
getMessage() ) to the given PrintStream . |
void |
printFinalResult(java.io.PrintStream ps) |
void |
printFinalResult(java.io.PrintStream ps,
java.lang.String thingsDesc) |
void |
printFinalResult(java.io.PrintStream ps,
java.lang.String thingsDesc,
java.lang.String printPrefix) |
void |
printFinalResult(java.io.PrintStream ps,
java.lang.String thingsDesc,
java.lang.String printPrefix,
boolean evenWhenNoPreviousOutput) |
boolean |
printProgress()
Convenience method that outputs a standard message (from
getMessage() )
to the given PrintStream when tick()
says to do so. |
boolean |
printProgress(java.io.PrintStream ps) |
boolean |
printProgress(java.io.PrintStream ps,
java.lang.String thingsDesc) |
boolean |
printProgress(java.io.PrintStream ps,
java.lang.String thingsDesc,
java.lang.String printPrefix) |
boolean |
progressToLog(org.apache.log4j.Logger log)
Convenience method that outputs a standard message (from
getMessage() )
to the given Logger (Level is current LogLevel) when tick()
says to do so. |
boolean |
progressToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc) |
boolean |
progressToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc,
java.lang.String logPrefix) |
void |
setCountHandled(long l)
Updates count handled to the passed value.
|
void |
setLogLevel(org.apache.log4j.Level l)
Sets the log level to the passed Level.
|
void |
start()
Must be called when the calculation or whatever for which progress info
should be shown starts.
|
boolean |
tick()
Must be called for every handled element.
|
boolean |
tick(boolean countUp) |
boolean |
tickAndPrintProgress()
Convenience method that does a
tick() and outputs a standard
message (from getMessage() ) to the given PrintStream
when tick() says to do so. |
boolean |
tickAndPrintProgress(java.io.PrintStream ps) |
boolean |
tickAndPrintProgress(java.io.PrintStream ps,
java.lang.String thingsDesc) |
boolean |
tickAndPrintProgress(java.io.PrintStream ps,
java.lang.String thingsDesc,
java.lang.String printPrefix) |
boolean |
tickAndProgressToLog(org.apache.log4j.Logger log)
Convenience method that does a
tick() and outputs a standard
message (from getMessage() ) to the given Logger
(Level INFO) when tick() says to do so. |
boolean |
tickAndProgressToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc) |
boolean |
tickAndProgressToLog(org.apache.log4j.Logger log,
java.lang.String thingsDesc,
java.lang.String logPrefix) |
public ProgressHandler()
_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 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
assure notifications are shown periodically even if progress is extremly
slow. If 0 this feature will be deactivated. Defaults to 20.public ProgressHandler(int _updateInterval)
public ProgressHandler(int _updateInterval, int _roundTo)
public ProgressHandler(int _updateInterval, int _roundTo, int _maxUpdateDelay)
public ProgressHandler(int _updateInterval, int _roundTo, int _maxUpdateDelay, org.apache.log4j.Level _logLevel)
public void start()
public org.apache.log4j.Level getLogLevel()
public void setLogLevel(org.apache.log4j.Level l)
public long getCountHandled()
public void setCountHandled(long l)
public boolean tick()
public boolean tick(boolean countUp)
public boolean tickAndProgressToLog(org.apache.log4j.Logger log)
tick()
and outputs a standard
message (from getMessage()
) to the given Logger
(Level INFO) when tick()
says to do so.log
- the Logger
to output toothingsDesc
- an (optional, defaults to null) string with the name of
the "things" currently handled; used in the message and defaults to
just "entries" when null_logPrefix
- will be prepended to the default log output if not nullpublic boolean tickAndProgressToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc)
public boolean tickAndProgressToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc, java.lang.String logPrefix)
public boolean tickAndPrintProgress()
tick()
and outputs a standard
message (from getMessage()
) to the given PrintStream
when tick()
says to do so.ps
- the PrintStream
to output toothingsDesc
- an (optional, defaults to null) string with the name of
the "things" currently handled; used in the message and defaults to
just "entries" when nullprintPrefix
- will be prepended to the default print output if not nullpublic boolean tickAndPrintProgress(java.io.PrintStream ps)
public boolean tickAndPrintProgress(java.io.PrintStream ps, java.lang.String thingsDesc)
public boolean tickAndPrintProgress(java.io.PrintStream ps, java.lang.String thingsDesc, java.lang.String printPrefix)
public boolean progressToLog(org.apache.log4j.Logger log)
getMessage()
)
to the given Logger
(Level is current LogLevel) when tick()
says to do so.log
- the Logger
to output toothingsDesc
- an (optional, defaults to null) string with the name of
the "things" currently handled; used in the message and defaults to
just "entries" when null_logPrefix
- will be prepended to the default log output if not nullpublic boolean progressToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc)
public boolean progressToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc, java.lang.String logPrefix)
public boolean printProgress()
getMessage()
)
to the given PrintStream
when tick()
says to do so.ps
- the thingsDesc
- an (optional, defaults to null) string with the name of
the "things" currently handled; used in the message and defaults to
just "entries" when nullprintPrefix
- will be prepended to the default print output if not nullpublic boolean printProgress(java.io.PrintStream ps)
public boolean printProgress(java.io.PrintStream ps, java.lang.String thingsDesc)
public boolean printProgress(java.io.PrintStream ps, java.lang.String thingsDesc, java.lang.String printPrefix)
public void finalResultToLog(org.apache.log4j.Logger log)
getMessage()
) to the given Logger
(Level INFO).log
- the Logger
to output toothingsDesc
- an (optional, defaults to null) string with the name of
the "things" currently handled; used in the message and defaults to
just "entries" when null_logPrefix
- will be prepended to the default log output if not nullpublic void finalResultToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc)
public void finalResultToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc, java.lang.String logPrefix)
public void finalResultToLog(org.apache.log4j.Logger log, java.lang.String thingsDesc, java.lang.String logPrefix, boolean evenWhenNoPreviousOutput)
public void printFinalResult()
getMessage()
) to the given PrintStream
.ps
- the PrintStream
to output toothingsDesc
- an (optional, defaults to null) string with the name of
the "things" currently handled; used in the message and defaults to
just "entries" when nullprintPrefix
- will be prepended to the default print output if not nullpublic void printFinalResult(java.io.PrintStream ps)
public void printFinalResult(java.io.PrintStream ps, java.lang.String thingsDesc)
public void printFinalResult(java.io.PrintStream ps, java.lang.String thingsDesc, java.lang.String printPrefix)
public void printFinalResult(java.io.PrintStream ps, java.lang.String thingsDesc, java.lang.String printPrefix, boolean evenWhenNoPreviousOutput)
public java.lang.String getMessage(java.lang.String thingsDesc)
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)
public java.lang.String getMessage(java.lang.String thingsDesc, boolean forFinalResult, java.lang.String logPrefix)
public java.util.Date getStartedAt()
public long getRunningTime()
public boolean isDone()
Copyright © 2000-2024 OAshi S.à r.l. All Rights Reserved.