public class java.beans.beancontext
BeanContextSupport


Show All Login
Java SE 6
  
Extends: BeanContextChildSupport
Implements: BeanContext, Serializable, PropertyChangeListener, VetoableChangeListener
Inner classes: BeanContextSupport.BCSIterator, BeanContextSupport.BCSChild
Extended by: BeanContextServicesSupport
Details
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.

version1.46, 01/13/03
since1.2

Fields
protected HashMap children
all accesses to the protected HashMap children field shall be synchronized on that object.
protected ArrayList bcmListeners
all accesses to the protected ArrayList bcmListeners field shall be synchronized on that object.
protected Locale locale
The current locale of this BeanContext.
protected boolean okToUseGui
A boolean indicating if this instance may now render a GUI.
protected boolean designTime
A boolean indicating whether or not this object is currently in design time mode.

Constructors
public BeanContextSupport(BeanContext peer, Locale lcle, boolean dTime, boolean visible) Details
Construct a BeanContextSupport instance
peerThe peer BeanContext we are supplying an implementation for, or null if this object is its own peer
lcleThe current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
dTimeThe initial state, true if in design mode, false if runtime.
visibleThe initial visibility.
See also getDefault(), setDefault(java.util.Locale)
public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime) Details
Create an instance using the specified Locale and design mode.
peerThe peer BeanContext we are supplying an implementation for, or null if this object is its own peer
lcleThe current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
dtimeThe initial state, true if in design mode, false if runtime.
See also getDefault(), setDefault(java.util.Locale)
public BeanContextSupport(BeanContext peer, Locale lcle) Details
Create an instance using the specified locale
peerThe peer BeanContext we are supplying an implementation for, or null if this object is its own peer
lcleThe current Locale for this BeanContext. If lcle is null, the default locale is assigned to the BeanContext instance.
See also getDefault(), setDefault(java.util.Locale)
public BeanContextSupport(BeanContext peer) Details
Create an instance using with a default locale
peerThe 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

Methods
public boolean add(Object targetChild) Details
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.

targetChildThe child objects to nest within this BeanContext
returntrue if the child was added successfully.
See also validatePendingAdd
public boolean addAll(Collection c) Details
add Collection to set of Children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
ThrowsUnsupportedOperationException:
public void addBeanContextMembershipListener(BeanContextMembershipListener bcml) Details
Adds a BeanContextMembershipListener
bcmlthe BeanContextMembershipListener to add
ThrowsNullPointerException:
public boolean avoidingGui() Details
Used to determine if the BeanContext child is avoiding using its GUI.
returnis this instance avoiding using its GUI?
See also java.beans.Visibility
protected Iterator bcsChildren() Details
Returns an iterator of all children of this BeanContext.
returnan iterator for all the current BCSChild values
protected void bcsPreDeserializationHook(ObjectInputStream ois) throws IOException, ClassNotFoundException
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) throws IOException
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().
protected void childDeserializedHook(Object child, BeanContextSupport.BCSChild bcsc) Details
Called by readObject with the newly deserialized child and BCSChild.
childthe newly deserialized child
bcscthe 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.
final protected static boolean classEquals(Class first, Class second) Details
Tests to see if two class objects, or their names are equal.
firstthe first object
secondthe second object
returntrue if equal, false if not
public void clear() Details
clear the children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
ThrowsUnsupportedOperationException:
public boolean contains(Object o) Details
Determines whether or not the specified object is currently a child of this BeanContext.
othe Object in question
returnif this object is a child
public boolean containsAll(Collection c) Details
Tests to see if all objects in the specified Collection are children of this BeanContext.
cthe specified Collection
returntrue if all objects in the collection are children of this BeanContext, false if not.
public boolean containsKey(Object o) Details
Determines whether or not the specified object is currently a child of this BeanContext.
othe Object in question
returnif this object is a child
final protected Object[] copyChildren() Details
Gets a copy of the this BeanContext's children.
returna copy of the current nested children
protected BeanContextSupport.BCSChild createBCSChild(Object targetChild, Object peer) Details

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.

targetChildthe child to create the Child on behalf of
peerthe peer if the tragetChild and the peer are related by an implementation of BeanContextProxy
final protected void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException Details
used by readObject to deserialize a collection.
oisthe ObjectInputStream to use
collthe Collection
public void dontUseGui()
notify this instance that it may no longer render a GUI.
final protected void fireChildrenAdded(BeanContextMembershipEvent bcme)
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
final protected void fireChildrenRemoved(BeanContextMembershipEvent bcme)
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
protected 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
public Object instantiateChild(String beanName) throws IOException, ClassNotFoundException Details

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.

beanNamethe name of the Bean to instantiate within this BeanContext
ThrowsIOException: if there is an I/O error when the bean is being deserialized
ThrowsClassNotFoundException: if the class identified by the beanName parameter is not found
returnthe new object
public Iterator iterator() Details
Gets all JavaBean or BeanContext instances currently nested in this BeanContext.
returnan Iterator of the nested children
public boolean needsGui() Details

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.

returntrue if the implementor needs a GUI
public 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.
final public void readChildren(ObjectInputStream ois) throws IOException, ClassNotFoundException
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) Details
Removes a child from this BeanContext. If the child object is not for adding then this method throws an IllegalStateException.
targetChildThe child objects to remove
See also validatePendingRemove
protected boolean remove(Object targetChild, boolean callChildSetBC) Details
internal remove used when removal caused by unexpected setBeanContext or by remove() invocation.
targetChildthe JavaBean, BeanContext, or Object to be removed
callChildSetBCused to indicate that the child should be notified that it is no longer nested in this BeanContext.
public boolean removeAll(Collection c) Details
remove all specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
ThrowsUnsupportedOperationException:
public void removeBeanContextMembershipListener(BeanContextMembershipListener bcml) Details
Removes a BeanContextMembershipListener
bcmlthe BeanContextMembershipListener to remove
ThrowsNullPointerException:
public boolean retainAll(Collection c) Details
retain only specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
ThrowsUnsupportedOperationException:
final protected void serialize(ObjectOutputStream oos, Collection coll) throws IOException Details
Used by writeObject to serialize a Collection.
oosthe ObjectOutputStream to use during serialization
collthe Collection to serialize
ThrowsIOException: if serialization failed
public int size() Details
Gets the number of children currently nested in this BeanContext.
returnnumber of children
public Object[] toArray()
Gets all JavaBean or BeanContext instances currently nested in this BeanContext.
public Object[] toArray(Object[] arry) Details
Gets an array containing all children of this BeanContext that match the types contained in arry.
arryThe array of object types that are of interest.
returnan array of children
protected boolean validatePendingAdd(Object targetChild) Details

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.

returntrue iff the child may be added to this BeanContext, otherwise false.
protected boolean validatePendingRemove(Object targetChild) Details

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.

returntrue iff the child may be removed from this BeanContext, otherwise false.
public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException
subclasses may envelope to monitor veto child property changes.
final public void writeChildren(ObjectOutputStream oos) throws IOException Details
Used to serialize all children of this BeanContext.
oosthe ObjectOutputStream to use during serialization
ThrowsIOException: if serialization failed

Properties
public BeanContext getBeanContextPeer() Details
Gets the instance of BeanContext that this object is providing the implementation for.
returnthe BeanContext instance
final protected static BeanContextChild getChildBeanContextChild(Object child) Details
Gets the BeanContextChild (if any) of the specified child
childthe specified child
returnthe BeanContextChild (if any) of the specified child
ThrowsIllegalArgumentException: if child implements both BeanContextChild and BeanContextProxy
final protected static BeanContextMembershipListener getChildBeanContextMembershipListener(Object child) Details
Gets the BeanContextMembershipListener (if any) of the specified child
childthe specified child
returnthe BeanContextMembershipListener (if any) of the specified child
final protected static PropertyChangeListener getChildPropertyChangeListener(Object child) Details
Gets the PropertyChangeListener (if any) of the specified child
childthe specified child
returnthe PropertyChangeListener (if any) of the specified child
final protected static Serializable getChildSerializable(Object child) Details
Gets the Serializable (if any) associated with the specified Child
childthe specified child
returnthe Serializable (if any) associated with the specified Child
final protected static VetoableChangeListener getChildVetoableChangeListener(Object child) Details
Gets the VetoableChangeListener (if any) of the specified child
childthe specified child
returnthe VetoableChangeListener (if any) of the specified child
final protected static Visibility getChildVisibility(Object child) Details
Gets the Component (if any) associated with the specified child.
childthe specified child
returnthe Component (if any) associated with the specified child.
public void setDesignTime(boolean dTime) Details
Sets the new design time value for this BeanContext.
dTimethe new designTime value
public boolean isDesignTime() Details
Reports whether or not this object is in currently in design time mode.
returntrue if in design time mode, false if not
public boolean isEmpty() Details
Reports whether or not this BeanContext is empty. A BeanContext is considered empty when it contains zero nested children.
returnif there are not children
public void setLocale(Locale newLocale) throws PropertyVetoException Details
Sets the locale of this BeanContext.
newLocalethe new locale. This method call will have no effect if newLocale is null.
ThrowsPropertyVetoException: if the new value is rejected
public Locale getLocale() Details
Gets the locale for this BeanContext.
returnthe current Locale of the BeanContext
public URL getResource(String name, BeanContextChild bcc) Details
namethe name of the resource requested.
bccthe child object making the request.
returnthe requested resource as an InputStream
public InputStream getResourceAsStream(String name, BeanContextChild bcc) Details
namethe name of the resource requested.
bccthe child object making the request.
returnthe requested resource as an InputStream
ThrowsNullPointerException:
public boolean isSerializing() Details
Is this BeanContext in the process of being serialized?
returnif this BeanContext is currently being serialized