public class BytesProgressWatcher
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
SECONDS_OF_HISTORY
The number of seconds worth of historical byte transfer information that will be
stored and used to calculate the recent transfer rate.
|
Constructor and Description |
---|
BytesProgressWatcher(long bytesToTransfer)
Construct a watcher for a transfer that will involve a given number of bytes.
|
Modifier and Type | Method and Description |
---|---|
static double |
calculateOverallBytesPerSecond(BytesProgressWatcher[] progressWatchers) |
static long |
calculateRecentByteRatePerSecond(BytesProgressWatcher[] progressWatchers) |
static long |
calculateRemainingTime(BytesProgressWatcher[] progressWatchers) |
protected void |
clearHistory()
Clears the history of transfer progress data.
|
long |
getBytesRemaining() |
long |
getBytesToTransfer() |
long |
getBytesTransferred() |
protected long |
getElapsedTimeMS() |
protected long |
getHistoricStartTimeMS() |
double |
getRecentByteRatePerSecond() |
long |
getRemainingTime() |
protected long |
getTotalBytesInAllTransfers() |
protected boolean |
isStarted() |
protected void |
removedFromHistory(java.lang.Long pSec,
java.lang.Long pBytes)
Called when transfer progress data is removed from history.
|
void |
resetWatcher()
Resets the byte count and timer variables for a watcher.
|
void |
setBytesToTransfer(long bytesToTransfer) |
static long |
sumBytesToTransfer(BytesProgressWatcher[] progressWatchers) |
static long |
sumBytesTransferred(BytesProgressWatcher[] progressWatchers) |
void |
updateBytesTransferred(long byteCount)
Notifies this watcher that bytes have been transferred.
|
public static final int SECONDS_OF_HISTORY
public BytesProgressWatcher(long bytesToTransfer)
bytesToTransfer
- the number of bytes that will be transferred, eg the size of a file being uploaded.public long getBytesToTransfer()
public void setBytesToTransfer(long bytesToTransfer)
public void resetWatcher()
updateBytesTransferred(long)
), or
when a transfer is restarted (eg due to transmission errors).public void updateBytesTransferred(long byteCount)
byteCount
- the number of bytes that have been transferred.protected void removedFromHistory(java.lang.Long pSec, java.lang.Long pBytes)
pSec
- pBytes
- protected void clearHistory()
public long getBytesTransferred()
public long getBytesRemaining()
public long getRemainingTime()
public double getRecentByteRatePerSecond()
SECONDS_OF_HISTORY
seconds before the current time.protected long getElapsedTimeMS()
protected long getTotalBytesInAllTransfers()
protected boolean isStarted()
protected long getHistoricStartTimeMS()
public static long sumBytesToTransfer(BytesProgressWatcher[] progressWatchers)
progressWatchers
- all the watchers involved in the same byte transfer operation.public static long sumBytesTransferred(BytesProgressWatcher[] progressWatchers)
progressWatchers
- all the watchers involved in the same byte transfer operation.public static long calculateRemainingTime(BytesProgressWatcher[] progressWatchers)
progressWatchers
- all the watchers involved in the same byte transfer operation.public static double calculateOverallBytesPerSecond(BytesProgressWatcher[] progressWatchers)
progressWatchers
- all the watchers involved in the same byte transfer operation.public static long calculateRecentByteRatePerSecond(BytesProgressWatcher[] progressWatchers)
progressWatchers
- all the watchers involved in the same byte transfer operation.SECONDS_OF_HISTORY
seconds).