com.threerings.presents.dobj
Class AttributeChangedEvent

java.lang.Object
  extended by com.threerings.presents.dobj.DEvent
      extended by com.threerings.presents.dobj.NamedEvent
          extended by com.threerings.presents.dobj.AttributeChangedEvent
All Implemented Interfaces:
Streamable

public class AttributeChangedEvent
extends NamedEvent

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 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  Object _oldValue
           
protected  Object _value
           
 
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
AttributeChangedEvent(int targetOid, String name, Object value)
          Constructs a new attribute changed event on the specified target object with the supplied attribute name and value.
 
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.
 byte getByteValue()
          Returns the new value of the attribute as a byte.
 double getDoubleValue()
          Returns the new value of the attribute as a double.
 float getFloatValue()
          Returns the new value of the attribute as a float.
 int getIntValue()
          Returns the new value of the attribute as an int.
 long getLongValue()
          Returns the new value of the attribute as a long.
 Object getOldValue()
          Returns the value of the attribute prior to the application of this event.
 short getShortValue()
          Returns the new value of the attribute as a short.
 Object getValue()
          Returns the new value of the attribute.
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  AttributeChangedEvent setOldValue(Object oldValue)
           
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

_value

protected Object _value

_oldValue

protected transient Object _oldValue
Constructor Detail

AttributeChangedEvent

public AttributeChangedEvent(int targetOid,
                             String name,
                             Object value)
Constructs a new attribute changed event on the specified target object with the supplied attribute name and value. Do not construct these objects by hand. Use DObject.changeAttribute(java.lang.String, java.lang.Object) instead.

Parameters:
targetOid - the object id of the object whose attribute has changed.
name - the name of the attribute (data member) that has changed.
value - the new value of the attribute (in the case of primitive types, the reflection-defined object-alternative is used).
Method Detail

getValue

public Object getValue()
Returns the new value of the attribute.


getOldValue

public Object getOldValue()
Returns the value of the attribute prior to the application of this event.


getByteValue

public byte getByteValue()
Returns the new value of the attribute as a byte. This will fail if the attribute in question is not a byte.


getShortValue

public short getShortValue()
Returns the new value of the attribute as a short. This will fail if the attribute in question is not a short.


getIntValue

public int getIntValue()
Returns the new value of the attribute as an int. This will fail if the attribute in question is not an int.


getLongValue

public long getLongValue()
Returns the new value of the attribute as a long. This will fail if the attribute in question is not a long.


getFloatValue

public float getFloatValue()
Returns the new value of the attribute as a float. This will fail if the attribute in question is not a float.


getDoubleValue

public double getDoubleValue()
Returns the new value of the attribute as a double. This will fail if the attribute in question is not a double.


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

setOldValue

protected AttributeChangedEvent setOldValue(Object oldValue)