org.spicefactory.pimento.io
Class FullEntitySnapshot

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

public class FullEntitySnapshot
extends AbstractApplicableEntitySnapshot

Represent an entity with all of its current property values. Some of these values may be uninitialized proxies though.

When an instance of this class gets populated, the order of addProperty invocations must correspond to the order of properties in the associated EntityMetadata instance. Furthermore it must be guaranteed that it will always be filled with values for all entity properties.

Author:
Jens Halm

Constructor Summary
FullEntitySnapshot()
          Creates a new instance.
FullEntitySnapshot(int metadataId, Object entityId)
          Creates a new instance.
 
Method Summary
 void addProperty(Object value)
          Add the specified property value to this instance.
 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

FullEntitySnapshot

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


FullEntitySnapshot

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

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

addProperty

public void addProperty(Object value)
Add the specified property value to this instance.

Parameters:
value - the property value to add to this snapshot

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