| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
BeanContextSupport context = new BeanContextSupport();
Based on 36 examples
public class BeanContextSupport extends BeanContextChildSupport implements BeanContext, Serializable, PropertyChangeListener, VetoableChangeListener
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 class |
|
protected static class |
protected final subclass that encapsulates an iterator but implements a noop remove() method. |
Field Summary | |
---|---|
protected transient ArrayList |
bcmListeners
all accesses to the protected ArrayList bcmListeners field
shall be synchronized on that object. |
protected transient 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. |
Fields inherited from class java.beans.beancontext.BeanContextChildSupport |
---|
beanContext, beanContextChildPeer, pcSupport, rejectedSetBCOnce, vcSupport |
Constructor Summary | |
---|---|
Create an instance that is not a delegate of another object |
|
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 |
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 |
Adds a BeanContextMembershipListener |
boolean |
Used to determine if the BeanContext child is avoiding using its GUI. |
protected Iterator |
Returns an iterator of all children of this BeanContext. |
protected void |
called by readObject after defaultReadObject() but prior to deserialization of any children. |
protected void |
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) 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 |
Determines whether or not the specified object is currently a child of this BeanContext. |
boolean |
Tests to see if all objects in the specified Collection are children of this BeanContext. |
boolean |
Determines whether or not the specified object is currently a child of this BeanContext. |
protected Object[] |
Gets a copy of the this BeanContext's children. |
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 |
notify this instance that it may no longer render a GUI. |
protected void |
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface |
protected void |
Fire a BeanContextshipEvent on the BeanContextMembershipListener interface |
BeanContext |
Gets the instance of BeanContext that this object is providing the implementation for. |
protected static BeanContextChild |
getChildBeanContextChild(Object child) Gets the BeanContextChild (if any) of the specified child |
protected static BeanContextMembershipListener |
Gets the BeanContextMembershipListener (if any) of the specified child |
protected static PropertyChangeListener |
Gets the PropertyChangeListener (if any) of the specified child |
protected static Serializable |
getChildSerializable(Object child) Gets the Serializable (if any) associated with the specified Child |
protected static VetoableChangeListener |
Gets the VetoableChangeListener (if any) of the specified child |
protected static Visibility |
getChildVisibility(Object child) Gets the Component (if any) associated with the specified child. |
Locale |
Gets the locale for this BeanContext. |
URL |
getResource(String name, BeanContextChild bcc) |
InputStream |
getResourceAsStream(String name, BeanContextChild bcc) |
protected void |
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 |
Reports whether or not this object is in currently in design time mode. |
boolean |
isEmpty() Reports whether or not this BeanContext is empty. |
boolean |
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 |
Notify this instance that it may now render a GUI |
void |
subclasses may envelope to monitor child property changes. |
void |
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 |
Removes a child from this BeanContext. |
protected boolean |
internal remove used when removal caused by unexpected setBeanContext or by remove() invocation. |
boolean |
remove all specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field |
void |
Removes a BeanContextMembershipListener |
boolean |
retain only specified children (Unsupported) implementations must synchronized on the hierarchy lock and "children" protected field |
protected void |
serialize(ObjectOutputStream oos, Collection coll) Used by writeObject to serialize a Collection. |
void |
setDesignTime(boolean dTime) Sets the new design time value for this BeanContext. |
void |
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[] |
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. |
void |
subclasses may envelope to monitor veto child property changes. |
void |
Used to serialize all children of this BeanContext. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient ArrayList bcmListeners
protected ArrayList bcmListeners
field
shall be synchronized on that object.
protected transient HashMap children
protected HashMap children
field
shall be synchronized on that object.
protected boolean designTime
protected Locale locale
protected boolean okToUseGui
Constructor Detail |
---|
public BeanContextSupport()
public BeanContextSupport(BeanContext peer)
peer
- The peer BeanContext we are
supplying an implementation for,
or null if this object
is its own peerpublic BeanContextSupport(BeanContext peer, Locale lcle)
peer
- The peer BeanContext we are
supplying an implementation for,
or null if 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.public BeanContextSupport(BeanContext peer, Locale lcle, boolean dtime)
peer
- The peer BeanContext we
are supplying an implementation for,
or null if 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.public BeanContextSupport(BeanContext peer, Locale lcle, boolean dTime, boolean visible)
peer
- The peer BeanContext we are
supplying an implementation for,
or null
if 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.Method Detail |
---|
public boolean add(Object targetChild)
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.
targetChild
- The child objects to nest
within this BeanContextpublic boolean addAll(Collection c)
c
public void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
bcml
- the BeanContextMembershipListener to addpublic boolean avoidingGui()
protected Iterator bcsChildren()
protected void bcsPreDeserializationHook(ObjectInputStream ois) throws IOException, ClassNotFoundException
ois
IOException
ClassNotFoundException
protected void bcsPreSerializationHook(ObjectOutputStream oos) throws IOException
oos
IOException
protected void childDeserializedHook(Object child, BeanContextSupport.BCSChild bcsc)
child
- the newly deserialized childbcsc
- the newly deserialized BCSChildprotected void childJustAddedHook(Object child, BeanContextSupport.BCSChild bcsc)
child
bcsc
protected void childJustRemovedHook(Object child, BeanContextSupport.BCSChild bcsc)
child
bcsc
protected static final boolean classEquals(Class first, Class second)
first
- the first objectsecond
- the second objectpublic void clear()
public boolean contains(Object o)
o
- the Object in questionpublic boolean containsAll(Collection c)
c
- the specified Collectionpublic boolean containsKey(Object o)
o
- the Object in questionprotected final 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.
targetChild
- the child to create the Child on behalf ofpeer
- the peer if the tragetChild and the peer are related by an implementation of BeanContextProxyprotected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException
ois
- the ObjectInputStream to usecoll
- the CollectionIOException
ClassNotFoundException
public synchronized void dontUseGui()
protected final void fireChildrenAdded(BeanContextMembershipEvent bcme)
bcme
protected final void fireChildrenRemoved(BeanContextMembershipEvent bcme)
bcme
public BeanContext getBeanContextPeer()
protected static final BeanContextChild getChildBeanContextChild(Object child)
child
- the specified childprotected static final BeanContextMembershipListener getChildBeanContextMembershipListener(Object child)
child
- the specified childprotected static final PropertyChangeListener getChildPropertyChangeListener(Object child)
child
- the specified childprotected static final Serializable getChildSerializable(Object child)
child
- the specified childprotected static final VetoableChangeListener getChildVetoableChangeListener(Object child)
child
- the specified childprotected static final Visibility getChildVisibility(Object child)
child
- the specified childpublic synchronized Locale getLocale()
public URL getResource(String name, BeanContextChild bcc)
name
- the name of the resource requested.bcc
- the child object making the request.public InputStream getResourceAsStream(String name, BeanContextChild bcc)
name
- the name of the resource requested.bcc
- the child object making the request.protected synchronized void initialize()
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 BeanContextIOException
- if there is an I/O error when the bean is being deserializedClassNotFoundException
- if the class
identified by the beanName parameter is not foundpublic synchronized boolean isDesignTime()
public boolean isEmpty()
public boolean isSerializing()
public Iterator iterator()
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()
public void propertyChange(PropertyChangeEvent pce)
pce
public final void readChildren(ObjectInputStream ois) throws IOException, ClassNotFoundException
ois
IOException
ClassNotFoundException
public boolean remove(Object targetChild)
targetChild
- The child objects to removeprotected boolean remove(Object targetChild, boolean callChildSetBC)
targetChild
- the JavaBean, BeanContext, or Object to be removedcallChildSetBC
- used to indicate that
the child should be notified that it is no
longer nested in this BeanContext.public boolean removeAll(Collection c)
c
public void removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
bcml
- the BeanContextMembershipListener to removepublic boolean retainAll(Collection c)
c
protected final void serialize(ObjectOutputStream oos, Collection coll) throws IOException
oos
- the ObjectOutputStream
to use during serializationcoll
- the Collection to serializeIOException
- if serialization failedpublic synchronized void setDesignTime(boolean dTime)
dTime
- the new designTime valuepublic synchronized void setLocale(Locale newLocale) throws PropertyVetoException
newLocale
- the new locale. This method call will have
no effect if newLocale is null
.PropertyVetoException
- if the new value is rejectedpublic int size()
public Object[] toArray()
public Object[] toArray(Object[] arry)
arry
- The array of object
types that are of interest.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.
targetChild
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.
targetChild
public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException
pce
PropertyVetoException
public final void writeChildren(ObjectOutputStream oos) throws IOException
oos
- the ObjectOutputStream
to use during serializationIOException
- if serialization failed
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |