src/share/classes/java/beans/PersistenceDelegate.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 180      * method which returns an expression involving elements in
 181      * a cloned environment simulating the state of an input stream during
 182      * reading. Each statement returned will have had all instances
 183      * the old environment replaced with objects which exist in the new
 184      * one. In particular, references to the target of these statements,
 185      * which start out as references to <code>oldInstance</code> are returned
 186      * as references to the <code>newInstance</code> instead.
 187      * Executing these statements effects an incremental
 188      * alignment of the state of the two objects as a series of
 189      * modifications to the objects in the new environment.
 190      * By the time the initialize method returns it should be impossible
 191      * to tell the two instances apart by using their public APIs.
 192      * Most importantly, the sequence of steps that were used to make
 193      * these objects appear equivalent will have been recorded
 194      * by the output stream and will form the actual output when
 195      * the stream is flushed.
 196      * <p>
 197      * The default implementation, calls the <code>initialize</code>
 198      * method of the type's superclass.
 199      *

 200      * @param oldInstance The instance to be copied.
 201      * @param newInstance The instance that is to be modified.
 202      * @param out The stream to which any initialization statements should be written.
 203      *
 204      * @throws NullPointerException if {@code out} is {@code null}
 205      */
 206     protected void initialize(Class<?> type,
 207                               Object oldInstance, Object newInstance,
 208                               Encoder out)
 209     {
 210         Class<?> superType = type.getSuperclass();
 211         PersistenceDelegate info = out.getPersistenceDelegate(superType);
 212         info.initialize(superType, oldInstance, newInstance, out);
 213     }
 214 }
   1 /*
   2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 180      * method which returns an expression involving elements in
 181      * a cloned environment simulating the state of an input stream during
 182      * reading. Each statement returned will have had all instances
 183      * the old environment replaced with objects which exist in the new
 184      * one. In particular, references to the target of these statements,
 185      * which start out as references to <code>oldInstance</code> are returned
 186      * as references to the <code>newInstance</code> instead.
 187      * Executing these statements effects an incremental
 188      * alignment of the state of the two objects as a series of
 189      * modifications to the objects in the new environment.
 190      * By the time the initialize method returns it should be impossible
 191      * to tell the two instances apart by using their public APIs.
 192      * Most importantly, the sequence of steps that were used to make
 193      * these objects appear equivalent will have been recorded
 194      * by the output stream and will form the actual output when
 195      * the stream is flushed.
 196      * <p>
 197      * The default implementation, calls the <code>initialize</code>
 198      * method of the type's superclass.
 199      *
 200      * @param type the type of the instances
 201      * @param oldInstance The instance to be copied.
 202      * @param newInstance The instance that is to be modified.
 203      * @param out The stream to which any initialization statements should be written.
 204      *
 205      * @throws NullPointerException if {@code out} is {@code null}
 206      */
 207     protected void initialize(Class<?> type,
 208                               Object oldInstance, Object newInstance,
 209                               Encoder out)
 210     {
 211         Class<?> superType = type.getSuperclass();
 212         PersistenceDelegate info = out.getPersistenceDelegate(superType);
 213         info.initialize(superType, oldInstance, newInstance, out);
 214     }
 215 }