src/java.desktop/share/classes/java/beans/beancontext/BeanContextSupport.java
author darcy
Tue, 24 Sep 2019 18:25:54 -0700
changeset 58309 c6f8b2c3dc66
parent 51116 7e34f3da2293
permissions -rw-r--r--
8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22265
1f8702989948 8031589: Fix doclint issues in java.beans.beancontext
darcy
parents: 21278
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.beans.beancontext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.beans.Beans;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.beans.AppletInitializer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.beans.DesignMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.beans.PropertyChangeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.beans.VetoableChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.beans.VetoableChangeSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.beans.PropertyVetoException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.beans.Visibility;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * This helper class provides a utility implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * java.beans.beancontext.BeanContext interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Since this class directly implements the BeanContext interface, the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * can, and is intended to be used either by subclassing this implementation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * or via ad-hoc delegation of an instance of this class from another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @author Laurence P. G. Cable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
public class      BeanContextSupport extends BeanContextChildSupport
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
       implements BeanContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                  Serializable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                  PropertyChangeListener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                  VetoableChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // Fix for bug 4282900 to pass JCK regression test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    static final long serialVersionUID = -4879613978649577204L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Construct a BeanContextSupport instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
    88
     * @param peer      The peer {@code BeanContext} we are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *                  supplying an implementation for,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
    90
     *                  or {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *                  if this object is its own peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param lcle      The current Locale for this BeanContext. If
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
    93
     *                  {@code lcle} is {@code null}, the default locale
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
    94
     *                  is assigned to the {@code BeanContext} instance.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param dTime     The initial state,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
    96
     *                  {@code true} if in design mode,
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
    97
     *                  {@code false} if runtime.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param visible   The initial visibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @see java.util.Locale#getDefault()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @see java.util.Locale#setDefault(java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public BeanContextSupport(BeanContext peer, Locale lcle, boolean dTime, boolean visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        super(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        locale          = lcle != null ? lcle : Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        designTime      = dTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        okToUseGui      = visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Create an instance using the specified Locale and design mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   115
     * @param peer      The peer {@code BeanContext} we
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *                  are supplying an implementation for,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   117
     *                  or {@code null} if this object is its own peer
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   118
     * @param lcle      The current Locale for this {@code BeanContext}. If
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   119
     *                  {@code lcle} is {@code null}, the default locale
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   120
     *                  is assigned to the {@code BeanContext} instance.
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   121
     * @param dtime     The initial state, {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *                  if in design mode,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   123
     *                  {@code false} if runtime.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @see java.util.Locale#getDefault()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @see java.util.Locale#setDefault(java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        this (peer, lcle, dtime, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Create an instance using the specified locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param peer      The peer BeanContext we are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *                  supplying an implementation for,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   136
     *                  or {@code null} if this object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *                  is its own peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param lcle      The current Locale for this
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   139
     *                  {@code BeanContext}. If
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   140
     *                  {@code lcle} is {@code null},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *                  the default locale
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   142
     *                  is assigned to the {@code BeanContext}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *                  instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @see java.util.Locale#getDefault()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @see java.util.Locale#setDefault(java.util.Locale)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public BeanContextSupport(BeanContext peer, Locale lcle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        this (peer, lcle, false, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * Create an instance using with a default locale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   154
     * @param peer      The peer {@code BeanContext} we are
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *                  supplying an implementation for,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   156
     *                  or {@code null} if this object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *                  is its own peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public BeanContextSupport(BeanContext peer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        this (peer, null, false, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Create an instance that is not a delegate of another object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public BeanContextSupport() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        this (null, null, false, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   172
     * Gets the instance of {@code BeanContext} that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * this object is providing the implementation for.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @return the BeanContext instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public BeanContext getBeanContextPeer() { return (BeanContext)getBeanContextChildPeer(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * The instantiateChild method is a convenience hook
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * in BeanContext to simplify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * the task of instantiating a Bean, nested,
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   183
     * into a {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <p>
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19213
diff changeset
   186
     * The semantics of the beanName parameter are defined by java.beans.Beans.instantiate.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param beanName the name of the Bean to instantiate within this BeanContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @throws IOException if there is an I/O error when the bean is being deserialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @throws ClassNotFoundException if the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * identified by the beanName parameter is not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @return the new object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public Object instantiateChild(String beanName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
           throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        BeanContext bc = getBeanContextPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return Beans.instantiate(bc.getClass().getClassLoader(), beanName, bc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Gets the number of children currently nested in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * this BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return number of children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public int size() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            return children.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * Reports whether or not this
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   216
     * {@code BeanContext} is empty.
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   217
     * A {@code BeanContext} is considered
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * empty when it contains zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * nested children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @return if there are not children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public boolean isEmpty() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return children.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Determines whether or not the specified object
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   230
     * is currently a child of this {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @param o the Object in question
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @return if this object is a child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public boolean contains(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            return children.containsKey(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Determines whether or not the specified object
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   242
     * is currently a child of this {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @param o the Object in question
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @return if this object is a child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public boolean containsKey(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            return children.containsKey(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   253
     * Gets all JavaBean or {@code BeanContext} instances
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   254
     * currently nested in this {@code BeanContext}.
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   255
     * @return an {@code Iterator} of the nested children
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   257
    public Iterator<Object> iterator() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            return new BCSIterator(children.keySet().iterator());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   264
     * Gets all JavaBean or {@code BeanContext}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * instances currently nested in this BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    public Object[] toArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            return children.keySet().toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Gets an array containing all children of
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   275
     * this {@code BeanContext} that match
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * the types contained in arry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @param arry The array of object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * types that are of interest.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @return an array of children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    public Object[] toArray(Object[] arry) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            return children.keySet().toArray(arry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    /************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * protected final subclass that encapsulates an iterator but implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * a noop remove() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   295
    protected static final class BCSIterator implements Iterator<Object> {
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   296
        BCSIterator(Iterator<?> i) { super(); src = i; }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        public boolean hasNext() { return src.hasNext(); }
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   299
        public Object       next()    { return src.next();    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        public void    remove()  { /* do nothing */      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   302
        private Iterator<?> src;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * protected nested class containing per child information, an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * of which is associated with each child in the "children" hashtable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * subclasses can extend this class to include their own per-child state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Note that this 'value' is serialized with the corresponding child 'key'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * when the BeanContextSupport is serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    protected class BCSChild implements Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    private static final long serialVersionUID = -5815286101609939109L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        BCSChild(Object bcc, Object peer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            child     = bcc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            proxyPeer = peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        Object  getChild()                  { return child; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        void    setRemovePending(boolean v) { removePending = v; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        boolean isRemovePending()           { return removePending; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        boolean isProxyPeer()               { return proxyPeer != null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        Object  getProxyPeer()              { return proxyPeer; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
         * fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
58309
c6f8b2c3dc66 8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents: 51116
diff changeset
   341
        @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        private           Object   child;
58309
c6f8b2c3dc66 8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents: 51116
diff changeset
   343
        @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        private           Object   proxyPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        private transient boolean  removePending;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * Subclasses can override this method to insert their own subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * of Child without having to override add() or the other Collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * methods that add children to the set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @param targetChild the child to create the Child on behalf of
22265
1f8702989948 8031589: Fix doclint issues in java.beans.beancontext
darcy
parents: 21278
diff changeset
   356
     * @param peer        the peer if the tragetChild and the peer are related by an implementation of BeanContextProxy
1f8702989948 8031589: Fix doclint issues in java.beans.beancontext
darcy
parents: 21278
diff changeset
   357
     * @return Subtype-specific subclass of Child without overriding collection methods
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    protected BCSChild createBCSChild(Object targetChild, Object peer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        return new BCSChild(targetChild, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   367
     * Adds/nests a child within this {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * Invoked as a side effect of java.beans.Beans.instantiate().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * If the child object is not valid for adding then this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * throws an IllegalStateException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @param targetChild The child objects to nest
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   376
     * within this {@code BeanContext}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * @return true if the child was added successfully.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see #validatePendingAdd
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    public boolean add(Object targetChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        if (targetChild == null) throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        // The specification requires that we do nothing if the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        // is already nested herein.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        if (children.containsKey(targetChild)) return false; // test before locking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        synchronized(BeanContext.globalHierarchyLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            if (children.containsKey(targetChild)) return false; // check again
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            if (!validatePendingAdd(targetChild)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                throw new IllegalStateException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            // The specification requires that we invoke setBeanContext() on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            // newly added child if it implements the java.beans.beancontext.BeanContextChild interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            BeanContextChild cbcc  = getChildBeanContextChild(targetChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            BeanContextChild  bccp = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            synchronized(targetChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                if (targetChild instanceof BeanContextProxy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                    bccp = ((BeanContextProxy)targetChild).getBeanContextProxy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                    if (bccp == null) throw new NullPointerException("BeanContextPeer.getBeanContextProxy()");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                BCSChild bcsc  = createBCSChild(targetChild, bccp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                BCSChild pbcsc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                synchronized (children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                    children.put(targetChild, bcsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                    if (bccp != null) children.put(bccp, pbcsc = createBCSChild(bccp, targetChild));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                if (cbcc != null) synchronized(cbcc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                        cbcc.setBeanContext(getBeanContextPeer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                    } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                        synchronized (children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                            children.remove(targetChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                            if (bccp != null) children.remove(bccp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                        throw new IllegalStateException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                    cbcc.addPropertyChangeListener("beanContext", childPCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    cbcc.addVetoableChangeListener("beanContext", childVCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                Visibility v = getChildVisibility(targetChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    if (okToUseGui)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        v.okToUseGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        v.dontUseGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                if (getChildSerializable(targetChild) != null) serializable++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                childJustAddedHook(targetChild, bcsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                if (bccp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    v = getChildVisibility(bccp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                    if (v != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                        if (okToUseGui)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                            v.okToUseGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                            v.dontUseGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    if (getChildSerializable(bccp) != null) serializable++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    childJustAddedHook(bccp, pbcsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            // The specification requires that we fire a notification of the change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            fireChildrenAdded(new BeanContextMembershipEvent(getBeanContextPeer(), bccp == null ? new Object[] { targetChild } : new Object[] { targetChild, bccp } ));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * Removes a child from this BeanContext.  If the child object is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * for adding then this method throws an IllegalStateException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @param targetChild The child objects to remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @see #validatePendingRemove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    public boolean remove(Object targetChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        return remove(targetChild, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * internal remove used when removal caused by
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   490
     * unexpected {@code setBeanContext} or
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   491
     * by {@code remove()} invocation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @param targetChild the JavaBean, BeanContext, or Object to be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @param callChildSetBC used to indicate that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * the child should be notified that it is no
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   495
     * longer nested in this {@code BeanContext}.
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   496
     * @return whether or not was present before being removed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    protected boolean remove(Object targetChild, boolean callChildSetBC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        if (targetChild == null) throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        synchronized(BeanContext.globalHierarchyLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            if (!containsKey(targetChild)) return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            if (!validatePendingRemove(targetChild)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                throw new IllegalStateException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   509
            BCSChild bcsc  = children.get(targetChild);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            BCSChild pbcsc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            Object   peer  = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            // we are required to notify the child that it is no longer nested here if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            // it implements java.beans.beancontext.BeanContextChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            synchronized(targetChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                if (callChildSetBC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    BeanContextChild cbcc = getChildBeanContextChild(targetChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                    if (cbcc != null) synchronized(cbcc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                        cbcc.removePropertyChangeListener("beanContext", childPCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                        cbcc.removeVetoableChangeListener("beanContext", childVCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                            cbcc.setBeanContext(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                        } catch (PropertyVetoException pve1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                            cbcc.addPropertyChangeListener("beanContext", childPCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                            cbcc.addVetoableChangeListener("beanContext", childVCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                            throw new IllegalStateException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                synchronized (children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                    children.remove(targetChild);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                    if (bcsc.isProxyPeer()) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   538
                        pbcsc = children.get(peer = bcsc.getProxyPeer());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                        children.remove(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                if (getChildSerializable(targetChild) != null) serializable--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                childJustRemovedHook(targetChild, bcsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                    if (getChildSerializable(peer) != null) serializable--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                    childJustRemovedHook(peer, pbcsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            fireChildrenRemoved(new BeanContextMembershipEvent(getBeanContextPeer(), peer == null ? new Object[] { targetChild } : new Object[] { targetChild, peer } ));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * Tests to see if all objects in the
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   563
     * specified {@code Collection} are children of
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   564
     * this {@code BeanContext}.
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   565
     * @param c the specified {@code Collection}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   567
     * @return {@code true} if all objects
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * in the collection are children of
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   569
     * this {@code BeanContext}, false if not.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   571
    @SuppressWarnings("rawtypes")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    public boolean containsAll(Collection c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        synchronized(children) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   574
            Iterator<?> i = c.iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            while (i.hasNext())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                if(!contains(i.next()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * add Collection to set of Children (Unsupported)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * implementations must synchronized on the hierarchy lock and "children" protected field
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   586
     * @throws UnsupportedOperationException thrown unconditionally by this implementation
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   587
     * @return this implementation unconditionally throws {@code UnsupportedOperationException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   589
    @SuppressWarnings("rawtypes")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    public boolean addAll(Collection c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * remove all specified children (Unsupported)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * implementations must synchronized on the hierarchy lock and "children" protected field
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   597
     * @throws UnsupportedOperationException thrown unconditionally by this implementation
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   598
     * @return this implementation unconditionally throws {@code UnsupportedOperationException}
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   599
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   601
    @SuppressWarnings("rawtypes")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public boolean removeAll(Collection c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * retain only specified children (Unsupported)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * implementations must synchronized on the hierarchy lock and "children" protected field
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   610
     * @throws UnsupportedOperationException thrown unconditionally by this implementation
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   611
     * @return this implementation unconditionally throws {@code UnsupportedOperationException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   613
    @SuppressWarnings("rawtypes")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    public boolean retainAll(Collection c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * clear the children (Unsupported)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * implementations must synchronized on the hierarchy lock and "children" protected field
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   621
     * @throws UnsupportedOperationException thrown unconditionally by this implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public void clear() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * Adds a BeanContextMembershipListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * @param  bcml the BeanContextMembershipListener to add
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   631
     * @throws NullPointerException if the argument is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    public void addBeanContextMembershipListener(BeanContextMembershipListener bcml) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        if (bcml == null) throw new NullPointerException("listener");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        synchronized(bcmListeners) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            if (bcmListeners.contains(bcml))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                bcmListeners.add(bcml);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * Removes a BeanContextMembershipListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * @param  bcml the BeanContextMembershipListener to remove
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   649
     * @throws NullPointerException if the argument is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    public void removeBeanContextMembershipListener(BeanContextMembershipListener bcml) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        if (bcml == null) throw new NullPointerException("listener");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        synchronized(bcmListeners) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            if (!bcmListeners.contains(bcml))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                bcmListeners.remove(bcml);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * @param name the name of the resource requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * @param bcc  the child object making the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @return  the requested resource as an InputStream
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   668
     * @throws  NullPointerException if the argument is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public InputStream getResourceAsStream(String name, BeanContextChild bcc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        if (name == null) throw new NullPointerException("name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        if (bcc  == null) throw new NullPointerException("bcc");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        if (containsKey(bcc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            ClassLoader cl = bcc.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            return cl != null ? cl.getResourceAsStream(name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                              : ClassLoader.getSystemResourceAsStream(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        } else throw new IllegalArgumentException("Not a valid child");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @param name the name of the resource requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @param bcc  the child object making the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * @return the requested resource as an InputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    public URL getResource(String name, BeanContextChild bcc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        if (name == null) throw new NullPointerException("name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        if (bcc  == null) throw new NullPointerException("bcc");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        if (containsKey(bcc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            ClassLoader cl = bcc.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            return cl != null ? cl.getResource(name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                              : ClassLoader.getSystemResource(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        } else throw new IllegalArgumentException("Not a valid child");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   703
     * Sets the new design time value for this {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @param dTime the new designTime value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    public synchronized void setDesignTime(boolean dTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        if (designTime != dTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            designTime = dTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            firePropertyChange("designMode", Boolean.valueOf(!dTime), Boolean.valueOf(dTime));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * Reports whether or not this object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * currently in design time mode.
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   718
     * @return {@code true} if in design time mode,
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   719
     * {@code false} if not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    public synchronized boolean isDesignTime() { return designTime; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * Sets the locale of this BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * @param newLocale the new locale. This method call will have
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   726
     *        no effect if newLocale is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * @throws PropertyVetoException if the new value is rejected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    public synchronized void setLocale(Locale newLocale) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        if ((locale != null && !locale.equals(newLocale)) && newLocale != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            Locale old = locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            fireVetoableChange("locale", old, newLocale); // throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            locale = newLocale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            firePropertyChange("locale", old, newLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   743
     * Gets the locale for this {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     *
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   745
     * @return the current Locale of the {@code BeanContext}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    public synchronized Locale getLocale() { return locale; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * This method is typically called from the environment in order to determine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * if the implementor "needs" a GUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * The algorithm used herein tests the BeanContextPeer, and its current children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * to determine if they are either Containers, Components, or if they implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * Visibility and return needsGui() == true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * </p>
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   759
     * @return {@code true} if the implementor needs a GUI
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    public synchronized boolean needsGui() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        BeanContext bc = getBeanContextPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        if (bc != this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            if (bc instanceof Visibility) return ((Visibility)bc).needsGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
            if (bc instanceof Container || bc instanceof Component)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        synchronized(children) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   772
            for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                Object c = i.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                        return ((Visibility)c).needsGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                    } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                        // do nothing ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                    if (c instanceof Container || c instanceof Component)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * notify this instance that it may no longer render a GUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    public synchronized void dontUseGui() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        if (okToUseGui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            okToUseGui = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            // lets also tell the Children that can that they may not use their GUI's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            synchronized(children) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   799
                for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                    Visibility v = getChildVisibility(i.next());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                    if (v != null) v.dontUseGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
               }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * Notify this instance that it may now render a GUI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    public synchronized void okToUseGui() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        if (!okToUseGui) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            okToUseGui = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            // lets also tell the Children that can that they may use their GUI's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            synchronized(children) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   818
                for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                    Visibility v = getChildVisibility(i.next());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                    if (v != null) v.okToUseGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   828
     * Used to determine if the {@code BeanContext}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * child is avoiding using its GUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * @return is this instance avoiding using its GUI?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * @see Visibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    public boolean avoidingGui() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        return !okToUseGui && needsGui();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   838
     * Is this {@code BeanContext} in the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * process of being serialized?
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   840
     * @return if this {@code BeanContext} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * currently being serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    public boolean isSerializing() { return serializing; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * Returns an iterator of all children
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   847
     * of this {@code BeanContext}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * @return an iterator for all the current BCSChild values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   850
    protected Iterator<BCSChild> bcsChildren() { synchronized(children) { return children.values().iterator();  } }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * called by writeObject after defaultWriteObject() but prior to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     * serialization of currently serializable children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * This method may be overridden by subclasses to perform custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * serialization of their state prior to this superclass serializing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * the children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * This method should not however be used by subclasses to replace their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * own implementation (if any) of writeObject().
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   862
     * @param oos the {@code ObjectOutputStream} to use during serialization
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   863
     * @throws IOException if serialization failed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    protected void bcsPreSerializationHook(ObjectOutputStream oos) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * called by readObject after defaultReadObject() but prior to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * deserialization of any children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * This method may be overridden by subclasses to perform custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * deserialization of their state prior to this superclass deserializing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * the children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * This method should not however be used by subclasses to replace their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * own implementation (if any) of readObject().
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   879
     * @param ois the {@code ObjectInputStream} to use during deserialization
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   880
     * @throws IOException if deserialization failed
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   881
     * @throws ClassNotFoundException if needed classes are not found
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    protected void bcsPreDeserializationHook(ObjectInputStream ois) throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * Called by readObject with the newly deserialized child and BCSChild.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     * @param child the newly deserialized child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     * @param bcsc the newly deserialized BCSChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    protected void childDeserializedHook(Object child, BCSChild bcsc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            children.put(child, bcsc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * Used by writeObject to serialize a Collection.
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   900
     * @param oos the {@code ObjectOutputStream}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * to use during serialization
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   902
     * @param coll the {@code Collection} to serialize
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * @throws IOException if serialization failed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   905
    protected final void serialize(ObjectOutputStream oos, Collection<?> coll) throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        int      count   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        Object[] objects = coll.toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        for (int i = 0; i < objects.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            if (objects[i] instanceof Serializable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                count++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                objects[i] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        oos.writeInt(count); // number of subsequent objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        for (int i = 0; count > 0; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            Object o = objects[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            if (o != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                oos.writeObject(o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                count--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * used by readObject to deserialize a collection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     * @param ois the ObjectInputStream to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     * @param coll the Collection
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   932
     * @throws IOException if deserialization failed
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
   933
     * @throws ClassNotFoundException if needed classes are not found
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   935
    @SuppressWarnings({"rawtypes", "unchecked"})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    protected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        int count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        count = ois.readInt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        while (count-- > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            coll.add(ois.readObject());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     * Used to serialize all children of
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   948
     * this {@code BeanContext}.
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
   949
     * @param oos the {@code ObjectOutputStream}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * to use during serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * @throws IOException if serialization failed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    public final void writeChildren(ObjectOutputStream oos) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        if (serializable <= 0) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        boolean prev = serializing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        serializing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        int count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        synchronized(children) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   963
            Iterator<Map.Entry<Object, BCSChild>> i = children.entrySet().iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            while (i.hasNext() && count < serializable) {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
   966
                Map.Entry<Object, BCSChild> entry = i.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                if (entry.getKey() instanceof Serializable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                        oos.writeObject(entry.getKey());   // child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                        oos.writeObject(entry.getValue()); // BCSChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                    } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                        serializing = prev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                        throw ioe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    count++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        serializing = prev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        if (count != serializable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            throw new IOException("wrote different number of children than expected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * Serialize the BeanContextSupport, if this instance has a distinct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * peer (that is this object is acting as a delegate for another) then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * the children of this instance are not serialized here due to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * 'chicken and egg' problem that occurs on deserialization of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * children at the same time as this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * Therefore in situations where there is a distinct peer to this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * it should always call writeObject() followed by writeChildren() and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * readObject() followed by readChildren().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * @param oos the ObjectOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
51116
7e34f3da2293 8203263: Remove unnecessary throws clauses from serialization-related methods
darcy
parents: 47216
diff changeset
  1003
    private synchronized void writeObject(ObjectOutputStream oos) throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        serializing = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        synchronized (BeanContext.globalHierarchyLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                oos.defaultWriteObject(); // serialize the BeanContextSupport object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                bcsPreSerializationHook(oos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                if (serializable > 0 && this.equals(getBeanContextPeer()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                    writeChildren(oos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                serialize(oos, (Collection)bcmListeners);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                serializing = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * When an instance of this class is used as a delegate for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * implementation of the BeanContext protocols (and its subprotocols)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * there exists a 'chicken and egg' problem during deserialization
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1026
     * @param ois the ObjectInputStream to use
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1027
     * @throws IOException if deserialization failed
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1028
     * @throws ClassNotFoundException if needed classes are not found
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    public final void readChildren(ObjectInputStream ois) throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        int count = serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        while (count-- > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
            Object                      child = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
            BeanContextSupport.BCSChild bscc  = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                child = ois.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                bscc  = (BeanContextSupport.BCSChild)ois.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            } catch (ClassNotFoundException cnfe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            synchronized(child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                BeanContextChild bcc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                    bcc = (BeanContextChild)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                    // do nothing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                if (bcc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                        bcc.setBeanContext(getBeanContextPeer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                       bcc.addPropertyChangeListener("beanContext", childPCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                       bcc.addVetoableChangeListener("beanContext", childVCL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                    } catch (PropertyVetoException pve) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                childDeserializedHook(child, bscc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * deserialize contents ... if this instance has a distinct peer the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * children are *not* serialized here, the peer's readObject() must call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     * readChildren() after deserializing this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    private synchronized void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        synchronized(BeanContext.globalHierarchyLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            ois.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
            initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            bcsPreDeserializationHook(ois);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            if (serializable > 0 && this.equals(getBeanContextPeer()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                readChildren(ois);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1092
            deserialize(ois, bcmListeners = new ArrayList<>(1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * subclasses may envelope to monitor veto child property changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        String propertyName = pce.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        Object source       = pce.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            if ("beanContext".equals(propertyName) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                containsKey(source)                    &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                !getBeanContextPeer().equals(pce.getNewValue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
            ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                if (!validatePendingRemove(source)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                    throw new PropertyVetoException("current BeanContext vetoes setBeanContext()", pce);
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1111
                } else children.get(source).setRemovePending(true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     * subclasses may envelope to monitor child property changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    public void propertyChange(PropertyChangeEvent pce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        String propertyName = pce.getPropertyName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        Object source       = pce.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
        synchronized(children) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            if ("beanContext".equals(propertyName) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                containsKey(source)                    &&
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1127
                children.get(source).isRemovePending()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                BeanContext bc = getBeanContextPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                if (bc.equals(pce.getOldValue()) && !bc.equals(pce.getNewValue())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                    remove(source, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                } else {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1133
                    children.get(source).setRemovePending(false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
     * Subclasses of this class may override, or envelope, this method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
     * add validation behavior for the BeanContext to examine child objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
     * immediately prior to their being added to the BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
     *
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1146
     * @param targetChild the child to create the Child on behalf of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     * @return true iff the child may be added to this BeanContext, otherwise false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
    protected boolean validatePendingAdd(Object targetChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     * Subclasses of this class may override, or envelope, this method to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     * add validation behavior for the BeanContext to examine child objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     * immediately prior to their being removed from the BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     *
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1161
     * @param targetChild the child to create the Child on behalf of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * @return true iff the child may be removed from this BeanContext, otherwise false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
    protected boolean validatePendingRemove(Object targetChild) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
     * subclasses may override this method to simply extend add() semantics
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     * after the child has been added and before the event notification has
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     * occurred. The method is called with the child synchronized.
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1173
     * @param child the child
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1174
     * @param bcsc the BCSChild
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
    protected void childJustAddedHook(Object child, BCSChild bcsc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * subclasses may override this method to simply extend remove() semantics
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     * after the child has been removed and before the event notification has
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * occurred. The method is called with the child synchronized.
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1184
     * @param child the child
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1185
     * @param bcsc the BCSChild
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    protected void childJustRemovedHook(Object child, BCSChild bcsc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * Gets the Component (if any) associated with the specified child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     * @param child the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * @return the Component (if any) associated with the specified child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
    protected static final Visibility getChildVisibility(Object child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
            return (Visibility)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
     * Gets the Serializable (if any) associated with the specified Child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * @param child the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     * @return the Serializable (if any) associated with the specified Child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    protected static final Serializable getChildSerializable(Object child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
            return (Serializable)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
     * Gets the PropertyChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
     * (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * @param child the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     * @return the PropertyChangeListener (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
    protected static final PropertyChangeListener getChildPropertyChangeListener(Object child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            return (PropertyChangeListener)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     * Gets the VetoableChangeListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     * (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     * @param child the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
     * @return the VetoableChangeListener (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
    protected static final VetoableChangeListener getChildVetoableChangeListener(Object child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            return (VetoableChangeListener)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     * Gets the BeanContextMembershipListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
     * (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
     * @param child the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
     * @return the BeanContextMembershipListener (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
    protected static final BeanContextMembershipListener getChildBeanContextMembershipListener(Object child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            return (BeanContextMembershipListener)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * Gets the BeanContextChild (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * @param child the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     * @return  the BeanContextChild (if any) of the specified child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
     * @throws  IllegalArgumentException if child implements both BeanContextChild and BeanContextProxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
    protected static final BeanContextChild getChildBeanContextChild(Object child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
            BeanContextChild bcc = (BeanContextChild)child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
            if (child instanceof BeanContextChild && child instanceof BeanContextProxy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                throw new IllegalArgumentException("child cannot implement both BeanContextChild and BeanContextProxy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                return bcc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        } catch (ClassCastException cce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
                return ((BeanContextProxy)child).getBeanContextProxy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            } catch (ClassCastException cce1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1284
     * @param bcme the event to fire
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    protected final void fireChildrenAdded(BeanContextMembershipEvent bcme) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        Object[] copy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
        synchronized(bcmListeners) { copy = bcmListeners.toArray(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
        for (int i = 0; i < copy.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            ((BeanContextMembershipListener)copy[i]).childrenAdded(bcme);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
     * Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
19213
c360667a0da2 8022406: Fix doclint issues in java.beans
darcy
parents: 5506
diff changeset
  1298
     * @param bcme the event to fire
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
    protected final void fireChildrenRemoved(BeanContextMembershipEvent bcme) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
        Object[] copy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
        synchronized(bcmListeners) { copy = bcmListeners.toArray(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
        for (int i = 0; i < copy.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
            ((BeanContextMembershipListener)copy[i]).childrenRemoved(bcme);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     * protected method called from constructor and readObject to initialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
     * transient state of BeanContextSupport instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
     * This class uses this method to instantiate inner class listeners used
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
     * to monitor PropertyChange and VetoableChange events on children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
     * subclasses may envelope this method to add their own initialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     * behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
    protected synchronized void initialize() {
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1322
        children     = new HashMap<>(serializable + 1);
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1323
        bcmListeners = new ArrayList<>(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        childPCL = new PropertyChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
             * this adaptor is used by the BeanContextSupport class to forward
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
             * property changes from a child to the BeanContext, avoiding
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
             * accidential serialization of the BeanContext by a badly
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
             * behaved Serializable child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
            public void propertyChange(PropertyChangeEvent pce) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
                BeanContextSupport.this.propertyChange(pce);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
        childVCL = new VetoableChangeListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
             * this adaptor is used by the BeanContextSupport class to forward
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
             * vetoable changes from a child to the BeanContext, avoiding
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
             * accidential serialization of the BeanContext by a badly
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
             * behaved Serializable child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
            public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
                BeanContextSupport.this.vetoableChange(pce);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     * Gets a copy of the this BeanContext's children.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     * @return a copy of the current nested children
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
    protected final Object[] copyChildren() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
        synchronized(children) { return children.keySet().toArray(); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
     * Tests to see if two class objects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
     * or their names are equal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
     * @param first the first object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * @param second the second object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * @return true if equal, false if not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1369
    protected static final boolean classEquals(Class<?> first, Class<?> second) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
        return first.equals(second) || first.getName().equals(second.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
     * fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
  1380
     * all accesses to the {@code protected HashMap children} field
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     * shall be synchronized on that object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1383
    protected transient HashMap<Object, BCSChild>         children;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
    private             int             serializable  = 0; // children serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
  1388
     * all accesses to the {@code protected ArrayList bcmListeners} field
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * shall be synchronized on that object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     */
25123
1f70b30da563 8042860: Fix raw and unchecked warnings in java.beans
darcy
parents: 22265
diff changeset
  1391
    protected transient ArrayList<BeanContextMembershipListener> bcmListeners;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     * The current locale of this BeanContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    protected           Locale          locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
  1401
     * A {@code boolean} indicating if this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
     * instance may now render a GUI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
    protected           boolean         okToUseGui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    /**
32283
1a96ab120a48 8133134: docs: replace <tt> tags (obsolete in html5) for java.desktop
avstepan
parents: 25859
diff changeset
  1408
     * A {@code boolean} indicating whether or not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
     * this object is currently in design time mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
    protected           boolean         designTime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
     * transient
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
    private transient PropertyChangeListener childPCL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
    private transient VetoableChangeListener childVCL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
    private transient boolean                serializing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
}