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 void
cancel()
Interrupt any further work.static java.lang.String
getProgressReport(long startTime, long currentTime, double fraction, double initFraction)
Get a user-viewable String describing the progress and completion time.void
initReport(double initFraction)
Initialize the fraction of the work that was completed when the process started.boolean
isCanceled()
If true, then any further progress should be cancelled.static void
main(java.lang.String[] argv)
run testsvoid
report(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:Monitor
Initialize the fraction of the work that was completed when the process started. If not called, then assumed to be 0.- Specified by:
initReport
in interfaceMonitor
- Parameters:
initFraction
- Fraction of work done when process started, from 0 to 1.
-
report
public void report(double fraction)
Description copied from interface:Monitor
This 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:Monitor
If true, then any further progress should be cancelled.- Specified by:
isCanceled
in 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.Exception
run tests- Parameters:
argv
- command line- Throws:
java.lang.Exception
- test failures
-
-