2362N/A * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This helper class provides a utility implementation of the 0N/A * java.beans.beancontext.BeanContext interface. 0N/A * Since this class directly implements the BeanContext interface, the class 0N/A * can, and is intended to be used either by subclassing this implementation, 0N/A * or via ad-hoc delegation of an instance of this class from another. 0N/A * @author Laurence P. G. Cable 0N/A // Fix for bug 4282900 to pass JCK regression test 0N/A * Construct a BeanContextSupport instance 0N/A * @param peer The peer <tt>BeanContext</tt> we are 0N/A * supplying an implementation for, 0N/A * if this object is its own peer 0N/A * @param lcle The current Locale for this BeanContext. If 0N/A * <tt>lcle</tt> is <tt>null</tt>, the default locale 0N/A * is assigned to the <tt>BeanContext</tt> instance. 0N/A * @param dTime The initial state, 0N/A * <tt>true</tt> if in design mode, 0N/A * <tt>false</tt> if runtime. 0N/A * @param visible The initial visibility. 0N/A * @see java.util.Locale#getDefault() 0N/A * @see java.util.Locale#setDefault(java.util.Locale) 0N/A * Create an instance using the specified Locale and design mode. 0N/A * @param peer The peer <tt>BeanContext</tt> we 0N/A * are supplying an implementation for, 0N/A * or <tt>null</tt> if this object is its own peer 0N/A * @param lcle The current Locale for this <tt>BeanContext</tt>. If 0N/A * <tt>lcle</tt> is <tt>null</tt>, the default locale 0N/A * is assigned to the <tt>BeanContext</tt> instance. 0N/A * @param dtime The initial state, <tt>true</tt> 0N/A * if in design mode, 0N/A * <tt>false</tt> if runtime. 0N/A * @see java.util.Locale#getDefault() 0N/A * @see java.util.Locale#setDefault(java.util.Locale) 0N/A * Create an instance using the specified locale 0N/A * @param peer The peer BeanContext we are 0N/A * supplying an implementation for, 0N/A * or <tt>null</tt> if this object 0N/A * @param lcle The current Locale for this 0N/A * <tt>BeanContext</tt>. If 0N/A * <tt>lcle</tt> is <tt>null</tt>, 0N/A * the default locale 0N/A * is assigned to the <tt>BeanContext</tt> 0N/A * @see java.util.Locale#getDefault() 0N/A * @see java.util.Locale#setDefault(java.util.Locale) 0N/A * Create an instance using with a default locale 0N/A * @param peer The peer <tt>BeanContext</tt> we are 0N/A * supplying an implementation for, 0N/A * or <tt>null</tt> if this object 0N/A * Create an instance that is not a delegate of another object 0N/A * Gets the instance of <tt>BeanContext</tt> that 0N/A * this object is providing the implementation for. 0N/A * @return the BeanContext instance 0N/A * The instantiateChild method is a convenience hook 0N/A * in BeanContext to simplify 0N/A * the task of instantiating a Bean, nested, 0N/A * into a <tt>BeanContext</tt>. 0N/A * The semantics of the beanName parameter are defined by java.beans.Beans.instantate. 0N/A * @param beanName the name of the Bean to instantiate within this BeanContext 0N/A * @throws IOException if there is an I/O error when the bean is being deserialized 0N/A * @throws ClassNotFoundException if the class 0N/A * identified by the beanName parameter is not found 0N/A * @return the new object 0N/A * Gets the number of children currently nested in 0N/A * @return number of children 0N/A * Reports whether or not this 0N/A * <tt>BeanContext</tt> is empty. 0N/A * A <tt>BeanContext</tt> is considered 0N/A * empty when it contains zero 0N/A * @return if there are not children 0N/A * Determines whether or not the specified object 0N/A * is currently a child of this <tt>BeanContext</tt>. 0N/A * @param o the Object in question 0N/A * @return if this object is a child 0N/A * Determines whether or not the specified object 0N/A * is currently a child of this <tt>BeanContext</tt>. 0N/A * @param o the Object in question 0N/A * @return if this object is a child 0N/A * Gets all JavaBean or <tt>BeanContext</tt> instances 0N/A * currently nested in this <tt>BeanContext</tt>. 0N/A * @return an <tt>Iterator</tt> of the nested children 0N/A * Gets all JavaBean or <tt>BeanContext</tt> 0N/A * instances currently nested in this BeanContext. 0N/A * Gets an array containing all children of 0N/A * this <tt>BeanContext</tt> that match 0N/A * the types contained in arry. 0N/A * @param arry The array of object 0N/A * types that are of interest. 0N/A * @return an array of children 0N/A /************************************************************************/ 0N/A * protected final subclass that encapsulates an iterator but implements 0N/A * a noop remove() method. 0N/A /************************************************************************/ 0N/A * protected nested class containing per child information, an instance 0N/A * of which is associated with each child in the "children" hashtable. 0N/A * subclasses can extend this class to include their own per-child state. 0N/A * Note that this 'value' is serialized with the corresponding child 'key' 0N/A * when the BeanContextSupport is serialized. 0N/A * Subclasses can override this method to insert their own subclass 0N/A * of Child without having to override add() or the other Collection 0N/A * methods that add children to the set. 0N/A * @param targetChild the child to create the Child on behalf of 0N/A * @param peer the peer if the tragetChild and the peer are related by an implementation of BeanContextProxy 0N/A /************************************************************************/ 0N/A * Invoked as a side effect of java.beans.Beans.instantiate(). 0N/A * If the child object is not valid for adding then this method 0N/A * throws an IllegalStateException. 0N/A * @param targetChild The child objects to nest 0N/A * within this <tt>BeanContext</tt> 0N/A * @return true if the child was added successfully. 0N/A * @see #validatePendingAdd 0N/A // The specification requires that we do nothing if the child 0N/A // is already nested herein. 0N/A // The specification requires that we invoke setBeanContext() on the 0N/A // newly added child if it implements the java.beans.beancontext.BeanContextChild interface 0N/A // The specification requires that we fire a notification of the change 0N/A * Removes a child from this BeanContext. If the child object is not 0N/A * for adding then this method throws an IllegalStateException. 0N/A * @param targetChild The child objects to remove 0N/A * @see #validatePendingRemove 0N/A * internal remove used when removal caused by 0N/A * unexpected <tt>setBeanContext</tt> or 0N/A * by <tt>remove()</tt> invocation. 0N/A * @param targetChild the JavaBean, BeanContext, or Object to be removed 0N/A * @param callChildSetBC used to indicate that 0N/A * the child should be notified that it is no 0N/A * longer nested in this <tt>BeanContext</tt>. 0N/A // we are required to notify the child that it is no longer nested here if 0N/A // it implements java.beans.beancontext.BeanContextChild 0N/A * Tests to see if all objects in the 0N/A * specified <tt>Collection</tt> are children of 0N/A * this <tt>BeanContext</tt>. 0N/A * @param c the specified <tt>Collection</tt> 0N/A * @return <tt>true</tt> if all objects 0N/A * in the collection are children of 0N/A * this <tt>BeanContext</tt>, false if not. 0N/A * add Collection to set of Children (Unsupported) 0N/A * implementations must synchronized on the hierarchy lock and "children" protected field 0N/A * @throws UnsupportedOperationException 0N/A * remove all specified children (Unsupported) 0N/A * implementations must synchronized on the hierarchy lock and "children" protected field 0N/A * @throws UnsupportedOperationException 0N/A * retain only specified children (Unsupported) 0N/A * implementations must synchronized on the hierarchy lock and "children" protected field 0N/A * @throws UnsupportedOperationException 0N/A * clear the children (Unsupported) 0N/A * implementations must synchronized on the hierarchy lock and "children" protected field 0N/A * @throws UnsupportedOperationException 0N/A * Adds a BeanContextMembershipListener 0N/A * @param bcml the BeanContextMembershipListener to add 0N/A * @throws NullPointerException 0N/A * Removes a BeanContextMembershipListener 0N/A * @param bcml the BeanContextMembershipListener to remove 0N/A * @throws NullPointerException 0N/A * @param name the name of the resource requested. 0N/A * @param bcc the child object making the request. 0N/A * @return the requested resource as an InputStream 0N/A * @throws NullPointerException 0N/A * @param name the name of the resource requested. 0N/A * @param bcc the child object making the request. 0N/A * @return the requested resource as an InputStream 0N/A * Sets the new design time value for this <tt>BeanContext</tt>. 0N/A * @param dTime the new designTime value 0N/A * Reports whether or not this object is in 0N/A * currently in design time mode. 0N/A * @return <tt>true</tt> if in design time mode, 0N/A * <tt>false</tt> if not 0N/A * Sets the locale of this BeanContext. 0N/A * @param newLocale the new locale. This method call will have 0N/A * no effect if newLocale is <CODE>null</CODE>. 0N/A * @throws PropertyVetoException if the new value is rejected 0N/A * Gets the locale for this <tt>BeanContext</tt>. 0N/A * @return the current Locale of the <tt>BeanContext</tt> 0N/A * This method is typically called from the environment in order to determine 0N/A * if the implementor "needs" a GUI. 0N/A * The algorithm used herein tests the BeanContextPeer, and its current children 0N/A * to determine if they are either Containers, Components, or if they implement 0N/A * Visibility and return needsGui() == true. 0N/A * @return <tt>true</tt> if the implementor needs a GUI 0N/A * notify this instance that it may no longer render a GUI. 0N/A // lets also tell the Children that can that they may not use their GUI's 0N/A * Notify this instance that it may now render a GUI 0N/A // lets also tell the Children that can that they may use their GUI's 0N/A * Used to determine if the <tt>BeanContext</tt> 0N/A * child is avoiding using its GUI. 0N/A * @return is this instance avoiding using its GUI? 0N/A * Is this <tt>BeanContext</tt> in the 0N/A * process of being serialized? 0N/A * @return if this <tt>BeanContext</tt> is 0N/A * currently being serialized 0N/A * Returns an iterator of all children 0N/A * of this <tt>BeanContext</tt>. 0N/A * @return an iterator for all the current BCSChild values 0N/A * called by writeObject after defaultWriteObject() but prior to 0N/A * serialization of currently serializable children. 0N/A * This method may be overridden by subclasses to perform custom 0N/A * serialization of their state prior to this superclass serializing 0N/A * This method should not however be used by subclasses to replace their 0N/A * own implementation (if any) of writeObject(). 0N/A * called by readObject after defaultReadObject() but prior to 0N/A * deserialization of any children. 0N/A * This method may be overridden by subclasses to perform custom 0N/A * deserialization of their state prior to this superclass deserializing 0N/A * This method should not however be used by subclasses to replace their 0N/A * own implementation (if any) of readObject(). 0N/A * Called by readObject with the newly deserialized child and BCSChild. 0N/A * @param child the newly deserialized child 0N/A * @param bcsc the newly deserialized BCSChild 0N/A * Used by writeObject to serialize a Collection. 0N/A * @param oos the <tt>ObjectOutputStream</tt> 0N/A * to use during serialization 0N/A * @param coll the <tt>Collection</tt> to serialize 0N/A * @throws IOException if serialization failed 0N/A * used by readObject to deserialize a collection. 0N/A * @param ois the ObjectInputStream to use 0N/A * @param coll the Collection 0N/A * Used to serialize all children of 0N/A * this <tt>BeanContext</tt>. 0N/A * @param oos the <tt>ObjectOutputStream</tt> 0N/A * to use during serialization 0N/A * @throws IOException if serialization failed 0N/A throw new IOException(
"wrote different number of children than expected");
0N/A * Serialize the BeanContextSupport, if this instance has a distinct 0N/A * peer (that is this object is acting as a delegate for another) then 0N/A * the children of this instance are not serialized here due to a 0N/A * 'chicken and egg' problem that occurs on deserialization of the 0N/A * children at the same time as this instance. 0N/A * Therefore in situations where there is a distinct peer to this instance 0N/A * it should always call writeObject() followed by writeChildren() and 0N/A * readObject() followed by readChildren(). 0N/A * @param oos the ObjectOutputStream 0N/A * When an instance of this class is used as a delegate for the 0N/A * implementation of the BeanContext protocols (and its subprotocols) 0N/A * there exists a 'chicken and egg' problem during deserialization 0N/A * deserialize contents ... if this instance has a distinct peer the 0N/A * children are *not* serialized here, the peer's readObject() must call 0N/A * readChildren() after deserializing this instance. 0N/A * subclasses may envelope to monitor veto child property changes. 0N/A * subclasses may envelope to monitor child property changes. 0N/A * Subclasses of this class may override, or envelope, this method to 0N/A * add validation behavior for the BeanContext to examine child objects 0N/A * immediately prior to their being added to the BeanContext. 0N/A * @return true iff the child may be added to this BeanContext, otherwise false. 0N/A * Subclasses of this class may override, or envelope, this method to 0N/A * add validation behavior for the BeanContext to examine child objects 0N/A * immediately prior to their being removed from the BeanContext. 0N/A * @return true iff the child may be removed from this BeanContext, otherwise false. 0N/A * subclasses may override this method to simply extend add() semantics 0N/A * after the child has been added and before the event notification has 0N/A * occurred. The method is called with the child synchronized. 0N/A * subclasses may override this method to simply extend remove() semantics 0N/A * after the child has been removed and before the event notification has 0N/A * occurred. The method is called with the child synchronized. 0N/A * Gets the Component (if any) associated with the specified child. 0N/A * @param child the specified child 0N/A * @return the Component (if any) associated with the specified child. 0N/A * Gets the Serializable (if any) associated with the specified Child 0N/A * @param child the specified child 0N/A * @return the Serializable (if any) associated with the specified Child 0N/A * Gets the PropertyChangeListener 0N/A * (if any) of the specified child 0N/A * @param child the specified child 0N/A * @return the PropertyChangeListener (if any) of the specified child 0N/A * Gets the VetoableChangeListener 0N/A * (if any) of the specified child 0N/A * @param child the specified child 0N/A * @return the VetoableChangeListener (if any) of the specified child 0N/A * Gets the BeanContextMembershipListener 0N/A * (if any) of the specified child 0N/A * @param child the specified child 0N/A * @return the BeanContextMembershipListener (if any) of the specified child 0N/A * Gets the BeanContextChild (if any) of the specified child 0N/A * @param child the specified child 0N/A * @return the BeanContextChild (if any) of the specified child 0N/A * @throws IllegalArgumentException if child implements both BeanContextChild and BeanContextProxy 0N/A * Fire a BeanContextshipEvent on the BeanContextMembershipListener interface 0N/A * Fire a BeanContextshipEvent on the BeanContextMembershipListener interface 0N/A * protected method called from constructor and readObject to initialize 0N/A * transient state of BeanContextSupport instance. 0N/A * This class uses this method to instantiate inner class listeners used 0N/A * to monitor PropertyChange and VetoableChange events on children. 0N/A * subclasses may envelope this method to add their own initialization 0N/A * this adaptor is used by the BeanContextSupport class to forward 0N/A * property changes from a child to the BeanContext, avoiding 0N/A * accidential serialization of the BeanContext by a badly 0N/A * behaved Serializable child. 0N/A * this adaptor is used by the BeanContextSupport class to forward 0N/A * vetoable changes from a child to the BeanContext, avoiding 0N/A * accidential serialization of the BeanContext by a badly 0N/A * behaved Serializable child. 0N/A * Gets a copy of the this BeanContext's children. 0N/A * @return a copy of the current nested children 0N/A * Tests to see if two class objects, 0N/A * or their names are equal. 0N/A * @param first the first object 0N/A * @param second the second object 0N/A * @return true if equal, false if not 0N/A * all accesses to the <code> protected HashMap children </code> field 0N/A * shall be synchronized on that object. 0N/A * all accesses to the <code> protected ArrayList bcmListeners </code> field 0N/A * shall be synchronized on that object. 0N/A * The current locale of this BeanContext. 0N/A * A <tt>boolean</tt> indicating if this 0N/A * instance may now render a GUI. 0N/A * A <tt>boolean</tt> indicating whether or not 0N/A * this object is currently in design time mode.