org.tranche.timeestimator
Class ContextualTimeEstimator

java.lang.Object
  extended by org.tranche.commons.Debuggable
      extended by org.tranche.timeestimator.TimeEstimator
          extended by org.tranche.timeestimator.ContextualTimeEstimator

public class ContextualTimeEstimator
extends TimeEstimator

Estimated remaining time depends on performance in last n seconds.

Subclass of TimeEstimator, falls back on TimeEstimator until first window completed.

Author:
Bryan Smith

Field Summary
protected static int HOUR
           
protected static int MINUTE
           
protected static int SECOND
           
 
Fields inherited from class org.tranche.timeestimator.TimeEstimator
bytesCompleted, currentTime, filesCompleted, startTime, totalBytes, totalFiles
 
Constructor Summary
ContextualTimeEstimator()
           
ContextualTimeEstimator(long bytesCompleted, long totalBytes, long totalFilesCompleted, long totalFiles)
           
 
Method Summary
 int getContextInterval()
          Returns the length of each context window used for estimating time remaining.
 long getHours()
          Get the number of hours the estimator has been running.
 long getMinutes()
          Get the number of minutes the estimator has been running.
 long getSeconds()
          Get the number of seconds the estimator has been running.
 void setContextInterval(int milliseconds)
          Set the sample context window duration for determining progress.
 void update(long totalBytesCompleted, long totalBytes, long totalFilesCompleted, long totalFiles)
          Submit new data to the time estimator.
 
Methods inherited from class org.tranche.timeestimator.TimeEstimator
addTotalBytes, addTotalFiles, getBytesDone, getFilesDone, getPercentDone, getStartTime, getTimeLeftString, getTimeRunning, getTotalBytes, getTotalFiles, subtractTotalBytes, subtractTotalFiles
 
Methods inherited from class org.tranche.commons.Debuggable
debugErr, debugErr, debugOut, isDebug, setDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECOND

protected static final int SECOND
See Also:
Constant Field Values

MINUTE

protected static final int MINUTE
See Also:
Constant Field Values

HOUR

protected static final int HOUR
See Also:
Constant Field Values
Constructor Detail

ContextualTimeEstimator

public ContextualTimeEstimator()

ContextualTimeEstimator

public ContextualTimeEstimator(long bytesCompleted,
                               long totalBytes,
                               long totalFilesCompleted,
                               long totalFiles)
Parameters:
bytesCompleted -
totalBytes -
Method Detail

update

public void update(long totalBytesCompleted,
                   long totalBytes,
                   long totalFilesCompleted,
                   long totalFiles)

Submit new data to the time estimator. Used to update the estimator.

Overrides:
update in class TimeEstimator
Parameters:
totalBytesCompleted -
totalBytes -

getHours

public long getHours()

Get the number of hours the estimator has been running.

Overrides:
getHours in class TimeEstimator
Returns:

getMinutes

public long getMinutes()

Get the number of minutes the estimator has been running.

Overrides:
getMinutes in class TimeEstimator
Returns:

getSeconds

public long getSeconds()

Get the number of seconds the estimator has been running.

Overrides:
getSeconds in class TimeEstimator
Returns:

getContextInterval

public int getContextInterval()

Returns the length of each context window used for estimating time remaining.

Returns:

setContextInterval

public void setContextInterval(int milliseconds)

Set the sample context window duration for determining progress. Every context window, data transfered is measured and used to estimate time remaining.

E.g., if set to 30 seconds, every 30 seconds a new performance measurement is completed and used to estimate the time remaining for the next 30 seconds.

Parameters:
milliseconds - The time in milliseconds of each window.


This code is free for use both commercially and non-commercially as stated in the project's license