com.threerings.whirled.data
Class SceneUpdate

java.lang.Object
  extended by com.threerings.whirled.data.SceneUpdate
All Implemented Interfaces:
com.threerings.io.Streamable, Cloneable
Direct Known Subclasses:
DefaultColorUpdate, ModifyObjectsUpdate, ModifyPortalsUpdate

public class SceneUpdate
extends Object
implements com.threerings.io.Streamable, Cloneable

Used to encapsulate updates to scenes in such a manner that updates can be stored persistently and sent to clients to update their own local copies of scenes.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Constructor Summary
SceneUpdate()
           
 
Method Summary
 void apply(SceneModel model)
          Applies this update to the specified scene model.
 int getSceneId()
          Returns the scene id for which this update is appropriate.
 int getSceneVersion()
          Returns the scene version for which this update is appropriate.
 int getVersionIncrement()
          Returns the amount by which this update increments the scene version.
 void init(int targetId, int targetVersion)
          Initializes this scene update such that it will operate on a scene with the specified target scene and version number.
 void persistTo(com.threerings.io.ObjectOutputStream out)
          Serializes the bare representation of this instance without the scene id and version fields.
 void readObject(com.threerings.io.ObjectInputStream in)
          Reads our custom streamable fields.
 String toString()
           
 void unpersistFrom(com.threerings.io.ObjectInputStream in)
          Unserializes this instance from the bare representation created by persistTo(com.threerings.io.ObjectOutputStream).
 void validate(SceneModel model)
          Called to ensure that the scene is in the appropriate state prior to applying the update.
 void writeObject(com.threerings.io.ObjectOutputStream out)
          Writes our custom streamable fields.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SceneUpdate

public SceneUpdate()
Method Detail

init

public void init(int targetId,
                 int targetVersion)
Initializes this scene update such that it will operate on a scene with the specified target scene and version number.

Parameters:
targetId - the id of the scene on which we are to operate.
targetVersion - the version of the scene on which we are to operate.

getSceneId

public int getSceneId()
Returns the scene id for which this update is appropriate.


getSceneVersion

public int getSceneVersion()
Returns the scene version for which this update is appropriate.


getVersionIncrement

public int getVersionIncrement()
Returns the amount by which this update increments the scene version.


validate

public void validate(SceneModel model)
              throws IllegalStateException
Called to ensure that the scene is in the appropriate state prior to applying the update.

Throws:
IllegalStateException - thrown if the update cannot be applied to the scene because it is not in a valid state (appropriate previous updates were not applied, it's the wrong kind of scene, etc.).

apply

public void apply(SceneModel model)
Applies this update to the specified scene model. Derived classes will want to override this method and apply updates of their own, being sure to call super.apply.


writeObject

public void writeObject(com.threerings.io.ObjectOutputStream out)
                 throws IOException
Writes our custom streamable fields.

Throws:
IOException

readObject

public void readObject(com.threerings.io.ObjectInputStream in)
                throws IOException,
                       ClassNotFoundException
Reads our custom streamable fields.

Throws:
IOException
ClassNotFoundException

persistTo

public void persistTo(com.threerings.io.ObjectOutputStream out)
               throws IOException
Serializes the bare representation of this instance without the scene id and version fields. Useful when storing updates in a database where the scene id and version fields are stored in separate columns and the rest if the representation is contained in an opaque blob.

Throws:
IOException

unpersistFrom

public void unpersistFrom(com.threerings.io.ObjectInputStream in)
                   throws IOException,
                          ClassNotFoundException
Unserializes this instance from the bare representation created by persistTo(com.threerings.io.ObjectOutputStream).

Throws:
IOException
ClassNotFoundException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.