Package com.mckoi.util
Class Stats
- java.lang.Object
-
- com.mckoi.util.Stats
-
public final class Stats extends java.lang.ObjectAn object that is used to store and update various stats.NOTE: This object is thread safe.
- Author:
- Tobias Downer
-
-
Constructor Summary
Constructors Constructor Description Stats()Constructs the object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int value, java.lang.String stat_name)Adds the given value to a stat property.voiddecrement(java.lang.String stat_name)Decrements a stat property.java.lang.Objectget(java.lang.String stat_name)Retrieves the current Object value of a stat property.voidincrement(java.lang.String stat_name)Increments a stat property.java.lang.String[]keyList()Return a String array of all stat keys sorted in order from lowest to highest.voidprintTo(java.io.PrintStream out)Outputs the stats to a print stream.voidresetSession()Resets all stats that start with "{session}" to 0.voidset(int value, java.lang.String stat_name)Sets the given stat name with the given value.java.lang.StringstatString(java.lang.String key)Returns a String representation of the stat with the given key name.java.lang.StringtoString()Returns a String that can be use to print out the values of all the stats.
-
-
-
Method Detail
-
resetSession
public void resetSession()
Resets all stats that start with "{session}" to 0. This should be called when we are collecting stats over a given session and a session has finished.
-
add
public void add(int value, java.lang.String stat_name)Adds the given value to a stat property.
-
increment
public void increment(java.lang.String stat_name)
Increments a stat property. eg. stats.increment("File Hits");
-
decrement
public void decrement(java.lang.String stat_name)
Decrements a stat property.
-
get
public java.lang.Object get(java.lang.String stat_name)
Retrieves the current Object value of a stat property. Returns null if the stat wasn't found.
-
set
public void set(int value, java.lang.String stat_name)Sets the given stat name with the given value.
-
keyList
public java.lang.String[] keyList()
Return a String array of all stat keys sorted in order from lowest to highest.
-
statString
public java.lang.String statString(java.lang.String key)
Returns a String representation of the stat with the given key name.
-
toString
public java.lang.String toString()
Returns a String that can be use to print out the values of all the stats.- Overrides:
toStringin classjava.lang.Object
-
printTo
public void printTo(java.io.PrintStream out)
Outputs the stats to a print stream.
-
-