| java.lang.Object java.beans.PersistenceDelegate java.beans.DefaultPersistenceDelegate
All known Subclasses: java.beans.SwingJFramePersistenceDelegate, java.beans.AwtListPersistenceDelegate, java.beans.UtilDatePersistenceDelegate, java.beans.SwingAbstractButtonPersistenceDelegate, java.beans.AwtMenuBarPersistenceDelegate, java.beans.AwtChoicePersistenceDelegate, java.beans.AwtRectanglePersistenceDelegate, java.beans.AwtColorPersistenceDelegate, java.beans.AwtFontPersistenceDelegate, java.beans.UtilMapPersistenceDelegate, java.beans.AwtDimensionPersistenceDelegate, java.beans.AwtInsetsPersistenceDelegate, java.beans.AwtScrollPanePersistenceDelegate, java.beans.AwtCursorPersistenceDelegate, java.beans.AwtPointPersistenceDelegate, java.beans.UtilCollectionPersistenceDelegate, java.beans.SwingJTabbedPanePersistenceDelegate, java.beans.UtilListPersistenceDelegate, java.beans.SwingDefaultComboBoxModelPersistenceDelegate, java.beans.ProxyPersistenceDelegate, java.beans.AwtComponentPersistenceDelegate, java.beans.AwtMenuPersistenceDelegate,
DefaultPersistenceDelegate | public class DefaultPersistenceDelegate extends PersistenceDelegate (Code) | | Default PersistenceDelegate for normal classes. The instances of this class
are used when other customized PersistenceDelegate is not set in the encoders
for a particular type.
This PersistenceDelegate assumes that the bean to be made persistent has a
default constructor that takes no parameters or a constructor that takes some
properties as its parameters. Only the properties that can be got or set
based on the knowledge gained through an introspection will be made
persistent. In the case that a bean is constructed with some properties, the
value of these properties should be available via the conventional getter
method.
See Also: Encoder |
Constructor Summary | |
public | DefaultPersistenceDelegate() Constructs a DefaultPersistenceDelegate instance that
supports the persistence of a bean which has a default constructor. | public | DefaultPersistenceDelegate(String[] propertyNames) Constructs a DefaultPersistenceDelegate instance that
supports the persistence of a bean which is constructed with some
properties. |
Method Summary | |
protected void | initialize(Class> type, Object oldInstance, Object newInstance, Encoder enc) Initializes the new instance in the new environment so that it becomes
equivalent with the old one, meanwhile recording this process in the
encoder.
This is done by inspecting each property of the bean. | protected Expression | instantiate(Object oldInstance, Encoder enc) Returns an expression that represents a call to the bean's constructor. | protected boolean | mutatesTo(Object o1, Object o2) Determines whether one object mutates to the other object. |
DefaultPersistenceDelegate | public DefaultPersistenceDelegate()(Code) | | Constructs a DefaultPersistenceDelegate instance that
supports the persistence of a bean which has a default constructor.
|
DefaultPersistenceDelegate | public DefaultPersistenceDelegate(String[] propertyNames)(Code) | | Constructs a DefaultPersistenceDelegate instance that
supports the persistence of a bean which is constructed with some
properties.
Parameters: propertyNames - the name of the properties that are taken as parameters by thebean's constructor |
initialize | protected void initialize(Class> type, Object oldInstance, Object newInstance, Encoder enc)(Code) | | Initializes the new instance in the new environment so that it becomes
equivalent with the old one, meanwhile recording this process in the
encoder.
This is done by inspecting each property of the bean. The property value
from the old bean instance and the value from the new bean instance are
both retrieved and examined to see whether the latter mutates to the
former, and if not, issue a call to the write method to set the
equivalent value for the new instance. Exceptions occured during this
process are reported to the exception listener of the encoder.
Parameters: type - the type of the bean Parameters: oldInstance - the original bean object to be recorded Parameters: newInstance - the simmulating new bean object to be initialized Parameters: enc - the encoder to write the outputs to |
instantiate | protected Expression instantiate(Object oldInstance, Encoder enc)(Code) | | Returns an expression that represents a call to the bean's constructor.
The constructor may take zero or more parameters, as specified when this
DefaultPersistenceDelegate is constructed.
Parameters: oldInstance - the old instance Parameters: enc - the encoder that wants to record the old instance an expression for instantiating an object of the same type as theold instance |
mutatesTo | protected boolean mutatesTo(Object o1, Object o2)(Code) | | Determines whether one object mutates to the other object. If this
DefaultPersistenceDelegate is constructed with one or more
property names, and the class of o1 overrides the
"equals(Object)" method, then o2 is considered to mutate
to o1 if o1 equals to o2 .
Otherwise, the result is the same as the definition in
PersistenceDelegate .
Parameters: o1 - one object Parameters: o2 - the other object true if second object mutates to the first object, otherwisefalse |
|
|