Package com.mckoi.util

## Class Stats

- java.lang.Object
- - com.mckoi.util.Stats

    public final class Stats
    extends java.lang.Object

An object that is used to store and update various stats.

NOTE: This object is thread safe.

Author:
  Tobias Downer

### Constructor Summary

Constructors
`Stats()` Constructs the object.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `add​(int value, java.lang.String stat_name)` Adds the given value to a stat property.
`void` `decrement​(java.lang.String stat_name)` Decrements a stat property.
`java.lang.Object` `get​(java.lang.String stat_name)` Retrieves the current Object value of a stat property.
`void` `increment​(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.
`void` `printTo​(java.io.PrintStream out)` Outputs the stats to a print stream.
`void` `resetSession()` Resets all stats that start with "{session}" to 0.
`void` `set​(int value, java.lang.String stat_name)` Sets the given stat name with the given value.
`java.lang.String` `statString​(java.lang.String key)` Returns a String representation of the stat with the given key name.
`java.lang.String` `toString()` Returns a String that can be use to print out the values of all the stats.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### Stats

    public Stats()

Constructs the object.

### 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:
  `toString` in class `java.lang.Object`

#### printTo

    public void printTo​(java.io.PrintStream out)

Outputs the stats to a print stream.