org.spicefactory.pimento.io
Class TypeSnapshot

java.lang.Object
  extended by org.spicefactory.pimento.io.TypeSnapshot
All Implemented Interfaces:
Externalizable
Direct Known Subclasses:
EntitySnapshot

public class TypeSnapshot
extends Object
implements Externalizable

Abstract base class for a snapshot representation of a persistent type.

Author:
Jens Halm

Field Summary
protected static int EMPTY
          Constant used for empty snapshots.
protected static int FULL
          Constant used for full snapshots.
protected static int PARTIAL
          Constant used for partial snapshots.
protected  List<Object> propertyValues
          The property values held in this snapshot.
 
Constructor Summary
TypeSnapshot()
          Creates a new instance.
 
Method Summary
 void addProperty(Object value)
          Add the specified property value to this instance.
 void addProperty(Object value, int index)
          Adds the specified property value for the specified index position.
 PropertyIterator getPropertyIterator(ManagedType type)
          Returns an iterator over the property values of this snapshot.
 boolean isEmpty()
          Indicates whether this snapshot does not contain any property values.
 boolean isPartial()
          Indicates whether this snapshot only contains a subset of the properties of the represented entity.
 void readExternal(DataInput input)
          Restores the content of this object from the DataInput instance.
protected  void readProperties(DataInput input, int type)
          Reads the property values for the specified type of snapshot.
 void writeExternal(DataOutput output)
          Saves the content of this object to the DataOutput instance.
protected  void writeProperties(DataOutput output, int type)
          Writes the property values for the specified type of snapshot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

protected static final int EMPTY
Constant used for empty snapshots.

See Also:
Constant Field Values

PARTIAL

protected static final int PARTIAL
Constant used for partial snapshots.

See Also:
Constant Field Values

FULL

protected static final int FULL
Constant used for full snapshots.

See Also:
Constant Field Values

propertyValues

protected List<Object> propertyValues
The property values held in this snapshot.

Constructor Detail

TypeSnapshot

public TypeSnapshot()
Creates a new instance.

Method Detail

getPropertyIterator

public PropertyIterator getPropertyIterator(ManagedType type)
Returns an iterator over the property values of this snapshot.

Parameters:
type - the metamodel for this type.
Returns:
an iterator over the property values of this snapshot

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 Type instance).

addProperty

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

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

isPartial

public boolean isPartial()
Indicates whether this snapshot only contains a subset of the properties of the represented entity.

Returns:
true if this snapshot only contains a subset of the properties of the represented entity

isEmpty

public boolean isEmpty()
Indicates whether this snapshot does not contain any property values.

Returns:
true if this snapshot does not contain any property values

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
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
Parameters:
output - the output to write to

readProperties

protected void readProperties(DataInput input,
                              int type)
Reads the property values for the specified type of snapshot.

Parameters:
input - the binary input to read from
type - the type of the snapshot

writeProperties

protected void writeProperties(DataOutput output,
                               int type)
Writes the property values for the specified type of snapshot.

Parameters:
output - the binary output to write to
type - the type of the snapshot