Ja.NET Standard Edition 5.0

Documentation API Specification

Contents

PersistenceDelegate Class Reference

Inherited by ArrayPersistenceDelegate, AwtMenuShortcutPersistenceDelegate, ClassPersistenceDelegate, DefaultPersistenceDelegate, FieldPersistenceDelegate, MethodPersistenceDelegate, NullPersistenceDelegate, PrimitiveWrapperPersistenceDelegate, StaticFieldPersistenceDelegate, StringPersistenceDelegate, SwingBoxPersistenceDelegate, and SwingToolTipManagerPersistenceDelegate.

List of all members.


Detailed Description

PersistenceDelegate instances write received bean objects to encoders in the form of expressions and statements, which can be evaluated or executed to reconstruct the recorded bean objects in a new environment during decoding.

Expressions are usually used to instantiate bean objects in the new environment, and statements are used to initialize their properties if necessary. As a result, the reconstructed bean objects become equivalent to the original recorded ones in terms of their public states.


Public Member Functions

 PersistenceDelegate ()
 Default constructor.
void writeObject (Object oldInstance, Encoder out)
 Writes a bean object to the given encoder.

Protected Member Functions

void initialize (Class<?> type, Object oldInstance, Object newInstance, Encoder enc)
 Produces a series of expressions and statements for the initialization of a bean object's properties.
abstract Expression instantiate (Object oldInstance, Encoder enc)
 Constructs an expression for instantiating an object of the same type as the old instance.
boolean mutatesTo (Object o1, Object o2)
 Determines whether one object mutates to the other object.

Constructor & Destructor Documentation

Default constructor.


Member Function Documentation

void initialize ( Class<?>  type,
Object  oldInstance,
Object  newInstance,
Encoder  enc 
) [protected]

Produces a series of expressions and statements for the initialization of a bean object's properties.

The default implementation simply invokes the initialization provided by the super class's PersisteneceDelegate instance.

Parameters:
type the type of the bean
oldInstance the original bean object to be recorded
newInstance the simmulating new bean object to be initialized
enc the encoder to write the outputs to

Reimplemented in ArrayPersistenceDelegate, AwtChoicePersistenceDelegate, AwtComponentPersistenceDelegate, AwtContainerPersistenceDelegate, AwtListPersistenceDelegate, AwtMenuBarPersistenceDelegate, AwtMenuPersistenceDelegate, AwtRectanglePersistenceDelegate, ClassPersistenceDelegate, DefaultPersistenceDelegate, FieldPersistenceDelegate, MethodPersistenceDelegate, NullPersistenceDelegate, PrimitiveWrapperPersistenceDelegate, ProxyPersistenceDelegate, StringPersistenceDelegate, SwingAbstractButtonPersistenceDelegate, SwingBoxPersistenceDelegate, SwingDefaultComboBoxModelPersistenceDelegate, SwingJFramePersistenceDelegate, SwingJTabbedPanePersistenceDelegate, UtilCollectionPersistenceDelegate, UtilListPersistenceDelegate, and UtilMapPersistenceDelegate.

abstract Expression instantiate ( Object  oldInstance,
Encoder  enc 
) [protected, pure virtual]

Constructs an expression for instantiating an object of the same type as the old instance.

Any exceptions occured during this process could be reported to the exception listener registered in the given encoder.

Parameters:
oldInstance the old instance
enc the encoder that wants to record the old instance
Returns:
an expression for instantiating an object of the same type as the old instance

Implemented in ArrayPersistenceDelegate, AwtColorPersistenceDelegate, AwtCursorPersistenceDelegate, AwtDimensionPersistenceDelegate, AwtFontPersistenceDelegate, AwtInsetsPersistenceDelegate, AwtMenuShortcutPersistenceDelegate, AwtPointPersistenceDelegate, AwtRectanglePersistenceDelegate, AwtScrollPanePersistenceDelegate, ClassPersistenceDelegate, DefaultPersistenceDelegate, FieldPersistenceDelegate, MethodPersistenceDelegate, NullPersistenceDelegate, PrimitiveWrapperPersistenceDelegate, ProxyPersistenceDelegate, StaticFieldPersistenceDelegate, StringPersistenceDelegate, SwingBoxPersistenceDelegate, SwingToolTipManagerPersistenceDelegate, and UtilDatePersistenceDelegate.

boolean mutatesTo ( Object  o1,
Object  o2 
) [protected]

Determines whether one object mutates to the other object.

One object is considered able to mutate to another object if they are indistinguishable in terms of behaviors of all public APIs. The default implementation here is to return true only if the two objects are instances of the same class.

Parameters:
o1 one object
o2 the other object
Returns:
true if second object mutates to the first object, otherwise false

Reimplemented in ArrayPersistenceDelegate, AwtRectanglePersistenceDelegate, ClassPersistenceDelegate, DefaultPersistenceDelegate, FieldPersistenceDelegate, MethodPersistenceDelegate, PrimitiveWrapperPersistenceDelegate, ProxyPersistenceDelegate, and StringPersistenceDelegate.

void writeObject ( Object  oldInstance,
Encoder  out 
)

Writes a bean object to the given encoder.

First it is checked whether the simulating new object can be mutated to the old instance. If yes, it is initialized to produce a series of expressions and statements that can be used to restore the old instance. Otherwise, remove the new object in the simulating new environment and writes an expression that can instantiate a new instance of the same type as the old one to the given encoder.

Parameters:
oldInstance the old instance to be written
out the encoder that the old instance will be written to

Reimplemented in NullPersistenceDelegate.