com.threerings.whirled.server.persist
Class SceneUpdateMarshaller

java.lang.Object
  extended by com.threerings.whirled.server.persist.SceneUpdateMarshaller

public class SceneUpdateMarshaller
extends Object

A utility class to assist the management of scene updates by a SceneRepository.


Constructor Summary
SceneUpdateMarshaller(Class<?>... typesClasses)
          Create a SceneUpdateMarshaller that understands the update types specified.
 
Method Summary
 SceneUpdate decodeUpdate(int sceneId, int sceneVersion, int updateType, byte[] data)
          Instantiates the appropriate update class and decodes the update from the data.
 Class<?> getUpdateClass(int type)
          Returns the update class associated with the specified type code, or null.
 int getUpdateType(Class<?> typeClass)
          Returns the type code that is assigned to the specified SceneUpdate class, or -1.
 int getUpdateType(SceneUpdate update)
          Returns the type code that is assigned to the specified SceneUpdate instance, or -1.
 byte[] persistUpdate(SceneUpdate update)
          Persists the specified update to a new ByteArrayOutInputStream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SceneUpdateMarshaller

public SceneUpdateMarshaller(Class<?>... typesClasses)
Create a SceneUpdateMarshaller that understands the update types specified. Note: Once a type is registered and in use by some SceneRepository that type id can never be used again. If you need to remove an update type, it should be replaced with null in the class list to reserve the old type id that it represented.

Method Detail

getUpdateType

public int getUpdateType(SceneUpdate update)
Returns the type code that is assigned to the specified SceneUpdate instance, or -1.


getUpdateType

public int getUpdateType(Class<?> typeClass)
Returns the type code that is assigned to the specified SceneUpdate class, or -1.


getUpdateClass

public Class<?> getUpdateClass(int type)
Returns the update class associated with the specified type code, or null.


persistUpdate

public byte[] persistUpdate(SceneUpdate update)
                     throws PersistenceException
Persists the specified update to a new ByteArrayOutInputStream.

Throws:
PersistenceException

decodeUpdate

public SceneUpdate decodeUpdate(int sceneId,
                                int sceneVersion,
                                int updateType,
                                byte[] data)
                         throws PersistenceException
Instantiates the appropriate update class and decodes the update from the data.

Throws:
PersistenceException


Copyright © 2011. All Rights Reserved.