diff --git a/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java b/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java
new file mode 100644
index 000000000..1ffd9581a
--- /dev/null
+++ b/src/java/com/threerings/presents/dobj/AttributeChangedEvent.java
@@ -0,0 +1,97 @@
+//
+// $Id: AttributeChangedEvent.java,v 1.1 2001/06/01 07:12:13 mdb Exp $
+
+package com.threerings.cocktail.cher.dobj;
+
+/**
+ * An attribute changed event is dispatched when a single attribute of a
+ * distributed object has changed. It can also be constructed to request
+ * an attribute change on an object and posted to the dobjmgr.
+ *
+ * @see DObjectManager.postEvent
+ */
+public class AttributeChangedEvent extends DEvent
+{
+ /**
+ * Constructs a new attribute changed event on the specified target
+ * object with the supplied attribute name and value.
+ *
+ * @param targetOid the object id of the object whose attribute has
+ * changed.
+ * @param name the name of the attribute (data member) that has
+ * changed.
+ * @param value the new value of the attribute (in the case of
+ * primitive types, the reflection-defined object-alternative is
+ * used).
+ */
+ public AttributeChangedEvent (int targetOid, String name, Object value)
+ {
+ super(targetOid);
+ _name = name;
+ _value = value;
+ }
+
+ /**
+ * Returns the name of the attribute that has changed.
+ */
+ public String getName ()
+ {
+ return _name;
+ }
+
+ /**
+ * Returns the new value of the attribute.
+ */
+ public Object getValue ()
+ {
+ return _value;
+ }
+
+ /**
+ * Returns the new value of the attribute as a short. This will fail
+ * if the attribute in question is not a short.
+ */
+ public short getShortValue ()
+ {
+ return ((Short)_value).shortValue();
+ }
+
+ /**
+ * Returns the new value of the attribute as an int. This will fail if
+ * the attribute in question is not an int.
+ */
+ public int getIntValue ()
+ {
+ return ((Integer)_value).intValue();
+ }
+
+ /**
+ * Returns the new value of the attribute as a long. This will fail if
+ * the attribute in question is not a long.
+ */
+ public long getLongValue ()
+ {
+ return ((Long)_value).longValue();
+ }
+
+ /**
+ * Returns the new value of the attribute as a float. This will fail
+ * if the attribute in question is not a float.
+ */
+ public float getFloatValue ()
+ {
+ return ((Float)_value).floatValue();
+ }
+
+ /**
+ * Returns the new value of the attribute as a double. This will fail
+ * if the attribute in question is not a double.
+ */
+ public double getDoubleValue ()
+ {
+ return ((Double)_value).doubleValue();
+ }
+
+ protected String _name;
+ protected Object _value;
+}
diff --git a/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java b/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java
new file mode 100644
index 000000000..357b8fd4c
--- /dev/null
+++ b/src/java/com/threerings/presents/dobj/AttributesChangedEvent.java
@@ -0,0 +1,145 @@
+//
+// $Id: AttributesChangedEvent.java,v 1.1 2001/06/01 07:12:13 mdb Exp $
+
+package com.threerings.cocktail.cher.dobj;
+
+/**
+ * An attributes changed event is dispatched when multiple
+ * attributes of a distributed object have been changed in a single
+ * transaction.
+ *
+ * @see DObjectManager.postEvent
+ */
+public class AttributesChangedEvent extends DEvent
+{
+ /**
+ * Constructs a new attribute changed event on the specified target
+ * object with the supplied attribute name and value.
+ *
+ * @param targetOid the object id of the object whose attribute has
+ * changed.
+ * @param count the number of attributes that have changed (the length
+ * of the names and values arrays need not
+ * be exactly equal to the number of attributes changed, there can be
+ * extra space at the end).
+ * @param names the names of the attributes (data members) that have
+ * changed.
+ * @param values the new values of the attributes (in the case of
+ * primitive types, the reflection-defined object-alternative is
+ * used).
+ */
+ public AttributesChangedEvent (int targetOid, int count,
+ String[] names, Object[] values)
+ {
+ super(targetOid);
+ _count = count;
+ _names = names;
+ _values = values;
+ }
+
+ /**
+ * Returns the number of attributes that have changed.
+ */
+ public int getCount ()
+ {
+ return _count;
+ }
+
+ /**
+ * Returns the name of the indexth attribute that has
+ * changed. This value is not range checked, so be sure it is between
+ * 0 and getCount()-1. You may not receive
+ * an ArrayIndexOutOfBounds exception if you exceed
+ * getCount() but rather get a null name.
+ */
+ public String getName (int index)
+ {
+ return _names[index];
+ }
+
+ /**
+ * Returns the new value of the indexth attribute. This value
+ * is not range checked, so be sure it is between 0 and
+ * getCount()-1. You may not receive an
+ * ArrayIndexOutOfBounds exception if you exceed
+ * getCount() but rather get a null value.
+ */
+ public Object getValue (int index)
+ {
+ return _values[index];
+ }
+
+ /**
+ * Returns the new value of the indexth attribute as a
+ * short. This will fail if the attribute in question is not a short.
+ * The index parameter is not range checked, so be sure
+ * it is between 0 and getCount()-1. You may
+ * not receive an ArrayIndexOutOfBounds exception if you
+ * exceed getCount() but rather get a
+ * NullPointerException.
+ */
+ public short getShortValue (int index)
+ {
+ return ((Short)_values[index]).shortValue();
+ }
+
+ /**
+ * Returns the new value of the indexth attribute as an
+ * int. This will fail if the attribute in question is not an int.
+ * The index parameter is not range checked, so be sure
+ * it is between 0 and getCount()-1. You may
+ * not receive an ArrayIndexOutOfBounds exception if you
+ * exceed getCount() but rather get a
+ * NullPointerException.
+ */
+ public int getIntValue (int index)
+ {
+ return ((Integer)_values[index]).intValue();
+ }
+
+ /**
+ * Returns the new value of the indexth attribute as a
+ * long. This will fail if the attribute in question is not a long.
+ * The index parameter is not range checked, so be sure
+ * it is between 0 and getCount()-1. You may
+ * not receive an ArrayIndexOutOfBounds exception if you
+ * exceed getCount() but rather get a
+ * NullPointerException.
+ */
+ public long getLongValue (int index)
+ {
+ return ((Long)_values[index]).longValue();
+ }
+
+ /**
+ * Returns the new value of the indexth attribute as a
+ * float. This will fail if the attribute in question is not a float.
+ * The index parameter is not range checked, so be sure
+ * it is between 0 and getCount()-1. You may
+ * not receive an ArrayIndexOutOfBounds exception if you
+ * exceed getCount() but rather get a
+ * NullPointerException.
+ */
+ public float getFloatValue (int index)
+ {
+ return ((Float)_values[index]).floatValue();
+ }
+
+ /**
+ * Returns the new value of the indexth attribute as a
+ * double. This will fail if the attribute in question is not a
+ * double. The index parameter is not range checked, so
+ * be sure it is between 0 and getCount()-1.
+ * You may not receive an ArrayIndexOutOfBounds exception
+ * if you exceed getCount() but rather get a
+ * NullPointerException.
+ */
+ public double getDoubleValue (int index)
+ {
+ return ((Double)_values[index]).doubleValue();
+ }
+
+ 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 7a866281e..7dc1edb90 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.1 2001/06/01 05:01:52 mdb Exp $
+// $Id: DEvent.java,v 1.2 2001/06/01 07:12:13 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -11,4 +11,23 @@ package com.threerings.cocktail.cher.dobj;
*/
public class DEvent
{
+ /**
+ * Returns the oid of the object that is the target of this event.
+ */
+ public int getTargetOid ()
+ {
+ return _toid;
+ }
+
+ /**
+ * Constructs a new distributed object event that pertains to the
+ * specified distributed object.
+ */
+ protected DEvent (int targetOid)
+ {
+ _toid = targetOid;
+ }
+
+ /** The oid of the object that is the target of this event. */
+ protected int _toid;
}
diff --git a/src/java/com/threerings/presents/dobj/DObjectManager.java b/src/java/com/threerings/presents/dobj/DObjectManager.java
index 55edebb75..43cbc73dc 100644
--- a/src/java/com/threerings/presents/dobj/DObjectManager.java
+++ b/src/java/com/threerings/presents/dobj/DObjectManager.java
@@ -1,5 +1,5 @@
//
-// $Id: DObjectManager.java,v 1.2 2001/06/01 05:17:16 mdb Exp $
+// $Id: DObjectManager.java,v 1.3 2001/06/01 07:12:13 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -67,4 +67,22 @@ public interface DObjectManager
* @see Subscriber.requestFailed
*/
public void fetchObject (int oid, Subscriber target);
+
+ /**
+ * Posts a distributed object event into the system. Instead of
+ * requesting the modification of a distributed object attribute by
+ * calling the setter for that attribute on the object itself, an
+ * AttributeChangedEvent can be constructed and posted
+ * directly. This is true for all event types and is useful for
+ * situations where one doesn't have access to the object in question,
+ * but needs to affect some event.
+ *
+ *
This event will be forwarded to the ultimate manager of the + * object (on the client, this means it will be forwarded to the + * server) where it will be checked for validity and then applied to + * the object and dispatched to all its subscribers. + * + * @param event The event to be dispatched. + */ + public void postEvent (DEvent event); }