LimeWire Consolidated API

org.limewire.statistic
Class AbstractKilobytesStatistic

java.lang.Object
  extended by org.limewire.statistic.AbstractStatistic
      extended by org.limewire.statistic.AbstractKilobytesStatistic
All Implemented Interfaces:
Inspectable, Statistic
Direct Known Subclasses:
BasicKilobytesStatistic

public abstract class AbstractKilobytesStatistic
extends AbstractStatistic

Abstract class for recording data in kilobytes instead of bytes. In order to preserve data accuracy, data is stored in bytes and converted to kilobytes; otherwise, data would be lost.

A sample, aka a cycle of data, is all the data collected between calls to AbstractStatistic.storeCurrentStat(). Therefore, the getMax() is the largest sample and the getAverage() is the total size / the number of samples.

An example of using AbstractKilobytesStatistic:

    class Stats extends AbstractKilobytesStatistic {}
    Statistic s = new Stats();

    for(int i = 0; i < 1024; i++)
        s.incrementStat();
    s.storeCurrentStat();

    s.addData(2 * 1024);
    s.storeCurrentStat();

    s.addData(3 * 1024);
    s.storeCurrentStat();

    s.addData(4 * 1024);
    s.storeCurrentStat();

    s.addData(5 * 1024);
    s.storeCurrentStat();

    System.out.println("Total: " + s.getTotal());
    System.out.println("Max: " + s.getMax());
    System.out.println("Average: " + s.getAverage());

    Output:
        Total: 15.0
        Max: 5.0
        Average: 3.0
 


Field Summary
 
Fields inherited from class org.limewire.statistic.AbstractStatistic
_buffer, _current, _max, _total, _totalStatsRecorded
 
Fields inherited from interface org.limewire.statistic.Statistic
HISTORY_LENGTH
 
Constructor Summary
AbstractKilobytesStatistic()
           
 
Method Summary
 double getAverage()
          Overridden to report the average for this statistic in kilobyes.
 double getMax()
          Overridden to report the maximum for this statistic in kilobyes.
 double getTotal()
          Overridden to report the total for this statistic in kilobytes.
 
Methods inherited from class org.limewire.statistic.AbstractStatistic
addData, clearData, getCurrent, getLastStored, getStatHistory, incrementStat, initializeBuffer, inspect, storeCurrentStat, storeStats
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractKilobytesStatistic

public AbstractKilobytesStatistic()
Method Detail

getAverage

public double getAverage()
Overridden to report the average for this statistic in kilobyes.

Specified by:
getAverage in interface Statistic
Overrides:
getAverage in class AbstractStatistic
Returns:
the average for this statistic in kilobytes per unit of measurement (KB/s)

getMax

public double getMax()
Overridden to report the maximum for this statistic in kilobyes.

Specified by:
getMax in interface Statistic
Overrides:
getMax in class AbstractStatistic
Returns:
the maximum for a recorded time period for this statistic in kilobytes

getTotal

public double getTotal()
Overridden to report the total for this statistic in kilobytes.

Specified by:
getTotal in interface Statistic
Overrides:
getTotal in class AbstractStatistic
Returns:
the total for this statistic in kilobytes

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.