public class BeanContextSupport extends BeanContextChildSupport implements BeanContext, PropertyChangeListener, VetoableChangeListener, Serializable
BeanContext
interface.
This class can be used directly, or be a super class of your class,
or be a delegate of your implementation that needs to support
BeanContext
interface.beanContextChildPeer
globalHierarchyLock
PROPERTYNAME
Constructor and Description |
---|
BeanContextSupport()
Constructs a standload
BeanContextSupport . |
BeanContextSupport(BeanContext peer)
Constructs a
BeanContextSupport which is a delegate
of the given peer. |
BeanContextSupport(BeanContext peer,
Locale locale)
Constructs a
BeanContextSupport which is a delegate
of the given peer. |
BeanContextSupport(BeanContext peer,
Locale locale,
boolean designTime)
Constructs a
BeanContextSupport which is a delegate
of the given peer. |
BeanContextSupport(BeanContext peer,
Locale locale,
boolean designTime,
boolean okToUseGui)
Constructs a
BeanContextSupport which is a delegate
of the given peer. |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object child)
Add a child to this context.
|
boolean |
addAll(Collection collection)
This method is unsupported, throws
UnsupportedOperationException . |
void |
addBeanContextMembershipListener(BeanContextMembershipListener listener) |
boolean |
avoidingGui() |
void |
clear()
This method is unsupported, throws
UnsupportedOperationException . |
boolean |
contains(Object child)
Returns true if the given object is a child of this context.
|
boolean |
containsAll(Collection collection)
Returns true if given objects are children of this context.
|
boolean |
containsKey(Object child)
Returns true if the given object is a child of this context.
|
void |
dontUseGui() |
BeanContext |
getBeanContextPeer()
Returns the peer of this context casted as
BeanContext . |
Locale |
getLocale()
Returns the locale of this context.
|
URL |
getResource(String resourceName,
BeanContextChild child) |
InputStream |
getResourceAsStream(String resourceName,
BeanContextChild child) |
Object |
instantiateChild(String beanName) |
boolean |
isDesignTime() |
boolean |
isEmpty() |
boolean |
isSerializing()
Returns true if this context is currently being serialized
(by another thread).
|
Iterator |
iterator()
Returns an iterator of children of this context,
with
remove() disabled. |
boolean |
needsGui()
Returns true if this context or its children needs GUI to work properly.
|
void |
okToUseGui() |
void |
propertyChange(PropertyChangeEvent event) |
void |
readChildren(ObjectInputStream ois)
Deserializes children from the given object input stream.
|
boolean |
remove(Object child)
Removes the given child from this context.
|
boolean |
removeAll(Collection collection)
This method is unsupported, throws
UnsupportedOperationException . |
void |
removeBeanContextMembershipListener(BeanContextMembershipListener listener) |
boolean |
retainAll(Collection collection)
This method is unsupported, throws
UnsupportedOperationException . |
void |
setDesignTime(boolean designTime) |
void |
setLocale(Locale newLocale)
Sets the locale of this context.
|
int |
size()
Returns the number children of this context.
|
Object[] |
toArray()
Returns an array of children of this context.
|
Object[] |
toArray(Object[] array)
Returns an array of children of this context.
|
void |
vetoableChange(PropertyChangeEvent pce) |
void |
writeChildren(ObjectOutputStream oos)
Serializes children to the given object input stream.
|
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, fireVetoableChange, getBeanContext, getBeanContextChildPeer, isDelegated, removePropertyChangeListener, removeVetoableChangeListener, serviceAvailable, serviceRevoked, setBeanContext, validatePendingSetBeanContext
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
equals, hashCode
public BeanContextSupport()
BeanContextSupport
.public BeanContextSupport(BeanContext peer)
BeanContextSupport
which is a delegate
of the given peer.peer
- the peer of this contextpublic BeanContextSupport(BeanContext peer, Locale locale)
BeanContextSupport
which is a delegate
of the given peer.peer
- the peer of this contextlocale
- the locale of this contextpublic BeanContextSupport(BeanContext peer, Locale locale, boolean designTime)
BeanContextSupport
which is a delegate
of the given peer.peer
- the peer of this contextlocale
- the locale of this contextdesignTime
- whether in design mode or notpublic BeanContextSupport(BeanContext peer, Locale locale, boolean designTime, boolean okToUseGui)
BeanContextSupport
which is a delegate
of the given peer.peer
- the peer of this contextlocale
- the locale of this contextdesignTime
- whether in design mode or notokToUseGui
- whether GUI is usable or notpublic boolean add(Object child)
If the child already exists in this context, simply returns false.
Otherwise, it is validated by calling validatePendingAdd()
.
If the add is valid, the child and its proxy (if the child implements
BeanContextProxy
) is then added, and setBeanContext()
is called on it (if the child implements BeanContextChild
or it has a proxy). Last, the childJustAddedHook()
is
called and all registered BeanContextMembershipListener
s
are notified.
add
in interface Collection
child
- the child to addIllegalStateException
- if the child is not valid to addCollection.add(java.lang.Object)
public boolean addAll(Collection collection)
UnsupportedOperationException
.addAll
in interface Collection
Collection.addAll(java.util.Collection)
public void addBeanContextMembershipListener(BeanContextMembershipListener listener)
addBeanContextMembershipListener
in interface BeanContext
public boolean avoidingGui()
avoidingGui
in interface Visibility
public void clear()
UnsupportedOperationException
.clear
in interface Collection
Collection.clear()
public boolean contains(Object child)
contains
in interface Collection
child
- the object to testCollection.contains(java.lang.Object)
public boolean containsAll(Collection collection)
containsAll
in interface Collection
collection
- a collection of objectsCollection.containsAll(java.util.Collection)
public boolean containsKey(Object child)
child
- the object to testpublic void dontUseGui()
dontUseGui
in interface Visibility
public BeanContext getBeanContextPeer()
BeanContext
.BeanContext
public Locale getLocale()
public URL getResource(String resourceName, BeanContextChild child)
getResource
in interface BeanContext
public InputStream getResourceAsStream(String resourceName, BeanContextChild child) throws IllegalArgumentException
getResourceAsStream
in interface BeanContext
IllegalArgumentException
public Object instantiateChild(String beanName) throws IOException, ClassNotFoundException
instantiateChild
in interface BeanContext
IOException
ClassNotFoundException
public boolean isDesignTime()
isDesignTime
in interface DesignMode
public boolean isEmpty()
isEmpty
in interface Collection
public boolean isSerializing()
public Iterator iterator()
remove()
disabled.iterator
in interface Iterable
iterator
in interface Collection
Collection.iterator()
public boolean needsGui()
The implementation checks the peer and all the children that implement
Visibility
to see if any of their needsGui()
returns true, and if any of the children extends
java.awt.Component
.
needsGui
in interface Visibility
Visibility.needsGui()
public void okToUseGui()
okToUseGui
in interface Visibility
public void propertyChange(PropertyChangeEvent event)
propertyChange
in interface PropertyChangeListener
public final void readChildren(ObjectInputStream ois) throws IOException, ClassNotFoundException
The implementation reads pairs of child object and BCSChild
object according to serializable
property. For each pair,
it is added to the children
map and the
childDeserializedHook()
is called. If the child implements
BeanContextChild
, its setBeanContext()
is
also called.
This method is called by readObject()
if the context works
standalone. Or if this support object is a delegate of another
BeanContext
implementation, then this method should be
called by the peer. Doing this means that derialization can proceed
without any circular dependency problems.
ois
- the object input streamIOException
- if I/O exception occursClassNotFoundException
- if class of read object is not foundpublic boolean remove(Object child)
Delegates to remove(child, true)
.
remove
in interface Collection
child
- a child of this contextIllegalArgumentException
- if the child is nullIllegalStateException
- if the child is not valid to removeCollection.remove(java.lang.Object)
public boolean removeAll(Collection collection)
UnsupportedOperationException
.removeAll
in interface Collection
Collection.removeAll(java.util.Collection)
public void removeBeanContextMembershipListener(BeanContextMembershipListener listener)
removeBeanContextMembershipListener
in interface BeanContext
public boolean retainAll(Collection collection)
UnsupportedOperationException
.retainAll
in interface Collection
Collection.retainAll(java.util.Collection)
public void setDesignTime(boolean designTime)
setDesignTime
in interface DesignMode
public void setLocale(Locale newLocale) throws PropertyVetoException
VetoableChangeListener
s
and PropertyChangeListener
s are notified.newLocale
- the new locale to setPropertyVetoException
- if any VetoableChangeListener
vetos this changepublic int size()
size
in interface Collection
Collection.size()
public Object[] toArray()
toArray
in interface Collection
Collection.toArray()
public Object[] toArray(Object[] array)
toArray
in interface Collection
Collection.toArray(java.lang.Object[])
public void vetoableChange(PropertyChangeEvent pce) throws PropertyVetoException
vetoableChange
in interface VetoableChangeListener
PropertyVetoException
public final void writeChildren(ObjectOutputStream oos) throws IOException
The implementation iterates through all children and writes out pairs
of child object and BCSChild
object if the child is
serializable (implements Serialization
.
This method is called by writeObject()
if the context
works standalone. Or if this support object is a delegate of another
BeanContext
implementation, then this method should be
called by the peer to avoid the 'chicken and egg' problem during
deserialization.
oos
- the stream to writeIOException
- if I/O exception occursCopyright © 2013. All Rights Reserved.