From 3c3146d3816b2cb5db69e26e33729480a5381939 Mon Sep 17 00:00:00 2001 From: Tom Conkling Date: Thu, 24 Jul 2008 19:49:13 +0000 Subject: [PATCH] fix IntSetStat so that it streams properly. i'm not able to test this code on my machine, so nate will test momentarily and we'll roll back if there are any issues. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@675 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../com/threerings/stats/data/IntSetStat.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/stats/data/IntSetStat.java b/src/java/com/threerings/stats/data/IntSetStat.java index c15912f9..a9379868 100644 --- a/src/java/com/threerings/stats/data/IntSetStat.java +++ b/src/java/com/threerings/stats/data/IntSetStat.java @@ -93,8 +93,37 @@ public class IntSetStat extends Stat return StringUtil.toString(_intSet); } + /** Writes our custom streamable fields. */ + @Override // from Stat + public void writeObject (ObjectOutputStream out) + throws IOException + { + super.writeObject(out); + + out.writeInt(_intSet.size()); + for (int val : _intSet) { + out.writeInt(val); + } + } + + /** Reads our custom streamable fields. */ + @Override // from Stat + public void readObject (ObjectInputStream in) + throws IOException, ClassNotFoundException + { + super.readObject(in); + + int setSize = in.readInt(); + _intSet = new ArrayIntSet(setSize); + for (int ii = 0; ii < setSize; ii++) { + _intSet.add(in.readInt()); + } + } + protected int _maxSize; - protected IntSet _intSet = new ArrayIntSet(); + + /** ArrayIntSet is not Streamable, so we implement writeObject() and readObject() ourselves. */ + protected transient IntSet _intSet = new ArrayIntSet(); protected static final int MAX_MAX_SIZE = 255;