java.lang.Object
   ↳ java.beans.beancontext.BeanContextChildSupport
     ↳ java.beans.beancontext.BeanContextSupport
Known Direct Subclasses

Class Overview

This helper class provides a utility implementation of the java.beans.beancontext.BeanContext interface.

Since this class directly implements the BeanContext interface, the class can, and is intended to be used either by subclassing this implementation, or via ad-hoc delegation of an instance of this class from another.

Summary

Nested Classes
class BeanContextSupport.BCSChild  
class BeanContextSupport.BCSIterator protected final subclass that encapsulates an iterator but implements a noop remove() method. 
[Expand]
Inherited Constants
From interface java.beans.DesignMode
Fields
protected ArrayList bcmListeners all accesses to the protected ArrayList bcmListeners field shall be synchronized on that object.
protected HashMap children all accesses to the protected HashMap children field shall be synchronized on that object.
protected boolean designTime A boolean indicating whether or not this object is currently in design time mode.
protected Locale locale The current locale of this BeanContext.
protected boolean okToUseGui A boolean indicating if this instance may now render a GUI.
[Expand]
Inherited Fields
From class java.beans.beancontext.BeanContextChildSupport
From interface java.beans.beancontext.BeanContext
Public Constructors
BeanContextSupport(BeanContext peer, Locale lcle, boolean dTime, boolean visible)
Construct a BeanContextSupport instance
BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime)
Create an instance using the specified Locale and design mode.
BeanContextSupport(BeanContext peer, Locale lcle)
Create an instance using the specified locale
BeanContextSupport(BeanContext peer)
Create an instance using with a default locale
BeanContextSupport()
Create an instance that is not a delegate of another object
Public Methods
boolean add(Object targetChild)
Adds/nests a child within this BeanContext.
boolean addAll(Collection c)
add Collection to set of Children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
Adds a BeanContextMembershipListener
boolean avoidingGui()
Used to determine if the BeanContext child is avoiding using its GUI.
void clear()
clear the children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
boolean contains(Object o)
Determines whether or not the specified object is currently a child of this BeanContext.
boolean containsAll(Collection c)
Tests to see if all objects in the specified Collection are children of this BeanContext.
boolean containsKey(Object o)
Determines whether or not the specified object is currently a child of this BeanContext.
synchronized void dontUseGui()
notify this instance that it may no longer render a GUI.
BeanContext getBeanContextPeer()
Gets the instance of BeanContext that this object is providing the implementation for.
synchronized Locale getLocale()
Gets the locale for this BeanContext.
URL getResource(String name, BeanContextChild bcc)
Analagous to java.lang.ClassLoader.getResource(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.
InputStream getResourceAsStream(String name, BeanContextChild bcc)
Analagous to java.lang.ClassLoader.getResourceAsStream(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.
Object instantiateChild(String beanName)

The instantiateChild method is a convenience hook in BeanContext to simplify the task of instantiating a Bean, nested, into a BeanContext.

synchronized boolean isDesignTime()
Reports whether or not this object is in currently in design time mode.
boolean isEmpty()
Reports whether or not this BeanContext is empty.
boolean isSerializing()
Is this BeanContext in the process of being serialized?
Iterator iterator()
Gets all JavaBean or BeanContext instances currently nested in this BeanContext.
synchronized boolean needsGui()

This method is typically called from the environment in order to determine if the implementor "needs" a GUI.

synchronized void okToUseGui()
Notify this instance that it may now render a GUI
void propertyChange(PropertyChangeEvent pce)
subclasses may envelope to monitor child property changes.
final void readChildren(ObjectInputStream ois)
When an instance of this class is used as a delegate for the implementation of the BeanContext protocols (and its subprotocols) there exists a 'chicken and egg' problem during deserialization
boolean remove(Object targetChild)
Removes a child from this BeanContext.
boolean removeAll(Collection c)
remove all specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
void removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
Removes a BeanContextMembershipListener
boolean retainAll(Collection c)
retain only specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
synchronized void setDesignTime(boolean dTime)
Sets the new design time value for this BeanContext.
synchronized void setLocale(Locale newLocale)
Sets the locale of this BeanContext.
int size()
Gets the number of children currently nested in this BeanContext.
Object[] toArray(Object[] arry)
Gets an array containing all children of this BeanContext that match the types contained in arry.
Object[] toArray()
Gets all JavaBean or BeanContext instances currently nested in this BeanContext.
void vetoableChange(PropertyChangeEvent pce)
subclasses may envelope to monitor veto child property changes.
final void writeChildren(ObjectOutputStream oos)
Used to serialize all children of this BeanContext.
Protected Methods
Iterator bcsChildren()
Returns an iterator of all children of this BeanContext.
void bcsPreDeserializationHook(ObjectInputStream ois)
called by readObject after defaultReadObject() but prior to deserialization of any children.
void bcsPreSerializationHook(ObjectOutputStream oos)
called by writeObject after defaultWriteObject() but prior to serialization of currently serializable children.
void childDeserializedHook(Object child, BeanContextSupport.BCSChild bcsc)
Called by readObject with the newly deserialized child and BCSChild.
void childJustAddedHook(Object child, BeanContextSupport.BCSChild bcsc)
subclasses may override this method to simply extend add() semantics after the child has been added and before the event notification has occurred.
void childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
subclasses may override this method to simply extend remove() semantics after the child has been removed and before the event notification has occurred.
final static boolean classEquals(Class first, Class second)
Tests to see if two class objects, or their names are equal.
final Object[] copyChildren()
Gets a copy of the this BeanContext's children.
BeanContextSupport.BCSChild createBCSChild(Object targetChild, Object peer)

Subclasses can override this method to insert their own subclass of Child without having to override add() or the other Collection methods that add children to the set.

final void deserialize(ObjectInputStream ois, Collection coll)
used by readObject to deserialize a collection.
final void fireChildrenAdded(BeanContextMembershipEvent bcme)
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
final void fireChildrenRemoved(BeanContextMembershipEvent bcme)
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
final static BeanContextChild getChildBeanContextChild(Object child)
Gets the BeanContextChild (if any) of the specified child
final static BeanContextMembershipListener getChildBeanContextMembershipListener(Object child)
Gets the BeanContextMembershipListener (if any) of the specified child
final static PropertyChangeListener getChildPropertyChangeListener(Object child)
Gets the PropertyChangeListener (if any) of the specified child
final static Serializable getChildSerializable(Object child)
Gets the Serializable (if any) associated with the specified Child
final static VetoableChangeListener getChildVetoableChangeListener(Object child)
Gets the VetoableChangeListener (if any) of the specified child
final static Visibility getChildVisibility(Object child)
Gets the Component (if any) associated with the specified child.
synchronized void initialize()
protected method called from constructor and readObject to initialize transient state of BeanContextSupport instance.
boolean remove(Object targetChild, boolean callChildSetBC)
internal remove used when removal caused by unexpected setBeanContext or by remove() invocation.
final void serialize(ObjectOutputStream oos, Collection coll)
Used by writeObject to serialize a Collection.
boolean validatePendingAdd(Object targetChild)

Subclasses of this class may override, or envelope, this method to add validation behavior for the BeanContext to examine child objects immediately prior to their being added to the BeanContext.

boolean validatePendingRemove(Object targetChild)

Subclasses of this class may override, or envelope, this method to add validation behavior for the BeanContext to examine child objects immediately prior to their being removed from the BeanContext.

[Expand]
Inherited Methods
From class java.beans.beancontext.BeanContextChildSupport
From class java.lang.Object
From interface java.beans.DesignMode
From interface java.beans.PropertyChangeListener
From interface java.beans.VetoableChangeListener
From interface java.beans.Visibility
From interface java.beans.beancontext.BeanContext
From interface java.beans.beancontext.BeanContextChild
From interface java.beans.beancontext.BeanContextServiceRevokedListener
From interface java.beans.beancontext.BeanContextServicesListener
From interface java.lang.Iterable
From interface java.util.Collection

Fields

protected ArrayList bcmListeners

all accesses to the protected ArrayList bcmListeners field shall be synchronized on that object.

protected HashMap children

all accesses to the protected HashMap children field shall be synchronized on that object.

protected boolean designTime

A boolean indicating whether or not this object is currently in design time mode.

protected Locale locale

The current locale of this BeanContext.

protected boolean okToUseGui

A boolean indicating if this instance may now render a GUI.

Public Constructors

public BeanContextSupport (BeanContext peer, Locale lcle, boolean dTime, boolean visible)

Construct a BeanContextSupport instance

Parameters
peer The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
lcle The current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
dTime The initial state, true if in design mode, false if runtime.
visible The initial visibility.

public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime)

Create an instance using the specified Locale and design mode.

Parameters
peer The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
lcle The current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
dtime The initial state, true if in design mode, false if runtime.

public BeanContextSupport (BeanContext peer, Locale lcle)

Create an instance using the specified locale

Parameters
peer The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
lcle The current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.

public BeanContextSupport (BeanContext peer)

Create an instance using with a default locale

Parameters
peer The peer BeanContext we are supplying an implementation for, or null if this object is its own peer

public BeanContextSupport ()

Create an instance that is not a delegate of another object

Public Methods

public boolean add (Object targetChild)

Adds/nests a child within this BeanContext.

Invoked as a side effect of java.beans.Beans.instantiate(). If the child object is not valid for adding then this method throws an IllegalStateException.

Parameters
targetChild The child objects to nest within this BeanContext
Returns
  • true if the child was added successfully.

public boolean addAll (Collection c)

add Collection to set of Children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field

public void addBeanContextMembershipListener (BeanContextMembershipListener bcml)

Adds a BeanContextMembershipListener

Parameters
bcml the BeanContextMembershipListener to add

public boolean avoidingGui ()

Used to determine if the BeanContext child is avoiding using its GUI.

Returns
  • is this instance avoiding using its GUI?
See Also

public void clear ()

clear the children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field

public boolean contains (Object o)

Determines whether or not the specified object is currently a child of this BeanContext.

Parameters
o the Object in question
Returns
  • if this object is a child

public boolean containsAll (Collection c)

Tests to see if all objects in the specified Collection are children of this BeanContext.

Parameters
c the specified Collection
Returns
  • true if all objects in the collection are children of this BeanContext, false if not.

public boolean containsKey (Object o)

Determines whether or not the specified object is currently a child of this BeanContext.

Parameters
o the Object in question
Returns
  • if this object is a child

public synchronized void dontUseGui ()

notify this instance that it may no longer render a GUI.

public BeanContext getBeanContextPeer ()

Gets the instance of BeanContext that this object is providing the implementation for.

Returns
  • the BeanContext instance

public synchronized Locale getLocale ()

Gets the locale for this BeanContext.

Returns
  • the current Locale of the BeanContext

public URL getResource (String name, BeanContextChild bcc)

Analagous to java.lang.ClassLoader.getResource(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.

Parameters
name the name of the resource requested.
bcc the child object making the request.
Returns
  • the requested resource as an InputStream

public InputStream getResourceAsStream (String name, BeanContextChild bcc)

Analagous to java.lang.ClassLoader.getResourceAsStream(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.

Parameters
name the name of the resource requested.
bcc the child object making the request.
Returns
  • the requested resource as an InputStream

public Object instantiateChild (String beanName)

The instantiateChild method is a convenience hook in BeanContext to simplify the task of instantiating a Bean, nested, into a BeanContext.

The semantics of the beanName parameter are defined by java.beans.Beans.instantate.

Parameters
beanName the name of the Bean to instantiate within this BeanContext
Returns
  • the new object
Throws
IOException if there is an I/O error when the bean is being deserialized
ClassNotFoundException if the class identified by the beanName parameter is not found

public synchronized boolean isDesignTime ()

Reports whether or not this object is in currently in design time mode.

Returns
  • true if in design time mode, false if not

public boolean isEmpty ()

Reports whether or not this BeanContext is empty. A BeanContext is considered empty when it contains zero nested children.

Returns
  • if there are not children

public boolean isSerializing ()

Is this BeanContext in the process of being serialized?

Returns
  • if this BeanContext is currently being serialized

public Iterator iterator ()

Gets all JavaBean or BeanContext instances currently nested in this BeanContext.

Returns
  • an Iterator of the nested children

public synchronized boolean needsGui ()

This method is typically called from the environment in order to determine if the implementor "needs" a GUI.

The algorithm used herein tests the BeanContextPeer, and its current children to determine if they are either Containers, Components, or if they implement Visibility and return needsGui() == true.

Returns
  • true if the implementor needs a GUI

public synchronized void okToUseGui ()

Notify this instance that it may now render a GUI

public void propertyChange (PropertyChangeEvent pce)

subclasses may envelope to monitor child property changes.

Parameters
pce A PropertyChangeEvent object describing the event source and the property that has changed.

public final void readChildren (ObjectInputStream ois)

When an instance of this class is used as a delegate for the implementation of the BeanContext protocols (and its subprotocols) there exists a 'chicken and egg' problem during deserialization

public boolean remove (Object targetChild)

Removes a child from this BeanContext. If the child object is not for adding then this method throws an IllegalStateException.

Parameters
targetChild The child objects to remove
Returns
  • true if an element was removed as a result of this call

public boolean removeAll (Collection c)

remove all specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field

public void removeBeanContextMembershipListener (BeanContextMembershipListener bcml)

Removes a BeanContextMembershipListener

Parameters
bcml the BeanContextMembershipListener to remove

public boolean retainAll (Collection c)

retain only specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field

public synchronized void setDesignTime (boolean dTime)

Sets the new design time value for this BeanContext.

Parameters
dTime the new designTime value

public synchronized void setLocale (Locale newLocale)

Sets the locale of this BeanContext.

Parameters
newLocale the new locale. This method call will have no effect if newLocale is null.
Throws
PropertyVetoException if the new value is rejected

public int size ()

Gets the number of children currently nested in this BeanContext.

Returns
  • number of children

public Object[] toArray (Object[] arry)

Gets an array containing all children of this BeanContext that match the types contained in arry.

Parameters
arry The array of object types that are of interest.
Returns
  • an array of children

public Object[] toArray ()

Gets all JavaBean or BeanContext instances currently nested in this BeanContext.

Returns
  • an array containing all of the elements in this collection

public void vetoableChange (PropertyChangeEvent pce)

subclasses may envelope to monitor veto child property changes.

Parameters
pce a PropertyChangeEvent object describing the event source and the property that has changed.

public final void writeChildren (ObjectOutputStream oos)

Used to serialize all children of this BeanContext.

Parameters
oos the ObjectOutputStream to use during serialization
Throws
IOException if serialization failed

Protected Methods

protected Iterator bcsChildren ()

Returns an iterator of all children of this BeanContext.

Returns
  • an iterator for all the current BCSChild values

protected void bcsPreDeserializationHook (ObjectInputStream ois)

called by readObject after defaultReadObject() but prior to deserialization of any children. This method may be overridden by subclasses to perform custom deserialization of their state prior to this superclass deserializing the children. This method should not however be used by subclasses to replace their own implementation (if any) of readObject().

protected void bcsPreSerializationHook (ObjectOutputStream oos)

called by writeObject after defaultWriteObject() but prior to serialization of currently serializable children. This method may be overridden by subclasses to perform custom serialization of their state prior to this superclass serializing the children. This method should not however be used by subclasses to replace their own implementation (if any) of writeObject().

Throws
IOException

protected void childDeserializedHook (Object child, BeanContextSupport.BCSChild bcsc)

Called by readObject with the newly deserialized child and BCSChild.

Parameters
child the newly deserialized child
bcsc the newly deserialized BCSChild

protected void childJustAddedHook (Object child, BeanContextSupport.BCSChild bcsc)

subclasses may override this method to simply extend add() semantics after the child has been added and before the event notification has occurred. The method is called with the child synchronized.

protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc)

subclasses may override this method to simply extend remove() semantics after the child has been removed and before the event notification has occurred. The method is called with the child synchronized.

protected static final boolean classEquals (Class first, Class second)

Tests to see if two class objects, or their names are equal.

Parameters
first the first object
second the second object
Returns
  • true if equal, false if not

protected final Object[] copyChildren ()

Gets a copy of the this BeanContext's children.

Returns
  • a copy of the current nested children

protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, Object peer)

Subclasses can override this method to insert their own subclass of Child without having to override add() or the other Collection methods that add children to the set.

Parameters
targetChild the child to create the Child on behalf of
peer the peer if the tragetChild and the peer are related by an implementation of BeanContextProxy

protected final void deserialize (ObjectInputStream ois, Collection coll)

used by readObject to deserialize a collection.

Parameters
ois the ObjectInputStream to use
coll the Collection

protected final void fireChildrenAdded (BeanContextMembershipEvent bcme)

Fire a BeanContextshipEvent on the BeanContextMembershipListener interface

protected final void fireChildrenRemoved (BeanContextMembershipEvent bcme)

Fire a BeanContextshipEvent on the BeanContextMembershipListener interface

protected static final BeanContextChild getChildBeanContextChild (Object child)

Gets the BeanContextChild (if any) of the specified child

Parameters
child the specified child
Returns
  • the BeanContextChild (if any) of the specified child
Throws
IllegalArgumentException if child implements both BeanContextChild and BeanContextProxy

protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child)

Gets the BeanContextMembershipListener (if any) of the specified child

Parameters
child the specified child
Returns
  • the BeanContextMembershipListener (if any) of the specified child

protected static final PropertyChangeListener getChildPropertyChangeListener (Object child)

Gets the PropertyChangeListener (if any) of the specified child

Parameters
child the specified child
Returns
  • the PropertyChangeListener (if any) of the specified child

protected static final Serializable getChildSerializable (Object child)

Gets the Serializable (if any) associated with the specified Child

Parameters
child the specified child
Returns
  • the Serializable (if any) associated with the specified Child

protected static final VetoableChangeListener getChildVetoableChangeListener (Object child)

Gets the VetoableChangeListener (if any) of the specified child

Parameters
child the specified child
Returns
  • the VetoableChangeListener (if any) of the specified child

protected static final Visibility getChildVisibility (Object child)

Gets the Component (if any) associated with the specified child.

Parameters
child the specified child
Returns
  • the Component (if any) associated with the specified child.

protected synchronized void initialize ()

protected method called from constructor and readObject to initialize transient state of BeanContextSupport instance. This class uses this method to instantiate inner class listeners used to monitor PropertyChange and VetoableChange events on children. subclasses may envelope this method to add their own initialization behavior

protected boolean remove (Object targetChild, boolean callChildSetBC)

internal remove used when removal caused by unexpected setBeanContext or by remove() invocation.

Parameters
targetChild the JavaBean, BeanContext, or Object to be removed
callChildSetBC used to indicate that the child should be notified that it is no longer nested in this BeanContext.

protected final void serialize (ObjectOutputStream oos, Collection coll)

Used by writeObject to serialize a Collection.

Parameters
oos the ObjectOutputStream to use during serialization
coll the Collection to serialize
Throws
IOException if serialization failed

protected boolean validatePendingAdd (Object targetChild)

Subclasses of this class may override, or envelope, this method to add validation behavior for the BeanContext to examine child objects immediately prior to their being added to the BeanContext.

Returns
  • true iff the child may be added to this BeanContext, otherwise false.

protected boolean validatePendingRemove (Object targetChild)

Subclasses of this class may override, or envelope, this method to add validation behavior for the BeanContext to examine child objects immediately prior to their being removed from the BeanContext.

Returns
  • true iff the child may be removed from this BeanContext, otherwise false.