com.threerings.stats.data
Class IntStat

java.lang.Object
  extended by com.threerings.stats.data.Stat
      extended by com.threerings.stats.data.IntStat
All Implemented Interfaces:
Streamable, DSet.Entry, Cloneable
Direct Known Subclasses:
MaxIntStat, MaxValueIntStat

public class IntStat
extends Stat

Used to track a single integer statistic.


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
Streamable.Closure
 
Field Summary
protected  int _value
          Contains the integer value of this statistic.
 
Fields inherited from class com.threerings.stats.data.Stat
_codeToType, _crc, _modCount, _modified, _type
 
Constructor Summary
IntStat()
           
 
Method Summary
 int getValue()
          Returns the value of this integer statistic.
 boolean increment(int delta)
          Increments this statistic by the specified delta value.
 void persistTo(ObjectOutputStream out, Stat.AuxDataSource aux)
          Serializes this instance for storage in the item database.
 boolean setValue(int value)
          Sets this statistic's value to the specified value.
 void unpersistFrom(ObjectInputStream in, Stat.AuxDataSource aux)
          Unserializes this item from data obtained from the item database.
 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, crc32, getCode, getKey, getModCount, getType, getType, initType, isModified, setModCount, setModified, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_value

protected int _value
Contains the integer value of this statistic.

Constructor Detail

IntStat

public IntStat()
Method Detail

getValue

public int getValue()
Returns the value of this integer statistic.


setValue

public boolean setValue(int value)
Sets this statistic's value to the specified value.

Returns:
true if the stat was modified, false if not.

increment

public boolean increment(int delta)
Increments this statistic by the specified delta value.

Returns:
true if the stat was modified, false if not.

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

persistTo

public void persistTo(ObjectOutputStream out,
                      Stat.AuxDataSource aux)
               throws IOException
Description copied from class: Stat
Serializes this instance for storage in the item database. Derived classes must override this method to implement persistence.

Specified by:
persistTo in class Stat
Throws:
IOException

unpersistFrom

public void unpersistFrom(ObjectInputStream in,
                          Stat.AuxDataSource aux)
                   throws IOException,
                          ClassNotFoundException
Description copied from class: Stat
Unserializes this item from data obtained from the item database. Derived classes must override this method to implement persistence.

Specified by:
unpersistFrom in class Stat
Throws:
IOException
ClassNotFoundException