Modified DSet support such that additions, updates and removals are
applied immediately on the authoritative copy of the object (the one on the server). We already do this for all other object modifications (except OidList which is kind of special anyway), but we should be wary of potential wickosity. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2302 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: EntryRemovedEvent.java,v 1.13 2003/02/26 21:41:47 mdb Exp $
|
||||
// $Id: EntryRemovedEvent.java,v 1.14 2003/03/10 18:29:54 mdb Exp $
|
||||
|
||||
package com.threerings.presents.dobj;
|
||||
|
||||
@@ -24,9 +24,20 @@ public class EntryRemovedEvent extends NamedEvent
|
||||
* @param key the entry key that identifies the entry to remove.
|
||||
*/
|
||||
public EntryRemovedEvent (int targetOid, String name, Comparable key)
|
||||
{
|
||||
this(targetOid, name, key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when the distributed object already removed the entry before
|
||||
* generating the event.
|
||||
*/
|
||||
public EntryRemovedEvent (int targetOid, String name, Comparable key,
|
||||
DSet.Entry oldEntry)
|
||||
{
|
||||
super(targetOid, name);
|
||||
_key = key;
|
||||
_oldEntry = oldEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,11 +70,13 @@ public class EntryRemovedEvent extends NamedEvent
|
||||
public boolean applyToObject (DObject target)
|
||||
throws ObjectAccessException
|
||||
{
|
||||
DSet set = (DSet)target.getAttribute(_name);
|
||||
// fetch the previous value for interested callers
|
||||
_oldEntry = set.get(_key);
|
||||
// remove it from the set
|
||||
set.removeKey(_key);
|
||||
if (_oldEntry == null) {
|
||||
DSet set = (DSet)target.getAttribute(_name);
|
||||
// fetch the previous value for interested callers
|
||||
_oldEntry = set.get(_key);
|
||||
// remove it from the set
|
||||
set.removeKey(_key);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user