APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.beans.beancontext

public Class BeanContextSupport

extends BeanContextChildSupport
implements BeanContext, Serializable, PropertyChangeListener, VetoableChangeListener
Class Inheritance
All Implemented Interfaces
java.beans.VetoableChangeListener, java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable, java.beans.beancontext.BeanContext, java.beans.Visibility, java.beans.DesignMode, java.util.Collection, java.lang.Iterable, java.beans.beancontext.BeanContextChild
Known Direct Subclasses
java.beans.beancontext.BeanContextServicesSupport
Annotations
@SuppressWarnings:removal
@Deprecated
since:23
forRemoval:true
Imports
java.awt.Component, .Container, java.beans.Beans, .PropertyChangeEvent, .PropertyChangeListener, .PropertyVetoException, .VetoableChangeListener, .Visibility, java.io.IOException, .InputStream, .ObjectInputStream, .ObjectOutputStream, .Serial, .Serializable, java.net.URL, java.util.ArrayList, .Collection, .HashMap, .Iterator, .Locale, .Map

Deprecated

for removal since 23.

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.

Author
Laurence P. G. Cable
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
BeanContextSupport.BCSChild

A protected nested class containing per-child information in the children hashtable.

protected static class
BeanContextSupport.BCSIterator

protected final subclass that encapsulates an iterator but implements a noop remove() method.

Field Summary

Modifier and TypeField and Description
protected transient ArrayList<BeanContextMembershipListener>
bcmListeners

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

private transient PropertyChangeListener
protected transient HashMap<Object, BeanContextSupport.BCSChild>
children

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

private transient VetoableChangeListener
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.

private int
private transient boolean
private static final long
serialVersionUID

Hides java.beans.beancontext.BeanContextChildSupport.serialVersionUID.

Use serialVersionUID from JDK 1.3 for interoperability.
Inherited from java.beans.beancontext.BeanContextChildSupport:
beanContextbeanContextChildPeerpcSupportrejectedSetBCOncevcSupport

Constructor Summary

AccessConstructor and Description
public
BeanContextSupport(BeanContext
The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
peer
,
Locale
The current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
lcle
,
boolean
The initial state, true if in design mode, false if runtime.
dTime
,
boolean
The initial visibility.
visible
)
References Deprecated BeanContext is deprecated or references (maybe indirectly) at least one deprecated element.

Construct a BeanContextSupport instance

public
BeanContextSupport(BeanContext
The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
peer
,
Locale
The current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
lcle
,
boolean
The initial state, true if in design mode, false if runtime.
dtime
)
References Deprecated BeanContext is deprecated or references (maybe indirectly) at least one deprecated element.

Create an instance using the specified Locale and design mode.

public
BeanContextSupport(BeanContext
The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
peer
,
Locale
The current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
lcle
)
References Deprecated BeanContext is deprecated or references (maybe indirectly) at least one deprecated element.

Create an instance using the specified locale

public
BeanContextSupport(BeanContext
The peer BeanContext we are supplying an implementation for, or null if this object is its own peer
peer
)
References Deprecated BeanContext is deprecated or references (maybe indirectly) at least one deprecated element.

Create an instance using with a default locale

public
BeanContextSupport()

Create an instance that is not a delegate of another object

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the child was added successfully.
add
(Object
The child objects to nest within this BeanContext
targetChild
)

Implements java.util.Collection.add.

Adds/nests a child within this BeanContext.

public boolean

Returns:

this implementation unconditionally throws UnsupportedOperationException
addAll
(Collection<E> c)

Implements java.util.Collection.addAll.

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

public void
addBeanContextMembershipListener(BeanContextMembershipListener
the BeanContextMembershipListener to add
bcml
)

Implements java.beans.beancontext.BeanContext.addBeanContextMembershipListener.

References Deprecated BeanContextMembershipListener is deprecated or references (maybe indirectly) at least one deprecated element.

Adds a BeanContextMembershipListener

public boolean

Returns:

is this instance avoiding using its GUI?
avoidingGui
()

Implements java.beans.Visibility.avoidingGui.

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

protected Iterator<BeanContextSupport.BCSChild>

Returns:

an iterator for all the current BCSChild values
bcsChildren
()

Returns an iterator of all children of this BeanContext.

protected void
bcsPreDeserializationHook(ObjectInputStream
the ObjectInputStream to use during deserialization
ois
)

called by readObject after defaultReadObject() but prior to deserialization of any children.

protected void
bcsPreSerializationHook(ObjectOutputStream
the ObjectOutputStream to use during serialization
oos
)

called by writeObject after defaultWriteObject() but prior to serialization of currently serializable children.

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

Called by readObject with the newly deserialized child and BCSChild.

protected void
childJustAddedHook(Object
the child
child
,
BeanContextSupport.BCSChild
the 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.

protected void
childJustRemovedHook(Object
the child
child
,
BeanContextSupport.BCSChild
the 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.

protected static final boolean

Returns:

true if equal, false if not
classEquals
(Class<?>
the first object
first
,
Class<?>
the second object
second
)

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

public void
clear()

Implements java.util.Collection.clear.

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

public boolean

Returns:

true if this object is a child, otherwise false
contains
(Object
the Object in question
o
)

Implements java.util.Collection.contains.

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

public boolean

Returns:

true if all objects in the collection are children of this BeanContext, false if not.
containsAll
(Collection<E>
the specified Collection
c
)

Implements java.util.Collection.containsAll.

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

public boolean

Returns:

true if this object is a child, otherwise false
containsKey
(Object
the Object in question
o
)

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

protected final Object[]

Returns:

a copy of the current nested children
copyChildren
()

Gets a copy of the this BeanContext's children.

protected BeanContextSupport.BCSChild

Returns:

Subtype-specific subclass of Child without overriding collection methods
createBCSChild
(Object
the child to create the Child on behalf of
targetChild
,
Object
the peer if the tragetChild and the peer are related by an implementation of BeanContextProxy
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.

protected final void
deserialize(ObjectInputStream
the ObjectInputStream to use
ois
,
Collection<E>
the Collection
coll
)

used by readObject to deserialize a collection.

public synchronized void
dontUseGui()

Implements java.beans.Visibility.dontUseGui.

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

protected final void
fireChildrenAdded(BeanContextMembershipEvent
the event to fire
bcme
)
References Deprecated BeanContextMembershipEvent is deprecated or references (maybe indirectly) at least one deprecated element.

Fire a BeanContextMembershipEvent on the BeanContextMembershipListener interface

protected final void
fireChildrenRemoved(BeanContextMembershipEvent
the event to fire
bcme
)
References Deprecated BeanContextMembershipEvent is deprecated or references (maybe indirectly) at least one deprecated element.

Fire a BeanContextMembershipEvent on the BeanContextMembershipListener interface

public BeanContext

Returns:

the BeanContext instance
getBeanContextPeer
()
References Deprecated BeanContext is deprecated or references (maybe indirectly) at least one deprecated element.

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

protected static final BeanContextChild

Returns:

the BeanContextChild (if any) of the specified child
getChildBeanContextChild
(Object
the specified child
child
)
References Deprecated BeanContextChild is deprecated or references (maybe indirectly) at least one deprecated element.

Gets the BeanContextChild (if any) of the specified child

protected static final BeanContextMembershipListener

Returns:

the BeanContextMembershipListener (if any) of the specified child
getChildBeanContextMembershipListener
(Object
the specified child
child
)
References Deprecated BeanContextMembershipListener is deprecated or references (maybe indirectly) at least one deprecated element.

Gets the BeanContextMembershipListener (if any) of the specified child

protected static final PropertyChangeListener

Returns:

the PropertyChangeListener (if any) of the specified child
getChildPropertyChangeListener
(Object
the specified child
child
)

Gets the PropertyChangeListener (if any) of the specified child

protected static final Serializable

Returns:

the Serializable (if any) associated with the specified Child
getChildSerializable
(Object
the specified child
child
)

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

protected static final VetoableChangeListener

Returns:

the VetoableChangeListener (if any) of the specified child
getChildVetoableChangeListener
(Object
the specified child
child
)

Gets the VetoableChangeListener (if any) of the specified child

protected static final Visibility

Returns:

the Component (if any) associated with the specified child.
getChildVisibility
(Object
the specified child
child
)

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

public synchronized Locale

Returns:

the current Locale of the BeanContext
getLocale
()

Gets the locale for this BeanContext.

public URL

Returns:

the requested resource as an InputStream
getResource
(String
the name of the resource requested.
name
,
BeanContextChild
the child object making the request.
bcc
)

Implements java.beans.beancontext.BeanContext.getResource.

References Deprecated BeanContextChild is deprecated or references (maybe indirectly) at least one deprecated element.

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

public InputStream

Returns:

the requested resource as an InputStream
getResourceAsStream
(String
the name of the resource requested.
name
,
BeanContextChild
the child object making the request.
bcc
)

Implements java.beans.beancontext.BeanContext.getResourceAsStream.

References Deprecated BeanContextChild is deprecated or references (maybe indirectly) at least one deprecated element.

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

protected synchronized void
initialize()

protected method called from constructor and readObject to initialize transient state of BeanContextSupport instance.

public Object

Returns:

the new object
instantiateChild
(String
the name of the Bean to instantiate within this BeanContext
beanName
)

Implements java.beans.beancontext.BeanContext.instantiateChild.

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

public synchronized boolean

Returns:

true if in design time mode, false if not
isDesignTime
()

Implements java.beans.DesignMode.isDesignTime.

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

public boolean

Returns:

true if there are no children, otherwise false
isEmpty
()

Implements java.util.Collection.isEmpty.

Reports whether or not this BeanContext is empty.

public boolean

Returns:

true if this BeanContext is currently being serialized, otherwise false
isSerializing
()

Is this BeanContext in the process of being serialized?

public Iterator<Object>

Returns:

an Iterator of the nested children
iterator
()

Implements java.util.Collection.iterator.

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

public synchronized boolean

Returns:

true if the implementor needs a GUI
needsGui
()

Implements java.beans.Visibility.needsGui.

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

public synchronized void
okToUseGui()

Implements java.beans.Visibility.okToUseGui.

Notify this instance that it may now render a GUI

public void
propertyChange(PropertyChangeEvent pce)

Implements java.beans.PropertyChangeListener.propertyChange.

subclasses may envelope to monitor child property changes.

public final void
readChildren(ObjectInputStream
the ObjectInputStream to use
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

private synchronized void
readObject(ObjectInputStream
the ObjectInputStream to read
ois
)

Hides java.beans.beancontext.BeanContextChildSupport.readObject.

deserialize contents ...

public boolean
remove(Object
The child objects to remove
targetChild
)

Implements java.util.Collection.remove.

Removes a child from this BeanContext.

protected boolean

Returns:

whether or not was present before being removed
remove
(Object
the JavaBean, BeanContext, or Object to be removed
targetChild
,
boolean
used to indicate that the child should be notified that it is no longer nested in this BeanContext.
callChildSetBC
)

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

public boolean

Returns:

this implementation unconditionally throws UnsupportedOperationException
removeAll
(Collection<E> c)

Implements java.util.Collection.removeAll.

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

public void
removeBeanContextMembershipListener(BeanContextMembershipListener
the BeanContextMembershipListener to remove
bcml
)

Implements java.beans.beancontext.BeanContext.removeBeanContextMembershipListener.

References Deprecated BeanContextMembershipListener is deprecated or references (maybe indirectly) at least one deprecated element.

Removes a BeanContextMembershipListener

public boolean

Returns:

this implementation unconditionally throws UnsupportedOperationException
retainAll
(Collection<E> c)

Implements java.util.Collection.retainAll.

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

protected final void
serialize(ObjectOutputStream
the ObjectOutputStream to use during serialization
oos
,
Collection<?>
the Collection to serialize
coll
)

Used by writeObject to serialize a Collection.

public synchronized void
setDesignTime(boolean
the new designTime value
dTime
)

Implements java.beans.DesignMode.setDesignTime.

Sets the new design time value for this BeanContext.

public synchronized void
setLocale(Locale
the new locale. This method call will have no effect if newLocale is null.
newLocale
)

Sets the locale of this BeanContext.

public int

Returns:

number of children
size
()

Implements java.util.Collection.size.

Gets the number of children currently nested in this BeanContext.

public Object[]
toArray()

Implements java.util.Collection.toArray.

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

public Object[]

Returns:

an array of children
toArray
(Object[]
The array of object types that are of interest.
arry
)

Implements java.util.Collection.toArray.

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

protected boolean

Returns:

true iff the child may be added to this BeanContext, otherwise false.
validatePendingAdd
(Object
the child to create the Child on behalf of
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.

protected boolean

Returns:

true iff the child may be removed from this BeanContext, otherwise false.
validatePendingRemove
(Object
the child to create the Child on behalf of
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.

public void
vetoableChange(PropertyChangeEvent pce)

Implements java.beans.VetoableChangeListener.vetoableChange.

subclasses may envelope to monitor veto child property changes.

public final void
writeChildren(ObjectOutputStream
the ObjectOutputStream to use during serialization
oos
)

Used to serialize all children of this BeanContext.

private synchronized void
writeObject(ObjectOutputStream
the ObjectOutputStream to write
oos
)

Hides java.beans.beancontext.BeanContextChildSupport.writeObject.

Serialize the BeanContextSupport, if this instance has a distinct peer (that is this object is acting as a delegate for another) then the children of this instance are not serialized here due to a 'chicken and egg' problem that occurs on deserialization of the children at the same time as this instance.

Inherited from java.beans.beancontext.BeanContextChildSupport:
addPropertyChangeListeneraddVetoableChangeListenerfirePropertyChangefireVetoableChangegetBeanContextgetBeanContextChildPeerinitializeBeanContextResourcesisDelegatedreleaseBeanContextResourcesremovePropertyChangeListenerremoveVetoableChangeListenerserviceAvailableserviceRevokedsetBeanContextvalidatePendingSetBeanContext