Extracted the Bang stats system into reusable land. Too late for Yohoho, but

Whirled will benefit.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@251 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-03-20 17:23:18 +00:00
parent 6b2b9ecbbb
commit e6ab89f313
14 changed files with 1449 additions and 0 deletions
@@ -0,0 +1,75 @@
//
// $Id$
package com.threerings.stats.data;
import java.io.IOException;
import java.util.Arrays;
import com.samskivert.util.ArrayUtil;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* Used to track an integer array statistic.
*/
public class IntArrayStat extends Stat
{
/**
* Returns the value of this statistic.
*/
public int[] getValue ()
{
return _value;
}
/**
* Sets this statistic's value to the specified value.
*
* @return true if the stat was modified, false if not.
*/
public boolean setValue (int[] value)
{
if (!Arrays.equals(_value, value)) {
_value = value;
_modified = true;
return true;
}
return false;
}
/**
* Appends a value to this statistic.
*/
public void appendValue (int value)
{
_value = ArrayUtil.append(_value, value);
_modified = true;
}
@Override // documentation inherited
public String valueToString ()
{
return StringUtil.toString(_value);
}
@Override // documentation inherited
public void persistTo (ObjectOutputStream out, AuxDataSource aux)
throws IOException
{
out.writeObject(_value);
}
@Override // documentation inherited
public void unpersistFrom (ObjectInputStream in, AuxDataSource aux)
throws IOException, ClassNotFoundException
{
_value = (int[])in.readObject();
}
/** Contains the integer list value of this statistic. */
protected int[] _value = new int[0];
}