Factored out code for events that all shared a name; removed

hand-serialization code for fields which are now handled automatically.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2078 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-12-20 23:29:04 +00:00
parent 70a79f48e9
commit ee9049fe3e
17 changed files with 85 additions and 539 deletions
@@ -1,16 +1,10 @@
//
// $Id: AttributeChangedEvent.java,v 1.13 2002/10/27 01:33:43 mdb Exp $
// $Id: AttributeChangedEvent.java,v 1.14 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import java.lang.reflect.Method;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An attribute changed event is dispatched when a single attribute of a
* distributed object has changed. It can also be constructed to request
@@ -18,7 +12,7 @@ import com.threerings.io.ObjectOutputStream;
*
* @see DObjectManager#postEvent
*/
public class AttributeChangedEvent extends DEvent
public class AttributeChangedEvent extends NamedEvent
{
/**
* Constructs a new attribute changed event on the specified target
@@ -34,8 +28,7 @@ public class AttributeChangedEvent extends DEvent
*/
public AttributeChangedEvent (int targetOid, String name, Object value)
{
super(targetOid);
_name = name;
super(targetOid, name);
_value = value;
}
@@ -47,14 +40,6 @@ public class AttributeChangedEvent extends DEvent
{
}
/**
* Returns the name of the attribute that has changed.
*/
public String getName ()
{
return _name;
}
/**
* Returns the new value of the attribute.
*/
@@ -130,28 +115,6 @@ public class AttributeChangedEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeObject(_value);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_value = in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -165,12 +128,10 @@ public class AttributeChangedEvent extends DEvent
{
buf.append("CHANGE:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", value=");
StringUtil.toString(buf, _value);
}
protected String _name;
protected Object _value;
protected transient Object _oldValue;
}
@@ -1,13 +1,8 @@
//
// $Id: AttributesChangedEvent.java,v 1.10 2002/07/23 05:52:48 mdb Exp $
// $Id: AttributesChangedEvent.java,v 1.11 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.samskivert.util.StringUtil;
/**
@@ -167,36 +162,6 @@ public class AttributesChangedEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeInt(_count);
for (int ii = 0; ii < _count; ii++) {
out.writeUTF(_names[ii]);
out.writeObject(_values[ii]);
}
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_count = in.readInt();
_names = new String[_count];
_values = new Object[_count];
for (int ii = 0; ii < _count; ii++) {
_names[ii] = in.readUTF();
_values[ii] = in.readObject();
}
}
protected void toString (StringBuffer buf)
{
buf.append("CHANGES:");
@@ -1,9 +1,8 @@
//
// $Id: CompoundEvent.java,v 1.6 2002/10/04 01:32:15 mdb Exp $
// $Id: CompoundEvent.java,v 1.7 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -127,26 +126,6 @@ public class CompoundEvent extends DEvent
return false;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeObject(_events);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_events = (StreamableArrayList)in.readObject();
}
/**
* Calls out to all of the participating dobjects, clearing their
* transaction reference.
@@ -1,5 +1,5 @@
//
// $Id: DSet.java,v 1.23 2002/12/13 02:07:27 mdb Exp $
// $Id: DSet.java,v 1.24 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
@@ -304,7 +304,7 @@ public class DSet
throws IOException
{
out.defaultWriteObject();
out.writeInt(_size);
int ecount = _entries.length;
for (int ii = 0; ii < ecount; ii++) {
if (_entries[ii] != null) {
@@ -320,7 +320,7 @@ public class DSet
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
_size = in.readInt();
_entries = new Entry[Math.max(_size, INITIAL_CAPACITY)];
for (int ii = 0; ii < _size; ii++) {
_entries[ii] = (Entry)in.readObject();
@@ -347,7 +347,7 @@ public class DSet
}
/** The entries of the set (in a sparse array). */
protected Entry[] _entries = new Entry[INITIAL_CAPACITY];
protected transient Entry[] _entries = new Entry[INITIAL_CAPACITY];
/** The number of entries in this set. */
protected int _size;
@@ -1,17 +1,13 @@
//
// $Id: ElementUpdatedEvent.java,v 1.3 2002/10/27 01:33:43 mdb Exp $
// $Id: ElementUpdatedEvent.java,v 1.4 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.Log;
/**
@@ -21,7 +17,7 @@ import com.threerings.presents.Log;
*
* @see DObjectManager#postEvent
*/
public class ElementUpdatedEvent extends DEvent
public class ElementUpdatedEvent extends NamedEvent
{
/**
* Constructs a new element updated event on the specified target
@@ -38,8 +34,7 @@ public class ElementUpdatedEvent extends DEvent
public ElementUpdatedEvent (
int targetOid, String name, Object value, int index)
{
super(targetOid);
_name = name;
super(targetOid, name);
_value = value;
_index = index;
}
@@ -52,14 +47,6 @@ public class ElementUpdatedEvent extends DEvent
{
}
/**
* Returns the name of the attribute that has changed.
*/
public String getName ()
{
return _name;
}
/**
* Returns the new value of the element.
*/
@@ -163,30 +150,6 @@ public class ElementUpdatedEvent extends DEvent
}
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeObject(_value);
out.writeInt(_index);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_value = in.readObject();
_index = in.readInt();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -200,13 +163,11 @@ public class ElementUpdatedEvent extends DEvent
{
buf.append("UPDATE:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", value=");
StringUtil.toString(buf, _value);
buf.append(", index=").append(_index);
}
protected String _name;
protected Object _value;
protected int _index;
protected transient Object _oldValue;
@@ -1,15 +1,10 @@
//
// $Id: EntryAddedEvent.java,v 1.8 2002/07/23 05:52:48 mdb Exp $
// $Id: EntryAddedEvent.java,v 1.9 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.Log;
/**
@@ -19,7 +14,7 @@ import com.threerings.presents.Log;
*
* @see DObjectManager#postEvent
*/
public class EntryAddedEvent extends DEvent
public class EntryAddedEvent extends NamedEvent
{
/**
* Constructs a new entry added event on the specified target object
@@ -33,8 +28,7 @@ public class EntryAddedEvent extends DEvent
*/
public EntryAddedEvent (int targetOid, String name, DSet.Entry entry)
{
super(targetOid);
_name = name;
super(targetOid, name);
_entry = entry;
}
@@ -46,15 +40,6 @@ public class EntryAddedEvent extends DEvent
{
}
/**
* Returns the name of the set attribute to which an entry has been
* added.
*/
public String getName ()
{
return _name;
}
/**
* Returns the entry that has been added.
*/
@@ -74,28 +59,6 @@ public class EntryAddedEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeObject(_entry);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_entry = (DSet.Entry)in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -109,11 +72,9 @@ public class EntryAddedEvent extends DEvent
{
buf.append("ELADD:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", entry=");
StringUtil.toString(buf, _entry);
}
protected String _name;
protected DSet.Entry _entry;
}
@@ -1,13 +1,8 @@
//
// $Id: EntryRemovedEvent.java,v 1.10 2002/11/12 20:37:52 mdb Exp $
// $Id: EntryRemovedEvent.java,v 1.11 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An entry removed event is dispatched when an entry is removed from a
* {@link DSet} attribute of a distributed object. It can also be
@@ -16,7 +11,7 @@ import com.threerings.io.ObjectOutputStream;
*
* @see DObjectManager#postEvent
*/
public class EntryRemovedEvent extends DEvent
public class EntryRemovedEvent extends NamedEvent
{
/**
* Constructs a new entry removed event on the specified target object
@@ -30,8 +25,7 @@ public class EntryRemovedEvent extends DEvent
*/
public EntryRemovedEvent (int targetOid, String name, Object key)
{
super(targetOid);
_name = name;
super(targetOid, name);
_key = key;
}
@@ -43,15 +37,6 @@ public class EntryRemovedEvent extends DEvent
{
}
/**
* Returns the name of the oid list attribute from which an oid has
* been removed.
*/
public String getName ()
{
return _name;
}
/**
* Returns the key that identifies the entry that has been removed.
*/
@@ -82,28 +67,6 @@ public class EntryRemovedEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeObject(_key);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_key = in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -117,11 +80,9 @@ public class EntryRemovedEvent extends DEvent
{
buf.append("ELREM:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", key=").append(_key);
}
protected String _name;
protected Object _key;
protected transient DSet.Entry _oldEntry;
}
@@ -1,15 +1,10 @@
//
// $Id: EntryUpdatedEvent.java,v 1.8 2002/10/27 01:33:43 mdb Exp $
// $Id: EntryUpdatedEvent.java,v 1.9 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.Log;
/**
@@ -19,7 +14,7 @@ import com.threerings.presents.Log;
*
* @see DObjectManager#postEvent
*/
public class EntryUpdatedEvent extends DEvent
public class EntryUpdatedEvent extends NamedEvent
{
/**
* Constructs a new entry updated event on the specified target object
@@ -33,8 +28,7 @@ public class EntryUpdatedEvent extends DEvent
*/
public EntryUpdatedEvent (int targetOid, String name, DSet.Entry entry)
{
super(targetOid);
_name = name;
super(targetOid, name);
_entry = entry;
}
@@ -46,15 +40,6 @@ public class EntryUpdatedEvent extends DEvent
{
}
/**
* Returns the name of the set attribute for which an entry has been
* updated.
*/
public String getName ()
{
return _name;
}
/**
* Returns the entry that has been updated.
*/
@@ -93,28 +78,6 @@ public class EntryUpdatedEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeObject(_entry);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_entry = (DSet.Entry)in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -128,12 +91,10 @@ public class EntryUpdatedEvent extends DEvent
{
buf.append("ELUPD:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", entry=");
StringUtil.toString(buf, _entry);
}
protected String _name;
protected DSet.Entry _entry;
protected transient DSet.Entry _oldEntry;
}
@@ -1,16 +1,10 @@
//
// $Id: InvocationNotificationEvent.java,v 1.1 2002/08/14 19:07:55 mdb Exp $
// $Id: InvocationNotificationEvent.java,v 1.2 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
/**
* Used to dispatch an invocation notification from the server to a
* client.
@@ -83,30 +77,6 @@ public class InvocationNotificationEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeShort(_receiverId);
out.writeByte(_methodId);
out.writeObject(_args);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_receiverId = in.readShort();
_methodId = in.readByte();
_args = (Object[])in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -1,16 +1,10 @@
//
// $Id: InvocationRequestEvent.java,v 1.1 2002/08/14 19:07:55 mdb Exp $
// $Id: InvocationRequestEvent.java,v 1.2 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
/**
* Used to dispatch an invocation request from the client to the server.
*
@@ -80,30 +74,6 @@ public class InvocationRequestEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeInt(_invCode);
out.writeByte(_methodId);
out.writeObject(_args);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_invCode = in.readInt();
_methodId = in.readByte();
_args = (Object[])in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -1,16 +1,10 @@
//
// $Id: InvocationResponseEvent.java,v 1.1 2002/08/14 19:07:55 mdb Exp $
// $Id: InvocationResponseEvent.java,v 1.2 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.Streamable;
/**
* Used to dispatch an invocation response from the server to the client.
*
@@ -80,30 +74,6 @@ public class InvocationResponseEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeShort(_requestId);
out.writeByte(_methodId);
out.writeObject(_args);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_requestId = in.readShort();
_methodId = in.readByte();
_args = (Object[])in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -1,16 +1,10 @@
//
// $Id: MessageEvent.java,v 1.9 2002/07/23 05:52:48 mdb Exp $
// $Id: MessageEvent.java,v 1.10 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import java.lang.reflect.Method;
import com.samskivert.util.StringUtil;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* A message event is used to dispatch a message to all subscribers of a
* distributed object without actually changing any of the fields of the
@@ -20,7 +14,7 @@ import com.threerings.io.ObjectOutputStream;
*
* @see DObjectManager#postEvent
*/
public class MessageEvent extends DEvent
public class MessageEvent extends NamedEvent
{
/**
* Constructs a new message event on the specified target object with
@@ -34,8 +28,7 @@ public class MessageEvent extends DEvent
*/
public MessageEvent (int targetOid, String name, Object[] args)
{
super(targetOid);
_name = name;
super(targetOid, name);
_args = args;
}
@@ -47,14 +40,6 @@ public class MessageEvent extends DEvent
{
}
/**
* Returns the name of the message.
*/
public String getName ()
{
return _name;
}
/**
* Returns the arguments to this message.
*/
@@ -83,28 +68,6 @@ public class MessageEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeObject(_args);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_args = (Object[])in.readObject();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -118,10 +81,8 @@ public class MessageEvent extends DEvent
{
buf.append("MSG:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", args=").append(StringUtil.toString(_args));
}
protected String _name;
protected Object[] _args;
}
@@ -0,0 +1,48 @@
//
// $Id: NamedEvent.java,v 1.1 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
/**
* A common parent class for all events that are associated with a name
* (in some cases a field name, in other cases just an identifying name).
*/
public abstract class NamedEvent extends DEvent
{
/**
* Constructs a new named event for the specified target object with
* the supplied lock name.
*
* @param targetOid the object id of the object in question.
* @param name the name of the lock to release.
*/
public NamedEvent (int targetOid, String name)
{
super(targetOid);
_name = name;
}
/**
* Constructs a blank instance of this event in preparation for
* unserialization from the network.
*/
public NamedEvent ()
{
}
/**
* Returns the name of the lock to release.
*/
public String getName ()
{
return _name;
}
protected void toString (StringBuffer buf)
{
super.toString(buf);
buf.append(", name=").append(_name);
}
protected String _name;
}
@@ -1,13 +1,8 @@
//
// $Id: ObjectAddedEvent.java,v 1.7 2002/07/23 05:52:48 mdb Exp $
// $Id: ObjectAddedEvent.java,v 1.8 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An object added event is dispatched when an object is added to an
* <code>OidList</code> attribute of a distributed object. It can also be
@@ -16,7 +11,7 @@ import com.threerings.io.ObjectOutputStream;
*
* @see DObjectManager#postEvent
*/
public class ObjectAddedEvent extends DEvent
public class ObjectAddedEvent extends NamedEvent
{
/**
* Constructs a new object added event on the specified target object
@@ -30,8 +25,7 @@ public class ObjectAddedEvent extends DEvent
*/
public ObjectAddedEvent (int targetOid, String name, int oid)
{
super(targetOid);
_name = name;
super(targetOid, name);
_oid = oid;
}
@@ -43,15 +37,6 @@ public class ObjectAddedEvent extends DEvent
{
}
/**
* Returns the name of the oid list attribute to which an oid has been
* added.
*/
public String getName ()
{
return _name;
}
/**
* Returns the oid that has been added.
*/
@@ -71,28 +56,6 @@ public class ObjectAddedEvent extends DEvent
return true;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeInt(_oid);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_oid = in.readInt();
}
// documentation inherited
protected void notifyListener (Object listener)
{
@@ -106,10 +69,8 @@ public class ObjectAddedEvent extends DEvent
{
buf.append("OBJADD:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", oid=").append(_oid);
}
protected String _name;
protected int _oid;
}
@@ -1,14 +1,8 @@
//
// $Id: ObjectDestroyedEvent.java,v 1.4 2002/07/23 05:52:48 mdb Exp $
// $Id: ObjectDestroyedEvent.java,v 1.5 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import java.lang.reflect.Method;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An object destroyed event is dispatched when an object has been removed
* from the distributed object system. It can also be constructed to
@@ -1,13 +1,8 @@
//
// $Id: ObjectRemovedEvent.java,v 1.7 2002/07/23 05:52:48 mdb Exp $
// $Id: ObjectRemovedEvent.java,v 1.8 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An object removed event is dispatched when an object is removed from an
* <code>OidList</code> attribute of a distributed object. It can also be
@@ -16,7 +11,7 @@ import com.threerings.io.ObjectOutputStream;
*
* @see DObjectManager#postEvent
*/
public class ObjectRemovedEvent extends DEvent
public class ObjectRemovedEvent extends NamedEvent
{
/**
* Constructs a new object removed event on the specified target
@@ -31,8 +26,7 @@ public class ObjectRemovedEvent extends DEvent
*/
public ObjectRemovedEvent (int targetOid, String name, int oid)
{
super(targetOid);
_name = name;
super(targetOid, name);
_oid = oid;
}
@@ -44,15 +38,6 @@ public class ObjectRemovedEvent extends DEvent
{
}
/**
* Returns the name of the oid list attribute from which an oid has
* been removed.
*/
public String getName ()
{
return _name;
}
/**
* Returns the oid that has been removed.
*/
@@ -80,37 +65,13 @@ public class ObjectRemovedEvent extends DEvent
}
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
out.writeInt(_oid);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
_oid = in.readInt();
}
// documentation inherited
protected void toString (StringBuffer buf)
{
buf.append("OBJREM:");
super.toString(buf);
buf.append(", name=").append(_name);
buf.append(", oid=").append(_oid);
}
protected String _name;
protected int _oid;
}
@@ -1,14 +1,8 @@
//
// $Id: ReleaseLockEvent.java,v 1.6 2002/07/23 05:52:48 mdb Exp $
// $Id: ReleaseLockEvent.java,v 1.7 2002/12/20 23:29:04 mdb Exp $
package com.threerings.presents.dobj;
import java.io.IOException;
import java.lang.reflect.Method;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* A release lock event is dispatched at the end of a chain of events to
* release a lock that is intended to prevent some application defined
@@ -20,7 +14,7 @@ import com.threerings.io.ObjectOutputStream;
*
* @see DObjectManager#postEvent
*/
public class ReleaseLockEvent extends DEvent
public class ReleaseLockEvent extends NamedEvent
{
/**
* Constructs a new release lock event for the specified target object
@@ -31,8 +25,7 @@ public class ReleaseLockEvent extends DEvent
*/
public ReleaseLockEvent (int targetOid, String name)
{
super(targetOid);
_name = name;
super(targetOid, name);
}
/**
@@ -43,14 +36,6 @@ public class ReleaseLockEvent extends DEvent
{
}
/**
* Returns the name of the lock to release.
*/
public String getName ()
{
return _name;
}
/**
* Applies this lock release to the object.
*/
@@ -63,32 +48,9 @@ public class ReleaseLockEvent extends DEvent
return false;
}
/**
* Writes our custom streamable fields.
*/
public void writeObject (ObjectOutputStream out)
throws IOException
{
super.writeObject(out);
out.writeUTF(_name);
}
/**
* Reads our custom streamable fields.
*/
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
super.readObject(in);
_name = in.readUTF();
}
protected void toString (StringBuffer buf)
{
buf.append("UNLOCK:");
super.toString(buf);
buf.append(", name=").append(_name);
}
protected String _name;
}