diff --git a/src/java/com/threerings/crowd/data/OccupantInfo.java b/src/java/com/threerings/crowd/data/OccupantInfo.java index 0bf2ad8f8..8746b79de 100644 --- a/src/java/com/threerings/crowd/data/OccupantInfo.java +++ b/src/java/com/threerings/crowd/data/OccupantInfo.java @@ -1,13 +1,10 @@ // -// $Id: OccupantInfo.java,v 1.6 2002/03/18 23:21:26 mdb Exp $ +// $Id: OccupantInfo.java,v 1.7 2002/04/17 22:19:40 mdb Exp $ package com.threerings.crowd.data; -import java.io.IOException; -import java.io.DataInputStream; -import java.io.DataOutputStream; - import com.threerings.presents.dobj.DSet; +import com.threerings.presents.io.SimpleStreamableObject; /** * The occupant info object contains all of the information about an @@ -26,8 +23,13 @@ import com.threerings.presents.dobj.DSet; * that if derived classes add non-primitive attributes, they are * responsible for adding the code to clone those attributes when a clone * is requested. + * + *

Note also that this class extends {@link SimpleStreamableObject} + * which means that public data members will automatically be serialized, + * but if any non-public or data members are added, code must be added to + * serialize them when this object is streamed. */ -public class OccupantInfo +public class OccupantInfo extends SimpleStreamableObject implements DSet.Entry, Cloneable { /** The body object id of this occupant (and our entry key). */ @@ -59,43 +61,4 @@ public class OccupantInfo throw new RuntimeException("WTF? " + cnse); } } - - // documentation inherited - public void writeTo (DataOutputStream out) - throws IOException - { - out.writeInt(bodyOid.intValue()); - out.writeUTF(username); - } - - // documentation inherited - public void readFrom (DataInputStream in) - throws IOException - { - bodyOid = new Integer(in.readInt()); - username = in.readUTF(); - } - - /** - * Called to generate a string representation of this occupant info - * object. This calls the overridable {@link #toString(StringBuffer)} - * to generate that representation in a derived class friendly manner. - */ - public String toString () - { - StringBuffer buf = new StringBuffer("["); - toString(buf); - return buf.append("]").toString(); - } - - /** - * Derived classes should override this and append their extra - * occupant info to the buffer. They should of course not to forget to - * call super. - */ - protected void toString (StringBuffer buf) - { - buf.append("boid=").append(bodyOid); - buf.append(", username=").append(username); - } } diff --git a/src/java/com/threerings/whirled/spot/data/SpotOccupantInfo.java b/src/java/com/threerings/whirled/spot/data/SpotOccupantInfo.java index 8a19213ae..43334bc6d 100644 --- a/src/java/com/threerings/whirled/spot/data/SpotOccupantInfo.java +++ b/src/java/com/threerings/whirled/spot/data/SpotOccupantInfo.java @@ -1,12 +1,8 @@ // -// $Id: SpotOccupantInfo.java,v 1.1 2001/12/14 00:12:32 mdb Exp $ +// $Id: SpotOccupantInfo.java,v 1.2 2002/04/17 22:19:40 mdb Exp $ package com.threerings.whirled.spot.data; -import java.io.IOException; -import java.io.DataInputStream; -import java.io.DataOutputStream; - import com.threerings.crowd.data.OccupantInfo; /** @@ -18,27 +14,4 @@ public class SpotOccupantInfo extends OccupantInfo /** The id of the location occupied by this user or -1 if they occupy * no location. */ public int locationId; - - // documentation inherited - public void writeTo (DataOutputStream out) - throws IOException - { - super.writeTo(out); - out.writeInt(locationId); - } - - // documentation inherited - public void readFrom (DataInputStream in) - throws IOException - { - super.readFrom(in); - locationId = in.readInt(); - } - - // documentation inherited - protected void toString (StringBuffer buf) - { - super.toString(buf); - buf.append(", locId=").append(locationId); - } }