com.threerings.stats.data
Class StringMapStat

java.lang.Object
  extended by com.threerings.stats.data.Stat
      extended by com.threerings.stats.data.StringMapStat
All Implemented Interfaces:
com.threerings.io.Streamable, com.threerings.presents.dobj.DSet.Entry, Cloneable
Direct Known Subclasses:
ByteByteStringMapStat

public abstract class StringMapStat
extends Stat

Used to track a statistic comprised of a set of strings that map to numeric counts.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.stats.data.Stat
Stat.AuxDataSource, Stat.Type
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Constructor Summary
StringMapStat()
           
 
Method Summary
 boolean containsKey(String key)
          Returns true if the specified key is contained in this map.
 int get(String key)
          Returns the value to which the specified key maps or zero if it is not contained in this map.
 boolean increment(String key, int amount)
          Adds the specified key value pair to this set, overwriting any existing mapping.
 boolean put(String key, int value)
          Adds the specified key value pair to this set, overwriting any existing mapping.
 String valueToString()
          Derived statistics must override this method and render their value to a string.
 
Methods inherited from class com.threerings.stats.data.Stat
clone, getCode, getKey, getModCount, getType, getType, initType, isModified, persistTo, setModCount, setModified, toString, unpersistFrom
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringMapStat

public StringMapStat()
Method Detail

containsKey

public boolean containsKey(String key)
Returns true if the specified key is contained in this map.


get

public int get(String key)
Returns the value to which the specified key maps or zero if it is not contained in this map.


put

public boolean put(String key,
                   int value)
Adds the specified key value pair to this set, overwriting any existing mapping.

Returns:
true if the stat's value was changed, false otherwise.

increment

public boolean increment(String key,
                         int amount)
Adds the specified key value pair to this set, overwriting any existing mapping.

Returns:
true if the stat's value was changed, false otherwise.

valueToString

public String valueToString()
Description copied from class: Stat
Derived statistics must override this method and render their value to a string. Used by Stat.toString() and to display the value in game.

Specified by:
valueToString in class Stat


Copyright © 2011. All Rights Reserved.