|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.beans.beancontext.BeanContextChildSupport | +--java.beans.beancontext.BeanContextSupport
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.
Inner Class Summary | |
protected class |
BeanContextSupport.BCSChild
|
protected static class |
BeanContextSupport.BCSIterator
protected final subclass that encapsulates an iterator but implements a noop remove() method. |
Field Summary | |
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
|
protected Locale |
locale
|
protected boolean |
okToUseGui
|
Fields inherited from class java.beans.beancontext.BeanContextChildSupport |
beanContext,
beanContextChildPeer,
pcSupport,
rejectedSetBCOnce,
vcSupport |
Fields inherited from interface java.beans.beancontext.BeanContext |
globalHierarchyLock |
Fields inherited from interface java.beans.DesignMode |
PROPERTYNAME |
Constructor Summary | |
BeanContextSupport()
Create an instance that is not a delegate of another object |
|
BeanContextSupport(BeanContext peer)
Create an instance using with a default locale |
|
BeanContextSupport(BeanContext peer,
Locale lcle)
Create an instance using the specified locale |
|
BeanContextSupport(BeanContext peer,
Locale lcle,
boolean dtime)
Create an instance using the specified Locale and design mode. |
|
BeanContextSupport(BeanContext peer,
Locale lcle,
boolean dTime,
boolean visible)
Construct a BeanContextSupport instance |
Method Summary | |
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()
Determines whether this bean is avoiding using a GUI. |
protected Iterator |
bcsChildren()
|
protected void |
bcsPreDeserializationHook(ObjectInputStream ois)
called by readObject after defaultReadObject() but prior to deserialization of any children. |
protected void |
bcsPreSerializationHook(ObjectOutputStream oos)
called by writeObject after defaultWriteObject() but prior to serialization of currently serializable children. |
protected void |
childDeserializedHook(Object child,
BeanContextSupport.BCSChild bcsc)
called by readObject with the newly deserialized child and 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. |
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. |
protected static boolean |
classEquals(Class first,
Class second)
|
void |
clear()
clear the children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field |
boolean |
contains(Object o)
Returns true if this collection contains the specified element. |
boolean |
containsAll(Collection c)
Returns true if this collection contains all of the elements in the specified collection. |
boolean |
containsKey(Object o)
|
protected Object[] |
copyChildren()
|
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. |
protected void |
deserialize(ObjectInputStream ois,
Collection coll)
used by readObject to deserialize a collection |
void |
dontUseGui()
notify this instance that it may no longer render a GUI. |
protected void |
fireChildrenAdded(BeanContextMembershipEvent bcme)
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface |
protected void |
fireChildrenRemoved(BeanContextMembershipEvent bcme)
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface |
BeanContext |
getBeanContextPeer()
|
protected static BeanContextChild |
getChildBeanContextChild(Object child)
|
protected static BeanContextMembershipListener |
getChildBeanContextMembershipListener(Object child)
|
protected static PropertyChangeListener |
getChildPropertyChangeListener(Object child)
|
protected static Serializable |
getChildSerializable(Object child)
|
protected static VetoableChangeListener |
getChildVetoableChangeListener(Object child)
|
protected static Visibility |
getChildVisibility(Object child)
|
Locale |
getLocale()
|
URL |
getResource(String name,
BeanContextChild bcc)
|
InputStream |
getResourceAsStream(String name,
BeanContextChild bcc)
|
protected void |
initialize()
protected method called from constructor and readObject to initialize transient state of BeanContextSupport instance. |
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. |
boolean |
isDesignTime()
A value of true denotes that JavaBeans should behave in design time mode, a value of false denotes runtime behavior. |
boolean |
isEmpty()
Returns true if this collection contains no elements. |
boolean |
isSerializing()
|
Iterator |
iterator()
Returns an iterator over the elements in this collection. |
boolean |
needsGui()
Determines whether this bean needs a GUI. |
void |
okToUseGui()
Notify this instance that it may now render a GUI |
void |
propertyChange(PropertyChangeEvent pce)
subclasses may envelope to monitor child property changes. |
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 single instance of the specified element from this collection, if it is present (optional operation). |
protected boolean |
remove(Object targetChild,
boolean callChildSetBC)
|
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 |
protected void |
serialize(ObjectOutputStream oos,
Collection coll)
|
void |
setDesignTime(boolean dTime)
Sets the "value" of the "designTime" property. |
void |
setLocale(Locale newLocale)
|
int |
size()
Returns the number of elements in this collection. |
Object[] |
toArray()
Returns an array containing all of the elements in this collection. |
Object[] |
toArray(Object[] arry)
Returns an array containing all of the elements in this collection whose runtime type is that of the specified array. |
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. |
void |
vetoableChange(PropertyChangeEvent pce)
subclasses may envelope to monitor veto child property changes. |
void |
writeChildren(ObjectOutputStream oos)
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected transient HashMap children
protected HashMap children
field
shall be synchronized on that object.protected transient ArrayList bcmListeners
protected ArrayList bcmListeners
field
shall be synchronized on that object.protected Locale locale
protected boolean okToUseGui
protected boolean designTime
Constructor Detail |
public BeanContextSupport(BeanContext peer, Locale lcle, boolean dTime, boolean visible)
Construct a BeanContextSupport instance
peer
- The peer BeanContext we are supplying an implementation for, if null the this object is its own peerlcle
- 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()
,
public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime)
peer
- The peer BeanContext we are supplying an implementation for, if null the this object is its own peerlcle
- 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()
,
public BeanContextSupport(BeanContext peer, Locale lcle)
peer
- The peer BeanContext we are supplying an implementation for, if null the this object is its own peerlcle
- The current Locale for this BeanContext. If
lcle is null, the default locale
is assigned to the BeanContext instance.Locale.getDefault()
,
public BeanContextSupport(BeanContext peer)
peer
- The peer BeanContext we are supplying an implementation for, if null the this object is its own peerpublic BeanContextSupport()
Method Detail |
public BeanContext getBeanContextPeer()
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.
beanName
- the name of the Bean to instantiate within this BeanContextpublic int size()
public boolean isEmpty()
public boolean contains(Object o)
public boolean containsKey(Object o)
public Iterator iterator()
public Object[] toArray()
The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
public Object[] toArray(Object[] arry)
If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Like the toArray method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs
Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:
String[] x = (String[]) v.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
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 ofpeer
- the peer if the tragetChild and the peer are related by an implementation of BeanContextProxypublic boolean add(Object targetChild)
Adds/nests a child within this BeanContext
Invoked as a side effect of java.beans.Beans.instantiate().
targetChildren
- The child objects to nest within this BeanContextpublic boolean remove(Object targetChild)
targetChildren
- The child objects to removeprotected boolean remove(Object targetChild, boolean callChildSetBC)
public boolean containsAll(Collection c)
public boolean addAll(Collection c)
c
- elements to be inserted into this collection.Collection.add(Object)
public boolean removeAll(Collection c)
c
- elements to be removed from this collection.Collection.remove(Object)
,
Collection.contains(Object)
public boolean retainAll(Collection c)
c
- elements to be retained in this collection.Collection.remove(Object)
,
Collection.contains(Object)
public void clear()
public void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
bcml
- the BeanContextMembershipListener to addpublic void removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
bcml
- the BeanContextMembershipListener to removepublic InputStream getResourceAsStream(String name, BeanContextChild bcc)
name
- the name of the resource requested.child
- the child object making the request.public URL getResource(String name, BeanContextChild bcc)
name
- the name of the resource requested.child
- the child object making the request.public void setDesignTime(boolean dTime)
dTime
- the new designTime valuepublic boolean isDesignTime()
A value of true denotes that JavaBeans should behave in design time mode, a value of false denotes runtime behavior.
public void setLocale(Locale newLocale) throws PropertyVetoException
newLocale
- the new localepublic Locale getLocale()
public boolean needsGui()
public void dontUseGui()
public void okToUseGui()
public boolean avoidingGui()
public boolean isSerializing()
protected Iterator bcsChildren()
protected void bcsPreSerializationHook(ObjectOutputStream oos) throws IOException
protected void bcsPreDeserializationHook(ObjectInputStream ois) throws IOException, ClassNotFoundException
protected void childDeserializedHook(Object child, BeanContextSupport.BCSChild bcsc)
protected final void serialize(ObjectOutputStream oos, Collection coll) throws IOException
protected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException
public final void writeChildren(ObjectOutputStream oos) throws IOException
public final void readChildren(ObjectInputStream ois) throws IOException, ClassNotFoundException
public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException
evt
- a PropertyChangeEvent
object describing the
event source and the property that has changed.public void propertyChange(PropertyChangeEvent pce)
evt
- A PropertyChangeEvent object describing the event source
and the property that has changed.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.
protected void childJustAddedHook(Object child, BeanContextSupport.BCSChild bcsc)
protected void childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
protected static final Visibility getChildVisibility(Object child)
protected static final Serializable getChildSerializable(Object child)
protected static final PropertyChangeListener getChildPropertyChangeListener(Object child)
protected static final VetoableChangeListener getChildVetoableChangeListener(Object child)
protected static final BeanContextMembershipListener getChildBeanContextMembershipListener(Object child)
protected static final BeanContextChild getChildBeanContextChild(Object child)
protected final void fireChildrenAdded(BeanContextMembershipEvent bcme)
protected final void fireChildrenRemoved(BeanContextMembershipEvent bcme)
protected void initialize()
protected final Object[] copyChildren()
protected static final boolean classEquals(Class first, Class second)
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |