simnet
Class Statistics

java.lang.Object
  extended bysimnet.Statistics
Direct Known Subclasses:
LinkStatistics, NodeStatistics, ServerSocketStatistics, UDPStatistics

public abstract class Statistics
extends java.lang.Object

General class for keeping statistics.


Nested Class Summary
protected  class Statistics.StatisticData
          Inner class for storage of individual statistics
 
Field Summary
private  java.util.Vector stats
          The statistics' data.
 
Constructor Summary
Statistics()
           
 
Method Summary
 void clear()
          Reset all of the statistics to zero.
protected  int defineStatistic(java.lang.String name)
          This method should be called from the constructor of subclasses to define statistics.
protected abstract  java.lang.String getHeader()
          Return the header to use for the toString method.
 java.lang.String getStatisticString(int type)
          Public version of the getStatisticString method.
protected abstract  java.lang.String getStatisticString(Statistics.StatisticData sd)
          Return a string for a particular statistic.
 void record(int type, double extra)
          Record the specified values
 void record(int type, int stat)
           
 void record(int type, int stat, double extra)
           
protected  void recordAction(Statistics.StatisticData sd, int stat, double extra)
          Update the statistics data object with the new values to record
 java.lang.String toString()
          Return a string representation of this statistics object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stats

private java.util.Vector stats
The statistics' data.

Constructor Detail

Statistics

public Statistics()
Method Detail

defineStatistic

protected final int defineStatistic(java.lang.String name)
This method should be called from the constructor of subclasses to define statistics.


record

public final void record(int type,
                         double extra)
Record the specified values


record

public final void record(int type,
                         int stat)

record

public final void record(int type,
                         int stat,
                         double extra)

recordAction

protected void recordAction(Statistics.StatisticData sd,
                            int stat,
                            double extra)
Update the statistics data object with the new values to record


clear

public final void clear()
                 throws java.lang.IllegalStateException
Reset all of the statistics to zero.

Throws:
java.lang.IllegalStateException

getHeader

protected abstract java.lang.String getHeader()
Return the header to use for the toString method. All subclasses must implement this method.


getStatisticString

protected abstract java.lang.String getStatisticString(Statistics.StatisticData sd)
Return a string for a particular statistic. All subclasses must implement this method.


getStatisticString

public final java.lang.String getStatisticString(int type)
Public version of the getStatisticString method.


toString

public final java.lang.String toString()
Return a string representation of this statistics object.