Home » openjdk-7 » java » beans » beancontext » [javadoc | source]
java.beans.beancontext
public class: BeanContextSupport [javadoc | source]
java.lang.Object
   java.beans.beancontext.BeanContextChildSupport
      java.beans.beancontext.BeanContextSupport

All Implemented Interfaces:
    VetoableChangeListener, Serializable, PropertyChangeListener, BeanContext, BeanContextChild, BeanContextServicesListener

Direct Known Subclasses:
    BeanContextServicesSupport

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.

Nested Class Summary:
protected static final class  BeanContextSupport.BCSIterator  protected final subclass that encapsulates an iterator but implements a noop remove() method. 
protected class  BeanContextSupport.BCSChild   
Field Summary
static final  long serialVersionUID     
protected transient  HashMap children    all accesses to the protected HashMap children field shall be synchronized on that object. 
protected transient  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. 
Fields inherited from java.beans.beancontext.BeanContextChildSupport:
serialVersionUID,  beanContextChildPeer,  pcSupport,  vcSupport,  beanContext,  rejectedSetBCOnce
Constructor:
 public BeanContextSupport() 
 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(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.
    Also see:
    java.util.Locale#getDefault()
    java.util.Locale#setDefault(java.util.Locale)
 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.
    Also see:
    java.util.Locale#getDefault()
    java.util.Locale#setDefault(java.util.Locale)
 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.
    Also see:
    java.util.Locale#getDefault()
    java.util.Locale#setDefault(java.util.Locale)
Method from java.beans.beancontext.BeanContextSupport Summary:
add,   addAll,   addBeanContextMembershipListener,   avoidingGui,   bcsChildren,   bcsPreDeserializationHook,   bcsPreSerializationHook,   childDeserializedHook,   childJustAddedHook,   childJustRemovedHook,   classEquals,   clear,   contains,   containsAll,   containsKey,   copyChildren,   createBCSChild,   deserialize,   dontUseGui,   fireChildrenAdded,   fireChildrenRemoved,   getBeanContextPeer,   getChildBeanContextChild,   getChildBeanContextMembershipListener,   getChildPropertyChangeListener,   getChildSerializable,   getChildVetoableChangeListener,   getChildVisibility,   getLocale,   getResource,   getResourceAsStream,   initialize,   instantiateChild,   isDesignTime,   isEmpty,   isSerializing,   iterator,   needsGui,   okToUseGui,   propertyChange,   readChildren,   remove,   remove,   removeAll,   removeBeanContextMembershipListener,   retainAll,   serialize,   setDesignTime,   setLocale,   size,   toArray,   toArray,   validatePendingAdd,   validatePendingRemove,   vetoableChange,   writeChildren
Methods from java.beans.beancontext.BeanContextChildSupport:
addPropertyChangeListener,   addVetoableChangeListener,   firePropertyChange,   fireVetoableChange,   getBeanContext,   getBeanContextChildPeer,   initializeBeanContextResources,   isDelegated,   releaseBeanContextResources,   removePropertyChangeListener,   removeVetoableChangeListener,   serviceAvailable,   serviceRevoked,   setBeanContext,   validatePendingSetBeanContext
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.beans.beancontext.BeanContextSupport Detail:
 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.

 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
 public boolean avoidingGui() 
    Used to determine if the BeanContext child is avoiding using its GUI.
 protected Iterator bcsChildren() 
    Returns an iterator of all children of this BeanContext.
 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,
    BCSChild bcsc) 
    Called by readObject with the newly deserialized child and BCSChild.
 protected  void childJustAddedHook(Object child,
    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,
    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.
 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.
 public boolean containsAll(Collection c) 
    Tests to see if all objects in the specified Collection are children of this BeanContext.
 public boolean containsKey(Object o) 
    Determines whether or not the specified object is currently a child of this BeanContext.
 protected final Object[] copyChildren() 
    Gets a copy of the this BeanContext's children.
 protected 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.

 protected final  void deserialize(ObjectInputStream ois,
    Collection coll) throws IOException, ClassNotFoundException 
    used by readObject to deserialize a collection.
 public synchronized  void dontUseGui() 
    notify this instance that it may no longer render a GUI.
 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
 public BeanContext getBeanContextPeer() 
    Gets the instance of BeanContext that this object is providing the implementation for.
 protected static final BeanContextChild getChildBeanContextChild(Object child) 
    Gets the BeanContextChild (if any) of the specified child
 protected static final BeanContextMembershipListener getChildBeanContextMembershipListener(Object child) 
    Gets the BeanContextMembershipListener (if any) of the specified child
 protected static final PropertyChangeListener getChildPropertyChangeListener(Object child) 
    Gets 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
 protected static final VetoableChangeListener getChildVetoableChangeListener(Object child) 
    Gets 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.
 public synchronized Locale getLocale() 
    Gets the locale for this BeanContext.
 public URL getResource(String name,
    BeanContextChild bcc) 
 public InputStream getResourceAsStream(String name,
    BeanContextChild bcc) 
 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
 public Object instantiateChild(String beanName) throws IOException, ClassNotFoundException 

    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.

 public synchronized boolean isDesignTime() 
    Reports whether or not this object is in currently in design time mode.
 public boolean isEmpty() 
    Reports whether or not this BeanContext is empty. A BeanContext is considered empty when it contains zero nested children.
 public boolean isSerializing() 
    Is this BeanContext in the process of being serialized?
 public Iterator iterator() 
    Gets all JavaBean or BeanContext instances currently nested in this BeanContext.
 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.

 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.
 public final  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) 
    Removes a child from this BeanContext. If the child object is not for adding then this method throws an IllegalStateException.
 protected boolean remove(Object targetChild,
    boolean callChildSetBC) 
    internal remove used when removal caused by unexpected setBeanContext or by remove() invocation.
 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
 public boolean retainAll(Collection c) 
    retain only specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
 protected final  void serialize(ObjectOutputStream oos,
    Collection coll) throws IOException 
    Used by writeObject to serialize a Collection.
 public synchronized  void setDesignTime(boolean dTime) 
    Sets the new design time value for this BeanContext.
 public synchronized  void setLocale(Locale newLocale) throws PropertyVetoException 
    Sets the locale of this BeanContext.
 public int size() 
    Gets the number of children currently nested in this BeanContext.
 public Object[] toArray() 
    Gets all JavaBean or BeanContext instances currently nested in this BeanContext.
 public Object[] toArray(Object[] arry) 
    Gets an array containing all children of this BeanContext that match the types contained in arry.
 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.

 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.

 public  void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException 
    subclasses may envelope to monitor veto child property changes.
 public final  void writeChildren(ObjectOutputStream oos) throws IOException 
    Used to serialize all children of this BeanContext.