public class BeanContextSupport extends BeanContextChildSupportimplements BeanContext , Serializable , PropertyChangeListener , VetoableChangeListener
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.
| Modifier and Type | Class and Description |
|---|---|
protected class |
BeanContextSupport
|
protected static class |
BeanContextSupport
protected final subclass that encapsulates an iterator but implements a noop remove() method.
|
| Modifier and Type | Field and Description |
|---|---|
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.
|
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupportglobalHierarchyLockPROPERTYNAME| Constructor and Description |
|---|
BeanContextSupport()
Create an instance that is not a delegate of another object
|
BeanContextSupport(BeanContext
Create an instance using with a default locale
|
BeanContextSupport(BeanContext
Create an instance using the specified locale
|
BeanContextSupport(BeanContext
Create an instance using the specified Locale and design mode.
|
BeanContextSupport(BeanContext
Construct a BeanContextSupport instance
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Object
Adds/nests a child within this
BeanContext.
|
boolean |
addAll(Collection
add Collection to set of Children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
|
void |
addBeanContextMembershipListener(BeanContextMembershipListener
Adds a BeanContextMembershipListener
|
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
called by readObject after defaultReadObject() but prior to deserialization of any children.
|
protected void |
bcsPreSerializationHook(ObjectOutputStream
called by writeObject after defaultWriteObject() but prior to serialization of currently serializable children.
|
protected void |
childDeserializedHook(Object
Called by readObject with the newly deserialized child and BCSChild.
|
protected void |
childJustAddedHook(Object
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
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 boolean |
classEquals(Class
Tests to see if two class objects, or their names are equal.
|
void |
clear()
clear the children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
|
boolean |
contains(Object
Determines whether or not the specified object is currently a child of this
BeanContext.
|
boolean |
containsAll(Collection
Tests to see if all objects in the specified
Collection are children of this
BeanContext.
|
boolean |
containsKey(Object
Determines whether or not the specified object is currently a child of this
BeanContext.
|
protected Object |
copyChildren()
Gets a copy of the this BeanContext's children.
|
protected BeanContextSupport |
createBCSChild(Object
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 void |
deserialize(ObjectInputStream
used by readObject to deserialize a collection.
|
void |
dontUseGui()
notify this instance that it may no longer render a GUI.
|
protected void |
fireChildrenAdded(BeanContextMembershipEvent
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
|
protected void |
fireChildrenRemoved(BeanContextMembershipEvent
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface
|
BeanContext |
getBeanContextPeer()
Gets the instance of
BeanContext that this object is providing the implementation for.
|
protected static BeanContextChild |
getChildBeanContextChild(Object
Gets the BeanContextChild (if any) of the specified child
|
protected static BeanContextMembershipListener |
getChildBeanContextMembershipListener(Object
Gets the BeanContextMembershipListener (if any) of the specified child
|
protected static PropertyChangeListener |
getChildPropertyChangeListener(Object
Gets the PropertyChangeListener (if any) of the specified child
|
protected static Serializable |
getChildSerializable(Object
Gets the Serializable (if any) associated with the specified Child
|
protected static VetoableChangeListener |
getChildVetoableChangeListener(Object
Gets the VetoableChangeListener (if any) of the specified child
|
protected static Visibility |
getChildVisibility(Object
Gets the Component (if any) associated with the specified child.
|
Locale |
getLocale()
Gets the locale for this
BeanContext.
|
URL |
getResource(String
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
Analagous to
java.lang.ClassLoader.getResourceAsStream(), this method allows a
BeanContext implementation to interpose behavior between the child
Component and underlying
ClassLoader.
|
protected void |
initialize()
protected method called from constructor and readObject to initialize transient state of BeanContextSupport instance.
|
Object |
instantiateChild(String
The instantiateChild method is a convenience hook in BeanContext to simplify the task of instantiating a Bean, nested, into a
BeanContext.
|
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.
|
boolean |
needsGui()
This method is typically called from the environment in order to determine if the implementor "needs" a GUI.
|
void |
okToUseGui()
Notify this instance that it may now render a GUI
|
void |
propertyChange(PropertyChangeEvent
subclasses may envelope to monitor child property changes.
|
void |
readChildren(ObjectInputStream
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
Removes a child from this BeanContext.
|
protected boolean |
remove(Object
internal remove used when removal caused by unexpected
setBeanContext or by
remove() invocation.
|
boolean |
removeAll(Collection
remove all specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
|
void |
removeBeanContextMembershipListener(BeanContextMembershipListener
Removes a BeanContextMembershipListener
|
boolean |
retainAll(Collection
retain only specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field
|
protected void |
serialize(ObjectOutputStream
Used by writeObject to serialize a Collection.
|
void |
setDesignTime(boolean dTime)
Sets the new design time value for this
BeanContext.
|
void |
setLocale(Locale
Sets the locale of this BeanContext.
|
int |
size()
Gets the number of children currently nested in this BeanContext.
|
Object |
toArray()
Gets all JavaBean or
BeanContext instances currently nested in this BeanContext.
|
Object |
toArray(Object
Gets an array containing all children of this
BeanContext that match the types contained in arry.
|
protected boolean |
validatePendingAdd(Object
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
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.
|
void |
vetoableChange(PropertyChangeEvent
subclasses may envelope to monitor veto child property changes.
|
void |
writeChildren(ObjectOutputStream
Used to serialize all children of this
BeanContext.
|
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, initializeBeanContextResources, isDelegated, releaseBeanContextResources, removePropertyChangeListener, removeVetoableChangeListener, serviceAvailable, serviceRevoked, setBeanContext, validatePendingSetBeanContextclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContextequals, hashCode, parallelStream, removeIf, spliterator, streamprotected transient HashMapchildren
protected HashMap children field shall be synchronized on that object.
protected transient ArrayListbcmListeners
protected ArrayList bcmListeners field shall be synchronized on that object.
protected Localelocale
protected boolean okToUseGui
protected boolean designTime
public BeanContextSupport(BeanContextpeer, Locale lcle, boolean dTime, boolean visible)
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.
Locale.getDefault() ,
Locale.setDefault(java.util.Locale)
public BeanContextSupport(BeanContextpeer, Locale lcle, boolean dtime)
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.
Locale.getDefault() ,
Locale.setDefault(java.util.Locale)
public BeanContextSupport(BeanContextpeer, Locale lcle)
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.
Locale.getDefault() ,
Locale.setDefault(java.util.Locale)
public BeanContextSupport(BeanContextpeer)
peer - The peer
BeanContext we are supplying an implementation for, or
null if this object is its own peer
public BeanContextSupport()
public BeanContextgetBeanContextPeer()
public ObjectinstantiateChild(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.instantiate.
instantiateChild in interface
BeanContext
beanName - the name of the Bean to instantiate within this BeanContext
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 int size()
size in interface
Collection
public boolean isEmpty()
isEmpty in interface
Collection
public boolean contains(Objecto)
contains in interface
Collection
o - the Object in question
public boolean containsKey(Objecto)
o - the Object in question
public Iteratoriterator()
iterator in interface
Iterable
iterator in interface
Collection
public Object[] toArray()
toArray in interface
Collection
public Object[] toArray(Object [] arry)
toArray in interface
Collection
arry - The array of object types that are of interest.
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.
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 * @return Subtype-specific subclass of Child without overriding collection methods
public boolean add(ObjecttargetChild)
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.
add in interface
Collection
targetChild - The child objects to nest within this
BeanContext
validatePendingAdd(java.lang.Object)
public boolean remove(ObjecttargetChild)
remove in interface
Collection
targetChild - The child objects to remove
validatePendingRemove(java.lang.Object)
protected boolean remove(ObjecttargetChild, boolean callChildSetBC)
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.
public boolean containsAll(Collectionc)
containsAll in interface
Collection
c - the specified
Collection
Collection.contains(Object)
public boolean addAll(Collectionc)
addAll in interface
Collection
c - collection containing elements to be added to this collection
UnsupportedOperationException
UnsupportedOperationException - thrown unconditionally by this implementation
Collection.add(Object)
public boolean removeAll(Collectionc)
removeAll in interface
Collection
c - collection containing elements to be removed from this collection
UnsupportedOperationException
UnsupportedOperationException - thrown unconditionally by this implementation
Collection.remove(Object) ,
Collection.contains(Object)
public boolean retainAll(Collectionc)
retainAll in interface
Collection
c - collection containing elements to be retained in this collection
UnsupportedOperationException
UnsupportedOperationException - thrown unconditionally by this implementation
Collection.remove(Object) ,
Collection.contains(Object)
public void clear()
clear in interface
Collection
UnsupportedOperationException - thrown unconditionally by this implementation
public void addBeanContextMembershipListener(BeanContextMembershipListenerbcml)
addBeanContextMembershipListener in interface
BeanContext
bcml - the BeanContextMembershipListener to add
NullPointerException - if the argument is null
public void removeBeanContextMembershipListener(BeanContextMembershipListenerbcml)
removeBeanContextMembershipListener in interface
BeanContext
bcml - the BeanContextMembershipListener to remove
NullPointerException - if the argument is null
public InputStreamgetResourceAsStream(String name, BeanContextChild bcc)
BeanContext
java.lang.ClassLoader.getResourceAsStream(), this method allows a
BeanContext implementation to interpose behavior between the child
Component and underlying
ClassLoader.
getResourceAsStream in interface
BeanContext
name - the name of the resource requested.
bcc - the child object making the request.
NullPointerException - if the argument is null
public URLgetResource(String name, BeanContextChild bcc)
BeanContext
java.lang.ClassLoader.getResource(), this method allows a
BeanContext implementation to interpose behavior between the child
Component and underlying
ClassLoader.
getResource in interface
BeanContext
name - the name of the resource requested.
bcc - the child object making the request.
public void setDesignTime(boolean dTime)
setDesignTime in interface
DesignMode
dTime - the new designTime value
BeanContext,
BeanContextMembershipListener,
PropertyChangeEvent
public boolean isDesignTime()
isDesignTime in interface
DesignMode
public void setLocale(LocalenewLocale) throws PropertyVetoException
newLocale - the new locale. This method call will have no effect if newLocale is
null.
PropertyVetoException - if the new value is rejected
public LocalegetLocale()
public 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.
needsGui in interface
Visibility
public void dontUseGui()
public void okToUseGui()
public boolean avoidingGui()
avoidingGui in interface
Visibility
Visibility
public boolean isSerializing()
protected IteratorbcsChildren()
protected void bcsPreSerializationHook(ObjectOutputStreamoos) throws IOException
oos - the
ObjectOutputStream to use during serialization
IOException - if serialization failed
protected void bcsPreDeserializationHook(ObjectInputStreamois) throws IOException , ClassNotFoundException
ois - the
ObjectInputStream to use during deserialization
IOException - if deserialization failed
ClassNotFoundException - if needed classes are not found
protected void childDeserializedHook(Objectchild, BeanContextSupport .BCSChild bcsc)
child - the newly deserialized child
bcsc - the newly deserialized BCSChild
protected final void serialize(ObjectOutputStreamoos, Collection coll) throws IOException
oos - the
ObjectOutputStream to use during serialization
coll - the
Collection to serialize
IOException - if serialization failed
protected final void deserialize(ObjectInputStreamois, Collection coll) throws IOException , ClassNotFoundException
ois - the ObjectInputStream to use
coll - the Collection
IOException - if deserialization failed
ClassNotFoundException - if needed classes are not found
public final void writeChildren(ObjectOutputStreamoos) throws IOException
oos - the
ObjectOutputStream to use during serialization
IOException - if serialization failed
public final void readChildren(ObjectInputStreamois) throws IOException , ClassNotFoundException
ois - the ObjectInputStream to use
IOException - if deserialization failed
ClassNotFoundException - if needed classes are not found
public void vetoableChange(PropertyChangeEventpce) throws PropertyVetoException
vetoableChange in interface
VetoableChangeListener
pce - a
PropertyChangeEvent object describing the event source and the property that has changed.
PropertyVetoException - if the recipient wishes the property change to be rolled back.
public void propertyChange(PropertyChangeEventpce)
propertyChange in interface
PropertyChangeListener
pce - A PropertyChangeEvent object describing the event source and the property that has changed.
protected boolean validatePendingAdd(ObjecttargetChild)
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.
targetChild - the child to create the Child on behalf of
protected boolean validatePendingRemove(ObjecttargetChild)
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.
targetChild - the child to create the Child on behalf of
protected void childJustAddedHook(Objectchild, BeanContextSupport .BCSChild bcsc)
child - the child
bcsc - the BCSChild
protected void childJustRemovedHook(Objectchild, BeanContextSupport .BCSChild bcsc)
child - the child
bcsc - the BCSChild
protected static final VisibilitygetChildVisibility(Object child)
child - the specified child
protected static final SerializablegetChildSerializable(Object child)
child - the specified child
protected static final PropertyChangeListenergetChildPropertyChangeListener(Object child)
child - the specified child
protected static final VetoableChangeListenergetChildVetoableChangeListener(Object child)
child - the specified child
protected static final BeanContextMembershipListenergetChildBeanContextMembershipListener(Object child)
child - the specified child
protected static final BeanContextChildgetChildBeanContextChild(Object child)
child - the specified child
IllegalArgumentException - if child implements both BeanContextChild and BeanContextProxy
protected final void fireChildrenAdded(BeanContextMembershipEventbcme)
bcme - the event to fire
protected final void fireChildrenRemoved(BeanContextMembershipEventbcme)
bcme - the event to fire
protected void initialize()
protected final Object[] copyChildren()