org.spicefactory.pimento.io
Class PartialEntitySnapshot

java.lang.Object
  extended by org.spicefactory.pimento.io.AbstractEntitySnapshot
      extended by org.spicefactory.pimento.io.AbstractApplicableEntitySnapshot
          extended by org.spicefactory.pimento.io.PartialEntitySnapshot
All Implemented Interfaces:
Externalizable, ApplicableEntitySnapshot, EntitySnapshot

public class PartialEntitySnapshot
extends AbstractApplicableEntitySnapshot

Represents an entity with a subset of its property values. This snaphsot is used when receiving changesets of modified entities from the client or sending partial updates for refreshable properties to the client and should contain only the values for properties that were actually changed.

Author:
Jens Halm

Constructor Summary
PartialEntitySnapshot()
          Creates a new instance.
PartialEntitySnapshot(int metadataId, Object entityId)
          Creates a new instance.
PartialEntitySnapshot(int metadataId, Object entityId, int temporaryEntityId)
          Creates a new instance representing a transient entity.
 
Method Summary
 void addProperty(Object value, int index)
          Adds the specified property value for the specified index position.
 String getLogString(EntityMetadata metadata, boolean includeProperties)
          Returns a log String for this snapshot.
 EntityUpdate prepareUpdate(Object entity, EntityMetadata metadata, IoContext context)
          Creates and returns an EntityUpdate instance that reflects the state of this instance.
 void readExternal(DataInput input)
          Restores the content of this object from the DataInput instance.
 void writeExternal(DataOutput output)
          Saves the content of this object to the DataOutput instance.
 
Methods inherited from class org.spicefactory.pimento.io.AbstractApplicableEntitySnapshot
clearInvocationCache, getEntity, getProperties, hasEntity, isTransient, setEntity
 
Methods inherited from class org.spicefactory.pimento.io.AbstractEntitySnapshot
equals, getEntityId, getMetadataId, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.spicefactory.pimento.io.EntitySnapshot
getEntityId, getMetadataId
 

Constructor Detail

PartialEntitySnapshot

public PartialEntitySnapshot()
Creates a new instance. The default constructor will only be used by the AMF decoder.


PartialEntitySnapshot

public PartialEntitySnapshot(int metadataId,
                             Object entityId)
Creates a new instance.

Parameters:
metadataId - the id of the metadata for this entity
entityId - the id of the entity

PartialEntitySnapshot

public PartialEntitySnapshot(int metadataId,
                             Object entityId,
                             int temporaryEntityId)
Creates a new instance representing a transient entity. The temporary id is used to synchronize persistent entities with the client.

Parameters:
metadataId - the id of the metadata for this entity
entityId - the id of the entity
temporaryEntityId - the temporary id of the transient entity
Method Detail

addProperty

public void addProperty(Object value,
                        int index)
Adds the specified property value for the specified index position.

Parameters:
value - the property value to add to this snapshot
index - the index position of the property (determined by the order of properties in the associated EntityMetadata instance).

prepareUpdate

public EntityUpdate prepareUpdate(Object entity,
                                  EntityMetadata metadata,
                                  IoContext context)
Description copied from interface: ApplicableEntitySnapshot
Creates and returns an EntityUpdate instance that reflects the state of this instance. The returned instance must contain persistent entity references for all association properties that this instance contains snapshots for.

Parameters:
entity - the entity the update will later be applied to
metadata - the metadata for the specified entity
context - the active IoContext
Returns:
a new EntityUpdate instance that can later be applied to the entity

readExternal

public void readExternal(DataInput input)
Description copied from interface: Externalizable
Restores the content of this object from the DataInput instance. Values must be read in the same sequence as they were written on the client side.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class AbstractApplicableEntitySnapshot
Parameters:
input - the AMF3 data to read from

writeExternal

public void writeExternal(DataOutput output)
Description copied from interface: Externalizable
Saves the content of this object to the DataOutput instance.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class AbstractApplicableEntitySnapshot
Parameters:
output - the output to write to

getLogString

public String getLogString(EntityMetadata metadata,
                           boolean includeProperties)
Description copied from interface: EntitySnapshot
Returns a log String for this snapshot.

Specified by:
getLogString in interface EntitySnapshot
Overrides:
getLogString in class AbstractEntitySnapshot
Parameters:
metadata - the metadata associated with this snapshot
includeProperties - whether properties should be included in the log