diff --git a/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java b/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java index a3f629893..00068f099 100644 --- a/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java +++ b/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java @@ -1,5 +1,5 @@ // -// $Id: AttributeChangedEvent.java,v 1.7 2001/08/02 04:49:08 mdb Exp $ +// $Id: AttributeChangedEvent.java,v 1.8 2001/08/04 00:32:11 mdb Exp $ package com.threerings.cocktail.cher.dobj; @@ -142,10 +142,12 @@ public class AttributeChangedEvent extends TypedEvent _value = ValueMarshaller.readFrom(in); } - public String toString () + protected void toString (StringBuffer buf) { - return "[CHANGE:targetOid=" + _toid + ", name=" + _name + - ", value=" + _value + "]"; + buf.append("CHANGE:"); + super.toString(buf); + buf.append(", name=").append(_name); + buf.append(", value=").append(_value); } protected String _name; diff --git a/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java b/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java index 2911086e3..c266cc00c 100644 --- a/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java +++ b/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java @@ -1,5 +1,5 @@ // -// $Id: AttributesChangedEvent.java,v 1.6 2001/08/02 04:49:08 mdb Exp $ +// $Id: AttributesChangedEvent.java,v 1.7 2001/08/04 00:32:11 mdb Exp $ package com.threerings.cocktail.cher.dobj; @@ -7,6 +7,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import com.samskivert.util.StringUtil; import com.threerings.cocktail.cher.dobj.io.ValueMarshaller; /** @@ -198,6 +199,14 @@ public class AttributesChangedEvent extends TypedEvent } } + protected void toString (StringBuffer buf) + { + buf.append("CHANGES:"); + super.toString(buf); + buf.append(", names=").append(StringUtil.toString(_names)); + buf.append(", values=").append(StringUtil.toString(_values)); + } + protected int _count; protected String[] _names; protected Object[] _values; diff --git a/src/java/com/threerings/presents/dobj/DEvent.java b/src/java/com/threerings/presents/dobj/DEvent.java index 4ba5e5d81..e2f8ce13d 100644 --- a/src/java/com/threerings/presents/dobj/DEvent.java +++ b/src/java/com/threerings/presents/dobj/DEvent.java @@ -1,5 +1,5 @@ // -// $Id: DEvent.java,v 1.4 2001/07/19 18:08:20 mdb Exp $ +// $Id: DEvent.java,v 1.5 2001/08/04 00:32:11 mdb Exp $ package com.threerings.cocktail.cher.dobj; @@ -63,6 +63,29 @@ public abstract class DEvent _toid = targetOid; } + /** + * Constructs and returns a string representation of this event. + */ + public String toString () + { + StringBuffer buf = new StringBuffer(); + buf.append("["); + toString(buf); + buf.append("]"); + return buf.toString(); + } + + /** + * This should be overridden by derived classes (which should be sure + * to call super.toString()) to append the derived class + * specific event information to the string buffer. + */ + protected void toString (StringBuffer buf) + { + buf.append("targetOid=").append(_toid); + buf.append(", sourceOid=").append(_soid); + } + /** The oid of the object that is the target of this event. */ protected int _toid; diff --git a/src/java/com/threerings/presents/dobj/MessageEvent.java b/src/java/com/threerings/presents/dobj/MessageEvent.java index 1da701957..ccc7dc427 100644 --- a/src/java/com/threerings/presents/dobj/MessageEvent.java +++ b/src/java/com/threerings/presents/dobj/MessageEvent.java @@ -1,5 +1,5 @@ // -// $Id: MessageEvent.java,v 1.3 2001/08/02 04:49:08 mdb Exp $ +// $Id: MessageEvent.java,v 1.4 2001/08/04 00:32:11 mdb Exp $ package com.threerings.cocktail.cher.dobj; @@ -110,10 +110,12 @@ public class MessageEvent extends TypedEvent } } - public String toString () + protected void toString (StringBuffer buf) { - return "[MSG:targetOid=" + _toid + ", name=" + _name + - ", args=" + StringUtil.toString(_args) + "]"; + buf.append("MSG:"); + super.toString(buf); + buf.append(", name=").append(_name); + buf.append(", args=").append(StringUtil.toString(_args)); } protected String _name; diff --git a/src/java/com/threerings/presents/dobj/ObjectAddedEvent.java b/src/java/com/threerings/presents/dobj/ObjectAddedEvent.java index b86087d98..fd6b5fb62 100644 --- a/src/java/com/threerings/presents/dobj/ObjectAddedEvent.java +++ b/src/java/com/threerings/presents/dobj/ObjectAddedEvent.java @@ -1,5 +1,5 @@ // -// $Id: ObjectAddedEvent.java,v 1.3 2001/08/02 04:49:08 mdb Exp $ +// $Id: ObjectAddedEvent.java,v 1.4 2001/08/04 00:32:11 mdb Exp $ package com.threerings.cocktail.cher.dobj; @@ -94,10 +94,12 @@ public class ObjectAddedEvent extends TypedEvent _oid = in.readInt(); } - public String toString () + protected void toString (StringBuffer buf) { - return "[OBJADD:targetOid=" + _toid + ", name=" + _name + - ", oid=" + _oid + "]"; + buf.append("OBJADD:"); + super.toString(buf); + buf.append(", name=").append(_name); + buf.append(", oid=").append(_oid); } protected String _name; diff --git a/src/java/com/threerings/presents/dobj/ObjectRemovedEvent.java b/src/java/com/threerings/presents/dobj/ObjectRemovedEvent.java index dcaa37a1e..80b8280c3 100644 --- a/src/java/com/threerings/presents/dobj/ObjectRemovedEvent.java +++ b/src/java/com/threerings/presents/dobj/ObjectRemovedEvent.java @@ -1,5 +1,5 @@ // -// $Id: ObjectRemovedEvent.java,v 1.3 2001/08/02 04:49:08 mdb Exp $ +// $Id: ObjectRemovedEvent.java,v 1.4 2001/08/04 00:32:11 mdb Exp $ package com.threerings.cocktail.cher.dobj; @@ -95,10 +95,12 @@ public class ObjectRemovedEvent extends TypedEvent _oid = in.readInt(); } - public String toString () + protected void toString (StringBuffer buf) { - return "[OBJREM:targetOid=" + _toid + ", name=" + _name + - ", oid=" + _oid + "]"; + buf.append("OBJREM:"); + super.toString(buf); + buf.append(", name=").append(_name); + buf.append(", oid=").append(_oid); } protected String _name; diff --git a/src/java/com/threerings/presents/dobj/ReleaseLockEvent.java b/src/java/com/threerings/presents/dobj/ReleaseLockEvent.java new file mode 100644 index 000000000..92236f249 --- /dev/null +++ b/src/java/com/threerings/presents/dobj/ReleaseLockEvent.java @@ -0,0 +1,94 @@ +// +// $Id: ReleaseLockEvent.java,v 1.1 2001/08/04 00:32:11 mdb Exp $ + +package com.threerings.cocktail.cher.dobj; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; + +import com.threerings.cocktail.cher.dobj.io.ValueMarshaller; + +/** + * A release lock event is dispatched at the end of a chain of attribute + * change events to release a lock that is intended to prevent some + * application defined activity from happening on the distributed object + * until those events have been processed. + * + * @see DObjectManager#postEvent + */ +public class ReleaseLockEvent extends TypedEvent +{ + /** The typed object code for this event. */ + public static final short TYPE = TYPE_BASE + 6; + + /** + * Constructs a new release lock 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 ReleaseLockEvent (int targetOid, String name) + { + super(targetOid); + _name = name; + } + + /** + * Constructs a blank instance of this event in preparation for + * unserialization from the network. + */ + public ReleaseLockEvent () + { + } + + /** + * Returns the name of the lock to release. + */ + public String getName () + { + return _name; + } + + /** + * Applies this attribute change to the object. + */ + public boolean applyToObject (DObject target) + throws ObjectAccessException + { + // pass the new value on to the object + target.setAttribute(_name, _value); + return true; + } + + public short getType () + { + return TYPE; + } + + public void writeTo (DataOutputStream out) + throws IOException + { + super.writeTo(out); + out.writeUTF(_name); + } + + public void readFrom (DataInputStream in) + throws IOException + { + super.readFrom(in); + _name = in.readUTF(); + } + + protected void toString (StringBuffer buf) + { + buf.append("UNLOCK:"); + super.toString(buf); + buf.append(", name=").append(_name); + } + + protected String _name; + protected Object _value; +}