Brought code into line with the new streaming world order.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1606 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-07-23 05:52:49 +00:00
parent 2330afc3cd
commit c3191b9170
42 changed files with 805 additions and 1232 deletions
@@ -1,14 +1,16 @@
//
// $Id: EntryUpdatedEvent.java,v 1.6 2002/04/18 00:31:26 mdb Exp $
// $Id: EntryUpdatedEvent.java,v 1.7 2002/07/23 05:52:48 mdb Exp $
package com.threerings.presents.dobj;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.Log;
import com.threerings.presents.dobj.io.EntryUtil;
/**
* An entry updated event is dispatched when an entry of a {@link DSet} is
@@ -17,11 +19,8 @@ import com.threerings.presents.dobj.io.EntryUtil;
*
* @see DObjectManager#postEvent
*/
public class EntryUpdatedEvent extends TypedEvent
public class EntryUpdatedEvent extends DEvent
{
/** The typed object code for this event. */
public static final short TYPE = TYPE_BASE + 10;
/**
* Constructs a new entry updated event on the specified target object
* for the specified set name and with the supplied updated entry.
@@ -31,17 +30,12 @@ public class EntryUpdatedEvent extends TypedEvent
* @param name the name of the attribute in which to update the
* specified entry.
* @param entry the entry to update.
* @param qualified whether or not the entry need be qualified with
* its class when serializing (true for heterogenous sets, false for
* homogenous sets).
*/
public EntryUpdatedEvent (int targetOid, String name, DSet.Entry entry,
boolean qualified)
public EntryUpdatedEvent (int targetOid, String name, DSet.Entry entry)
{
super(targetOid);
_name = name;
_entry = entry;
_qualified = qualified;
}
/**
@@ -77,18 +71,6 @@ public class EntryUpdatedEvent extends TypedEvent
{
DSet set = (DSet)target.getAttribute(_name);
// now that we have access to our target set, we can unflatten our
// entry (if need be)
if (_entry == null) {
try {
_entry = EntryUtil.unflatten(set, _bytes);
} catch (Exception e) {
Log.warning("Error unflattening entry " + this + ".");
Log.logStackTrace(e);
return false;
}
}
// update the entry
if (!set.update(_entry)) {
// complain if we didn't update anything
@@ -100,34 +82,26 @@ public class EntryUpdatedEvent extends TypedEvent
return true;
}
// documentation inherited
public short getType ()
{
return TYPE;
}
// documentation inherited
public void writeTo (DataOutputStream out)
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeTo(out);
super.writeObject(out);
out.writeUTF(_name);
EntryUtil.flatten(out, _entry, _qualified);
out.writeObject(_entry);
}
// documentation inherited
public void readFrom (DataInputStream in)
throws IOException
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readFrom(in);
super.readObject(in);
_name = in.readUTF();
// we read in the raw entry data now and decode it later when we
// have access to the object and the DSet instance that knows what
// type of entry we need to decode
int bcount = in.readInt();
_bytes = new byte[bcount];
in.readFully(_bytes, 0, bcount);
_entry = (DSet.Entry)in.readObject();
}
// documentation inherited
@@ -144,11 +118,10 @@ public class EntryUpdatedEvent extends TypedEvent
buf.append("ELUPD:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", entry=").append(_entry);
buf.append(", entry=");
StringUtil.toString(buf, _entry);
}
protected String _name;
protected byte[] _bytes;
protected DSet.Entry _entry;
protected boolean _qualified;
}