More progress.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3861 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-17 05:11:31 +00:00
parent cd7e127bc6
commit 74c35b6d65
22 changed files with 1632 additions and 19 deletions
@@ -0,0 +1,85 @@
package com.threerings.presents.dobj {
import flash.util.StringBuilder;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* An entry added event is dispatched when an entry is added to a {@link
* DSet} attribute of a distributed entry. It can also be constructed to
* request the addition of an entry to a set and posted to the dobjmgr.
*
* @see DObjectManager#postEvent
*/
public class EntryAddedEvent extends NamedEvent
{
/**
* Constructs a new entry added event on the specified target object
* with the supplied set attribute name and entry to add.
*
* @param targetOid the object id of the object to whose set we will
* add an entry.
* @param name the name of the attribute to which to add the specified
* entry.
* @param entry the entry to add to the set attribute.
*/
public function EntryAddedEvent (
targetOid :int, name :String, entry :DSetEntry)
{
super(targetOid, name);
_entry = entry;
}
/**
* Returns the entry that has been added.
*/
public function getEntry () :DSetEntry
{
return _entry;
}
/**
* Applies this event to the object.
*/
public override function applyToObject (target :DObject) :Boolean
//throws ObjectAccessException
{
var added :Boolean = target[_name].add(_entry);
if (!added) {
trace("Duplicate entry found [event=" + this + "].");
}
return true;
}
// documentation inherited
protected override function notifyListener (listener :*) :void
{
if (listener is SetListener) {
listener.entryAdded(this);
}
}
// documentation inherited
protected override function toString (StringBuilder buf)
{
buf.append("ELADD:");
super.toString(buf);
buf.append(", entry=", _entry);
}
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeField(_entry);
}
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_entry = ins.readField(DSetEntry);
}
protected var _entry :DSetEntry;
}
}