Package com.mckoi.util
Class Stats
java.lang.Object
com.mckoi.util.Stats
An object that is used to store and update various stats.
NOTE: This object is thread safe.
- Author:
- Tobias Downer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given value to a stat property.void
Decrements a stat property.Retrieves the current Object value of a stat property.void
Increments a stat property.String[]
keyList()
Return a String array of all stat keys sorted in order from lowest to highest.void
printTo
(PrintStream out) Outputs the stats to a print stream.void
Resets all stats that start with "{session}" to 0.void
Sets the given stat name with the given value.statString
(String key) Returns a String representation of the stat with the given key name.toString()
Returns a String that can be use to print out the values of all the stats.
-
Constructor Details
-
Stats
public Stats()Constructs the object.
-
-
Method Details
-
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
Adds the given value to a stat property. -
increment
Increments a stat property. eg. stats.increment("File Hits"); -
decrement
Decrements a stat property. -
get
Retrieves the current Object value of a stat property. Returns null if the stat wasn't found. -
set
Sets the given stat name with the given value. -
keyList
Return a String array of all stat keys sorted in order from lowest to highest. -
statString
Returns a String representation of the stat with the given key name. -
toString
Returns a String that can be use to print out the values of all the stats. -
printTo
Outputs the stats to a print stream.
-