com.lgc.wsh.util
Class LogMonitor

java.lang.Object
  extended by com.lgc.wsh.util.LogMonitor
All Implemented Interfaces:
Monitor

public class LogMonitor
extends java.lang.Object
implements Monitor

Report progress to default Logger


Field Summary
 
Fields inherited from interface com.lgc.wsh.util.Monitor
NULL_MONITOR
 
Constructor Summary
LogMonitor(java.lang.String prefix, java.util.logging.Logger logger)
          Progress will be reported to this Logger.
 
Method Summary
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.
static void main(java.lang.String[] argv)
          run tests
 void report(double fraction)
          This method will be called with the current fraction of work done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogMonitor

public LogMonitor(java.lang.String prefix,
                  java.util.logging.Logger logger)
Progress will be reported to this Logger.

Parameters:
prefix - Prefix this string to every report.
logger - Send to this Logger. If null, then check arguments but do nothing.
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 interface Monitor
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.

Specified by:
report in interface Monitor
Parameters:
fraction - Fraction of work done so far, from 0 to 1. This value must equal or exceed all values previously passed to this method or to initReport.

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