|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.api.statistics.DataTransferStatistics<S,T>
S - the source of data, where data is coming fromT - the target of data, where data is being transferred into.public class DataTransferStatistics<S,T>
A basic implementation of DataTransfer which collects statistics about a given data transfer process, and
provides easy to use methods to report the progress and timing of the process.
NotificationHandler| Constructor Summary | |
|---|---|
DataTransferStatistics()
Creates a new data transfer statistics object that doesn't notify the user of updates. |
|
DataTransferStatistics(long notificationInterval,
NotificationHandler<DataTransferStatistics<S,T>> handler)
Creates a new data transfer statistics object that notifies the user of updates at given intervals, and when the process completes. |
|
DataTransferStatistics(NotificationHandler<DataTransferStatistics<S,T>> notificationHandler)
Creates a new data transfer statistics object that notifies the user of updates. |
|
| Method Summary | |
|---|---|
void |
aborted(S source,
T target,
Exception error)
Notifies that the data transfer has been aborted. |
void |
completed(S source,
T target)
Notifies that a data transfer has been finalized. |
boolean |
equals(Object o)
|
Exception |
getAbortError()
Returns the exception, if any, that caused the interruption of data transfer process. |
double |
getAverageRate()
Returns the average transfer rate, in milliseconds. |
double |
getAverageRate(TimeUnit timeUnit)
Returns the average transfer rate, using a given TimeUnit |
long |
getEndTime()
Returns the data transfer end time, in milliseconds. |
String |
getEndTime(String dateMask)
Returns the data transfer end time, in milliseconds. |
String |
getEndTime(String dateMask,
String valueOnError)
Returns the data transfer end time, in milliseconds. |
String |
getFormattedAverageRate()
Returns a formatted String representing the average rate, per second, at which the data is being transferred
to the target |
String |
getFormattedAverageRate(NumberFormat format,
TimeUnit timeUnit,
String rateSymbol)
Returns a formatted String representing the average rate at which the data is being transferred to the target. |
String |
getFormattedRatePerSecond()
Returns a formatted String representing the approximate rate, per second, at which the data was being
transferred to the target during the previous second. |
String |
getFormattedRatePerSecond(NumberFormat format,
String rateSymbol)
Returns a formatted String representing the approximate rate at which the data was transferred
during the previous second. |
String |
getFormattedTotalSize()
Returns a formatted String representing the total size of the source to be transferred to the target,
if available. |
String |
getFormattedTotalSize(NumberFormat format,
String valueIfUnknown)
Returns a formatted String representing the total size of the source to be transferred to the target,
if available. |
String |
getFormattedTotalTransferredSoFar()
Returns a formatted String representing the amount size of data already to be transferred to the target |
String |
getFormattedTotalTransferredSoFar(NumberFormat format)
Returns a formatted String representing the amount size of data already to be transferred to the target |
String |
getFormattedTransferPercentage()
Returns the percentage of data already transferred, formatted a decimal number between 0% and 100% inclusive, or ?% if unknown |
String |
getFormattedTransferPercentage(NumberFormat format,
String valueIfUnknown)
Returns a formatted String representing the percentage of data already transferred |
double |
getRatePerSecond()
Returns the approximate transfer rate at which the data was transferred during the previous second. |
S |
getSource()
Returns the source of data |
long |
getStartTime()
Returns the data transfer start time, in milliseconds. |
String |
getStartTime(String dateMask)
Returns the data transfer start time, as a formatted date. |
String |
getStartTime(String dateMask,
String valueOnError)
Returns the data transfer start time, as a formatted date. |
T |
getTarget()
Returns the destination of the data transferred from the source. |
long |
getTimeElapsed()
Returns the number of milliseconds the data transfer took so far. |
double |
getTimeElapsed(TimeUnit timeUnit)
Returns how long the data transfer took so far, using a given time unit. |
double |
getTotalSize()
Returns the total size of the source to be transferred to the target, if available. |
double |
getTotalTransferredSoFar()
Returns the total amount transferred already. |
double |
getTransferPercentage()
Returns the percentage of data already transferred, (where 0.0 represents 0% and 1.0 represents 100%) |
String |
getUnitDescription()
Returns a description of the unit of data being transferred. |
long |
getUnitDivisor()
Returns the unit divisor currently in use. |
int |
hashCode()
|
boolean |
isAborted()
Returns a flag indicating whether the data transfer was aborted. |
boolean |
isRunning()
Returns a flag indicating whether the data transfer is running. |
boolean |
isStarted()
Returns a flag indicating whether the data transfer has been started. |
protected void |
setNotificationHandler(long notificationInterval,
NotificationHandler<DataTransferStatistics<S,T>> handler)
Associates a notification handler callback to receive updates from the data transfer operation at at most after a given amount of time has elapsed. |
protected void |
setNotificationHandler(NotificationHandler<DataTransferStatistics<S,T>> handler)
Associates a notification handler callback to receive updates from the data transfer operation |
void |
setUnit(String unitDescription)
Defines a description of the unit of data being transferred. |
void |
setUnit(String unitDescription,
long unitDivisor)
Defines a description of the unit of data being transferred and updates the unit divisor to amounts will be returned taking into account the division of the totals by the given divisor. |
void |
started(S source,
long totalSize,
T target)
Notifies a data transfer has been started. |
String |
toString()
|
void |
transferred(S source,
long transferred,
T target)
Notifies how much data has been transferred from source to target. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DataTransferStatistics()
public DataTransferStatistics(NotificationHandler<DataTransferStatistics<S,T>> notificationHandler)
notificationHandler - the notification callback that will receive updates as soon as the statistics are changed.
public DataTransferStatistics(long notificationInterval,
NotificationHandler<DataTransferStatistics<S,T>> handler)
notificationInterval - the minimum interval, in milliseconds, before notifying the provided callback of updates.handler - the notification callback that will receive updates as soon as the statistics
are changed.| Method Detail |
|---|
protected final void setNotificationHandler(NotificationHandler<DataTransferStatistics<S,T>> handler)
handler - the callback that will be used every time the data transfer statistics are updated
protected final void setNotificationHandler(long notificationInterval,
NotificationHandler<DataTransferStatistics<S,T>> handler)
notificationInterval - the minimum interval in milliseconds to wait before the next call to
NotificationHandler.notify(Object, boolean) should be performed.
Prevents excessive notifications.handler - the callback that will be used every time the data transfer statistics are updatedpublic final String getUnitDescription()
public final void setUnit(String unitDescription)
unitDescription - the description of what is being transferred
public void setUnit(String unitDescription,
long unitDivisor)
unitDivisor = 1024) or megabytes (unitDivisor = 1024*1024) for example.
unitDescription - the description of what unit of data is being transferredunitDivisor - the divisor to be applied over the totals accumulated by this class, so that the unitspublic final long getUnitDivisor()
unitDivisor = 1024) or megabytes (unitDivisor = 1024*1024) for example.
public final void started(S source,
long totalSize,
T target)
DataTransfer
started in interface DataTransfer<S,T>source - the source of datatotalSize - the total size of the data. The meaning of the
amount provided depends on the underlying implementation: this can be bytes, number of
records, etc. If -1, the total size is unknown ahead of time.target - the data target
public final void transferred(S source,
long transferred,
T target)
DataTransfer
transferred in interface DataTransfer<S,T>source - the source of datatransferred - the amount of data transferred since the last time this method was called. The meaning of the
amount provided depends on the underlying implementation: this can be bytes, number of
records, etc.target - the data target
public final void completed(S source,
T target)
DataTransfer
completed in interface DataTransfer<S,T>source - the source of datatarget - the data target
public final void aborted(S source,
T target,
Exception error)
DataTransfer
aborted in interface DataTransfer<S,T>source - the source of datatarget - the data targeterror - exception that caused the process abortion.public final double getAverageRate()
public final double getAverageRate(TimeUnit timeUnit)
TimeUnit
timeUnit - the time unit used to calculate the transfer rate.
public final long getTimeElapsed()
public final double getTimeElapsed(TimeUnit timeUnit)
timeUnit - the unit of time to use to represent the time elapsed.
public final double getTotalTransferredSoFar()
public final double getTotalSize()
public final long getStartTime()
public final String getStartTime(String dateMask,
String valueOnError)
dateMask - a date mask following the rules specified by SimpleDateFormatvalueOnError - a default value to be returned in case of errors generating the formatted date.
public final String getStartTime(String dateMask)
dateMask - a date mask following the rules specified by SimpleDateFormat
public final long getEndTime()
-1
-1 of the process is still running.
public final String getEndTime(String dateMask,
String valueOnError)
-1
dateMask - a date mask following the rules specified by SimpleDateFormatvalueOnError - a default value to be returned in case of errors generating the formatted date.
-1 of the process is still running.public final String getEndTime(String dateMask)
-1
dateMask - a date mask following the rules specified by SimpleDateFormat
-1 of the process is still running.public final double getTransferPercentage()
public final S getSource()
public final T getTarget()
public final Exception getAbortError()
public final boolean isStarted()
DataTransfer
isStarted in interface DataTransfer<S,T>public final boolean isRunning()
DataTransfer
isRunning in interface DataTransfer<S,T>public final boolean isAborted()
DataTransfer
isAborted in interface DataTransfer<S,T>public final boolean equals(Object o)
equals in class Objectpublic final int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
public String getFormattedTransferPercentage(NumberFormat format,
String valueIfUnknown)
String representing the percentage of data already transferred
format - the numeric format to use to represent the percentage.valueIfUnknown - the String to return if the percentage cannot be determined.
public String getFormattedTransferPercentage()
public final double getRatePerSecond()
public String getFormattedRatePerSecond(NumberFormat format,
String rateSymbol)
String representing the approximate rate at which the data was transferred
during the previous second.
format - the numeric format to use to represent the rate.rateSymbol - the symbol to be displayed after the rate
public String getFormattedRatePerSecond()
String representing the approximate rate, per second, at which the data was being
transferred to the target during the previous second.
public String getFormattedAverageRate(NumberFormat format,
TimeUnit timeUnit,
String rateSymbol)
String representing the average rate at which the data is being transferred to the target.
format - the numeric format to use to represent thea average rate.timeUnit - the unit of time to be used to calculate the average rate.rateSymbol - the symbol to be displayed after the rate
public String getFormattedAverageRate()
String representing the average rate, per second, at which the data is being transferred
to the target
public String getFormattedTotalTransferredSoFar(NumberFormat format)
String representing the amount size of data already to be transferred to the target
format - the numeric format to use to represent the amount.
public String getFormattedTotalTransferredSoFar()
String representing the amount size of data already to be transferred to the target
public String getFormattedTotalSize(NumberFormat format,
String valueIfUnknown)
String representing the total size of the source to be transferred to the target,
if available.
format - the numeric format to use to represent the total.valueIfUnknown - the String to return if the total size cannot be determined.
public String getFormattedTotalSize()
String representing the total size of the source to be transferred to the target,
if available.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||