72 * <li>
73 * Deciding whether or not an instance can be mutated
74 * into another instance of the same class.
75 * <li>
76 * Instantiating the object, either by calling a
77 * public constructor or a public factory method.
78 * <li>
79 * Performing the initialization of the object.
80 * </ul>
81 * @see XMLEncoder
82 *
83 * @since 1.4
84 *
85 * @author Philip Milne
86 */
87
88 public abstract class PersistenceDelegate {
89
90 /**
91 * The {@code writeObject} is a single entry point to the persistence
92 * and is used by a {@code Encoder} in the traditional
93 * mode of delegation. Although this method is not final,
94 * it should not need to be subclassed under normal circumstances.
95 * <p>
96 * This implementation first checks to see if the stream
97 * has already encountered this object. Next the
98 * {@code mutatesTo} method is called to see if
99 * that candidate returned from the stream can
100 * be mutated into an accurate copy of {@code oldInstance}.
101 * If it can, the {@code initialize} method is called to
102 * perform the initialization. If not, the candidate is removed
103 * from the stream, and the {@code instantiate} method
104 * is called to create a new candidate for this object.
105 *
106 * @param oldInstance The instance that will be created by this expression.
107 * @param out The stream to which this expression will be written.
108 *
109 * @throws NullPointerException if {@code out} is {@code null}
110 */
111 public void writeObject(Object oldInstance, Encoder out) {
112 Object newInstance = out.get(oldInstance);
|
72 * <li>
73 * Deciding whether or not an instance can be mutated
74 * into another instance of the same class.
75 * <li>
76 * Instantiating the object, either by calling a
77 * public constructor or a public factory method.
78 * <li>
79 * Performing the initialization of the object.
80 * </ul>
81 * @see XMLEncoder
82 *
83 * @since 1.4
84 *
85 * @author Philip Milne
86 */
87
88 public abstract class PersistenceDelegate {
89
90 /**
91 * The {@code writeObject} is a single entry point to the persistence
92 * and is used by an {@code Encoder} in the traditional
93 * mode of delegation. Although this method is not final,
94 * it should not need to be subclassed under normal circumstances.
95 * <p>
96 * This implementation first checks to see if the stream
97 * has already encountered this object. Next the
98 * {@code mutatesTo} method is called to see if
99 * that candidate returned from the stream can
100 * be mutated into an accurate copy of {@code oldInstance}.
101 * If it can, the {@code initialize} method is called to
102 * perform the initialization. If not, the candidate is removed
103 * from the stream, and the {@code instantiate} method
104 * is called to create a new candidate for this object.
105 *
106 * @param oldInstance The instance that will be created by this expression.
107 * @param out The stream to which this expression will be written.
108 *
109 * @throws NullPointerException if {@code out} is {@code null}
110 */
111 public void writeObject(Object oldInstance, Encoder out) {
112 Object newInstance = out.get(oldInstance);
|