1 /*
2 * Copyright (c) 2000, 2012, 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
365 * the property value has not changed there is no need to
366 * call the corresponding "setter" method and no statement
367 * is emitted. If not however, the expression for this value
368 * is replaced with another expression (normally a constructor)
369 * and the corresponding "setter" method is called to install
370 * the new property value in the object. This scheme removes
371 * default information from the output produced by streams
372 * using this delegate.
373 * <p>
374 * In passing these statements to the output stream, where they
375 * will be executed, side effects are made to the <code>newInstance</code>.
376 * In most cases this allows the problem of properties
377 * whose values depend on each other to actually help the
378 * serialization process by making the number of statements
379 * that need to be written to the output smaller. In general,
380 * the problem of handling interdependent properties is reduced to
381 * that of finding an order for the properties in
382 * a class such that no property value depends on the value of
383 * a subsequent property.
384 *
385 * @param oldInstance The instance to be copied.
386 * @param newInstance The instance that is to be modified.
387 * @param out The stream to which any initialization statements should be written.
388 *
389 * @throws NullPointerException if {@code out} is {@code null}
390 *
391 * @see java.beans.Introspector#getBeanInfo
392 * @see java.beans.PropertyDescriptor
393 */
394 protected void initialize(Class<?> type,
395 Object oldInstance, Object newInstance,
396 Encoder out)
397 {
398 // System.out.println("DefulatPD:initialize" + type);
399 super.initialize(type, oldInstance, newInstance, out);
400 if (oldInstance.getClass() == type) { // !type.isInterface()) {
401 initBean(type, oldInstance, newInstance, out);
402 }
403 }
404
|
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
365 * the property value has not changed there is no need to
366 * call the corresponding "setter" method and no statement
367 * is emitted. If not however, the expression for this value
368 * is replaced with another expression (normally a constructor)
369 * and the corresponding "setter" method is called to install
370 * the new property value in the object. This scheme removes
371 * default information from the output produced by streams
372 * using this delegate.
373 * <p>
374 * In passing these statements to the output stream, where they
375 * will be executed, side effects are made to the <code>newInstance</code>.
376 * In most cases this allows the problem of properties
377 * whose values depend on each other to actually help the
378 * serialization process by making the number of statements
379 * that need to be written to the output smaller. In general,
380 * the problem of handling interdependent properties is reduced to
381 * that of finding an order for the properties in
382 * a class such that no property value depends on the value of
383 * a subsequent property.
384 *
385 * @param type the type of the instances
386 * @param oldInstance The instance to be copied.
387 * @param newInstance The instance that is to be modified.
388 * @param out The stream to which any initialization statements should be written.
389 *
390 * @throws NullPointerException if {@code out} is {@code null}
391 *
392 * @see java.beans.Introspector#getBeanInfo
393 * @see java.beans.PropertyDescriptor
394 */
395 protected void initialize(Class<?> type,
396 Object oldInstance, Object newInstance,
397 Encoder out)
398 {
399 // System.out.println("DefulatPD:initialize" + type);
400 super.initialize(type, oldInstance, newInstance, out);
401 if (oldInstance.getClass() == type) { // !type.isInterface()) {
402 initBean(type, oldInstance, newInstance, out);
403 }
404 }
405
|