com.threerings.presents.dobj
Class EntryAddedEvent<T extends DSet.Entry>

java.lang.Object
  extended by com.threerings.presents.dobj.DEvent
      extended by com.threerings.presents.dobj.NamedEvent
          extended by com.threerings.presents.dobj.EntryEvent<T>
              extended by com.threerings.presents.dobj.EntryAddedEvent<T>
Type Parameters:
T - the type of entry being handled by this event. This must match the type on the set that generated this event.
All Implemented Interfaces:
Streamable

public class EntryAddedEvent<T extends DSet.Entry>
extends EntryEvent<T>

An entry added event is dispatched when an entry is added to a 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 Also:
DObjectManager.postEvent(com.threerings.presents.dobj.DEvent)

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected  boolean _alreadyApplied
          Used when this event is generated on the authoritative server where object changes are made immediately.
protected  T _entry
           
 
Fields inherited from class com.threerings.presents.dobj.NamedEvent
_name
 
Fields inherited from class com.threerings.presents.dobj.DEvent
_actualTransport, _soid, _toid, _transport, eventId, UNSET_OLD_ENTRY, UNSET_OLD_VALUE
 
Constructor Summary
EntryAddedEvent(int targetOid, String name, T entry)
          Constructs a new entry added event on the specified target object with the supplied set attribute name and entry to add.
 
Method Summary
 boolean alreadyApplied()
          If this event applies itself immediately to the distributed object on the server and then NOOPs later when DEvent.applyToObject(com.threerings.presents.dobj.DObject) is called, it should return true from this method.
 boolean applyToObject(DObject target)
          Applies the attribute modifications represented by this event to the specified target object.
 T getEntry()
          Return the new or updated entry, or null if the entry was removed.
 Comparable<?> getKey()
          Return the key that identifies the entry related to this event.
 T getOldEntry()
          Return the old entry, or null if the entry is newly added.
protected  void notifyListener(Object listener)
          Events with associated listener interfaces should implement this function and notify the supplied listener if it implements their event listening interface.
protected  EntryAddedEvent<T> setAlreadyApplied(boolean alreadyApplied)
          Used by DObject to note if this event has already been applied locally.
protected  void toString(StringBuilder buf)
          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.
 
Methods inherited from class com.threerings.presents.dobj.NamedEvent
getName
 
Methods inherited from class com.threerings.presents.dobj.DEvent
getActualTransport, getSourceOid, getTargetOid, getTransport, isPrivate, noteActualTransport, setSourceOid, setTargetOid, setTransport, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_entry

protected T extends DSet.Entry _entry

_alreadyApplied

protected transient boolean _alreadyApplied
Used when this event is generated on the authoritative server where object changes are made immediately. This lets us know not to apply ourselves when we're actually dispatched.

Constructor Detail

EntryAddedEvent

public EntryAddedEvent(int targetOid,
                       String name,
                       T entry)
Constructs a new entry added event on the specified target object with the supplied set attribute name and entry to add.

Parameters:
targetOid - the object id of the object to whose set we will add an entry.
name - the name of the attribute to which to add the specified entry.
entry - the entry to add to the set attribute.
Method Detail

getKey

public Comparable<?> getKey()
Description copied from class: EntryEvent
Return the key that identifies the entry related to this event. Never returns null.

Specified by:
getKey in class EntryEvent<T extends DSet.Entry>

getEntry

public T getEntry()
Return the new or updated entry, or null if the entry was removed. This implementation never returns null.

Specified by:
getEntry in class EntryEvent<T extends DSet.Entry>

getOldEntry

public T getOldEntry()
Return the old entry, or null if the entry is newly added. This implementation always returns null.

Specified by:
getOldEntry in class EntryEvent<T extends DSet.Entry>

alreadyApplied

public boolean alreadyApplied()
Description copied from class: DEvent
If this event applies itself immediately to the distributed object on the server and then NOOPs later when DEvent.applyToObject(com.threerings.presents.dobj.DObject) is called, it should return true from this method. If it will modify the object during its DEvent.applyToObject(com.threerings.presents.dobj.DObject) call, it should return false.

Overrides:
alreadyApplied in class DEvent

applyToObject

public boolean applyToObject(DObject target)
                      throws ObjectAccessException
Description copied from class: DEvent
Applies the attribute modifications represented by this event to the specified target object. This is called by the distributed object manager in the course of dispatching events and should not be called directly.

Specified by:
applyToObject in class DEvent
Returns:
true if the object manager should go on to notify the object's listeners of this event, false if the event should be treated silently and the listeners should not be notified.
Throws:
ObjectAccessException - thrown if there is any problem applying the event to the object (invalid attribute, etc.).

notifyListener

protected void notifyListener(Object listener)
Description copied from class: DEvent
Events with associated listener interfaces should implement this function and notify the supplied listener if it implements their event listening interface. For example, the AttributeChangedEvent will notify listeners that implement AttributeChangeListener.

Overrides:
notifyListener in class DEvent

toString

protected void toString(StringBuilder buf)
Description copied from class: DEvent
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.

Overrides:
toString in class NamedEvent

setAlreadyApplied

protected EntryAddedEvent<T> setAlreadyApplied(boolean alreadyApplied)
Used by DObject to note if this event has already been applied locally.