Package wsh.util
Class LogMonitor
- java.lang.Object
-
- wsh.util.LogMonitor
-
-
Field Summary
-
Fields inherited from interface wsh.util.Monitor
NULL_MONITOR
-
-
Constructor Summary
Constructors Constructor Description LogMonitor(java.lang.String prefix, java.util.logging.Logger logger)Progress will be reported to this Logger.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Interrupt any further work.static java.lang.StringgetProgressReport(long startTime, long currentTime, double fraction, double initFraction)Get a user-viewable String describing the progress and completion time.voidinitReport(double initFraction)Initialize the fraction of the work that was completed when the process started.booleanisCanceled()If true, then any further progress should be cancelled.static voidmain(java.lang.String[] argv)run testsvoidreport(double fraction)This method will be called with the current fraction of work done.
-
-
-
Method Detail
-
initReport
public void initReport(double initFraction)
Description copied from interface:MonitorInitialize the fraction of the work that was completed when the process started. If not called, then assumed to be 0.- Specified by:
initReportin interfaceMonitor- Parameters:
initFraction- Fraction of work done when process started, from 0 to 1.
-
report
public void report(double fraction)
Description copied from interface:MonitorThis method will be called with the current fraction of work done. Values range from 0 at the beginning to 1 when all work is done.
-
isCanceled
public boolean isCanceled()
Description copied from interface:MonitorIf true, then any further progress should be cancelled.- Specified by:
isCanceledin interfaceMonitor- Returns:
- true, when any requested work should be interrupted. False, if progress is expected to run to completion.
-
cancel
public void cancel()
Interrupt any further work. Causes isCancelled() to return true.
-
getProgressReport
public static java.lang.String getProgressReport(long startTime, long currentTime, double fraction, double initFraction)Get a user-viewable String describing the progress and completion time.- Parameters:
startTime- Time in milliseconds when work began.currentTime- Current time in milliseconds.fraction- Current fraction of total progress, between 0 and 1.initFraction- Initial fraction of total progress, between 0 and 1, when work started.- Returns:
- Progress report as a string.
-
main
public static void main(java.lang.String[] argv) throws java.lang.Exceptionrun tests- Parameters:
argv- command line- Throws:
java.lang.Exception- test failures
-
-