Ja.NET Standard Edition 5.0

Documentation API Specification

Contents

BeanContextSupport Class Reference

Inherits java::beans::beancontext::BeanContextChildSupport, java::beans::beancontext::BeanContext, java::beans::PropertyChangeListener, java::beans::VetoableChangeListener, and java::io::Serializable.

Inherited by BeanContextServicesSupport.

List of all members.


Detailed Description

This support class implements 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.


Public Member Functions

 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.
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) throws IllegalArgumentException
Object instantiateChild (String beanName) throws IOException, ClassNotFoundException
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)
final void readChildren (ObjectInputStream ois) throws IOException, ClassNotFoundException
 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) throws PropertyVetoException
 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) throws PropertyVetoException
final void writeChildren (ObjectOutputStream oos) throws IOException
 Serializes children to the given object input stream.

Protected Member Functions

Iterator bcsChildren ()
 Returns an iterator of all BCSChild instances, with remove() disabled.
void bcsPreDeserializationHook (ObjectInputStream ois) throws IOException, ClassNotFoundException
 This method is called by readObject() after defaultReadObject() and before deserializing any children or listeners.
void bcsPreSerializationHook (ObjectOutputStream oos) throws IOException
 This method is called by writeObject() after defaultWriteObject() and before serializing any children or listeners.
void childDeserializedHook (Object child, BCSChild bcsChild)
 This method is called during deserialization everytime a child is read.
void childJustAddedHook (Object child, BCSChild bcsChild)
 This method is called everytime a child is added to this context.
void childJustRemovedHook (Object child, BCSChild bcsChild)
 This method is called everytime a child is removed from this context.
final Object[] copyChildren ()
 Returns an array containing all children of this context.
BCSChild createBCSChild (Object child, Object proxyPeer)
 Creates a BCSChild object to company the given child.
final void deserialize (ObjectInputStream ois, Collection collection) throws IOException, ClassNotFoundException
 Deserialize a collection.
final void fireChildrenAdded (BeanContextMembershipEvent event)
 Notifies registered BeanContextMembershipListeners that a new child has been added.
final void fireChildrenRemoved (BeanContextMembershipEvent event)
 Notifies registered BeanContextMembershipListeners that a child has been removed.
void initialize ()
 Initializes all transient fields of this instance, called by constructors and readObject().
boolean remove (Object child, boolean setChildBC)
 Removes the given child from this context.
final void serialize (ObjectOutputStream oos, Collection collection) throws IOException
 Serializes the given collection.
boolean validatePendingAdd (Object child)
 Validates the pending add of child.
boolean validatePendingRemove (Object child)
 Validates the pending removal of child.

Static Protected Member Functions

static final boolean classEquals (Class clz1, Class clz2)
 Compares if two classes are equal or their class names are equal.
static final BeanContextChild getChildBeanContextChild (Object child)
 Returns the BeanContextChild related with the given child.
static final
BeanContextMembershipListener 
getChildBeanContextMembershipListener (Object child)
 Returns the given child casted to BeanContextMembershipListener, or null if it does not implements the interface.
static final PropertyChangeListener getChildPropertyChangeListener (Object child)
 Returns the given child casted to PropertyChangeListener, or null if it does not implements the interface.
static final Serializable getChildSerializable (Object child)
 Returns the given child casted to Serializable, or null if it does not implements the interface.
static final VetoableChangeListener getChildVetoableChangeListener (Object child)
 Returns the given child casted to VetoableChangeListener, or null if it does not implements the interface.
static final Visibility getChildVisibility (Object child)
 Returns the given child casted to Visibility, or null if it does not implements the interface.

Protected Attributes

transient ArrayList bcmListeners
 A list of registered membership listeners.
transient HashMap children
 A map of children - key is child instance, value is BCSChild instance.
Locale locale
 The locale of this context.
boolean okToUseGui
 A flag indicating whether this context is allowed to use GUI.
boolean designTime
 A flag indicating whether this context is in design mode.

Static Package Attributes

static final long serialVersionUID = -4879613978649577204L

Private Member Functions

void writeObject (ObjectOutputStream oos) throws IOException
 The implementation goes through following steps:.
void readObject (ObjectInputStream ois) throws IOException, ClassNotFoundException
 The implementation goes through following steps:.

Private Attributes

transient boolean serializing
transient boolean inNeedsGui
transient PropertyChangeListener nonSerPCL
int serializable

Classes

class  BCSChild
 Every child of context is companied with a BCSChild instance. More...
class  BCSIterator
 This implementation wraps an iterator and override remove() with a noop method. More...

Constructor & Destructor Documentation

Constructs a standload BeanContextSupport.

Constructs a BeanContextSupport which is a delegate of the given peer.

Parameters:
peer the peer of this context

BeanContextSupport ( BeanContext  peer,
Locale  locale 
)

Constructs a BeanContextSupport which is a delegate of the given peer.

Parameters:
peer the peer of this context
locale the locale of this context

BeanContextSupport ( BeanContext  peer,
Locale  locale,
boolean  designTime 
)

Constructs a BeanContextSupport which is a delegate of the given peer.

Parameters:
peer the peer of this context
locale the locale of this context
designTime whether in design mode or not

BeanContextSupport ( BeanContext  peer,
Locale  locale,
boolean  designTime,
boolean  okToUseGui 
)

Constructs a BeanContextSupport which is a delegate of the given peer.

Parameters:
peer the peer of this context
locale the locale of this context
designTime whether in design mode or not
okToUseGui whether GUI is usable or not


Member Function Documentation

boolean add ( Object  child  ) 

Add a child to this context.

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 BeanContextMembershipListeners are notified.

Parameters:
child the child to add
Returns:
true if the child is added to this context; otherwise false
Exceptions:
IllegalStateException if the child is not valid to add
See also:
java.util.Collection.add(java.lang.Object)

boolean addAll ( Collection  collection  ) 

This method is unsupported, throws UnsupportedOperationException.

See also:
java.util.Collection.addAll(java.util.Collection)

void addBeanContextMembershipListener ( BeanContextMembershipListener  listener  ) 

Implements BeanContext.

boolean avoidingGui (  ) 

Implements Visibility.

Iterator bcsChildren (  )  [protected]

Returns an iterator of all BCSChild instances, with remove() disabled.

Returns:
an iterator of all BCSChild instances

void bcsPreDeserializationHook ( ObjectInputStream  ois  )  throws IOException, ClassNotFoundException [protected]

This method is called by readObject() after defaultReadObject() and before deserializing any children or listeners.

Subclass can insert its specific deserialization behavior by overrideing this method.

The default implementation does nothing.

Parameters:
ois the object input stream
Exceptions:
IOException 
ClassNotFoundException 

Reimplemented in BeanContextServicesSupport.

void bcsPreSerializationHook ( ObjectOutputStream  oos  )  throws IOException [protected]

This method is called by writeObject() after defaultWriteObject() and before serializing any children or listeners.

Subclass can insert its specific serialization behavior by overrideing this method.

The default implementation does nothing.

Parameters:
oos the object output stream
Exceptions:
IOException 

Reimplemented in BeanContextServicesSupport.

void childDeserializedHook ( Object  child,
BCSChild  bcsChild 
) [protected]

This method is called during deserialization everytime a child is read.

The default implementation does nothing.

Parameters:
child the child just deserialized
bcsChild the BCSChild just deserialized

void childJustAddedHook ( Object  child,
BCSChild  bcsChild 
) [protected]

This method is called everytime a child is added to this context.

This method is called with child synchronized.

The default implementation does nothing.

Parameters:
child the child just added
bcsChild the BCSChild just added

void childJustRemovedHook ( Object  child,
BCSChild  bcsChild 
) [protected]

This method is called everytime a child is removed from this context.

This method is called with child synchronized.

The default implementation does nothing.

Parameters:
child the child just removed
bcsChild the BCSChild just removed

Reimplemented in BeanContextServicesSupport.

static final boolean classEquals ( Class  clz1,
Class  clz2 
) [static, protected]

Compares if two classes are equal or their class names are equal.

Parameters:
clz1 a class
clz2 another class
Returns:
true if two class objects are equal or their class names are equal.

void clear (  ) 

This method is unsupported, throws UnsupportedOperationException.

See also:
java.util.Collection.clear()

boolean contains ( Object  child  ) 

Returns true if the given object is a child of this context.

Parameters:
child the object to test
Returns:
true if the given object is a child of this context
See also:
java.util.Collection.contains(java.lang.Object)

boolean containsAll ( Collection  collection  ) 

Returns true if given objects are children of this context.

Parameters:
collection a collection of objects
Returns:
true if given objects are children of this context
See also:
java.util.Collection.containsAll(java.util.Collection)

boolean containsKey ( Object  child  ) 

Returns true if the given object is a child of this context.

Parameters:
child the object to test
Returns:
true if the given object is a child of this context

final Object [] copyChildren (  )  [protected]

Returns an array containing all children of this context.

Returns:
an array containing all children of this context

BCSChild createBCSChild ( Object  child,
Object  proxyPeer 
) [protected]

Creates a BCSChild object to company the given child.

Parameters:
child the child
proxyPeer the proxy peer of the child if there is one
Returns:
a BCSChild object to company the given child

Reimplemented in BeanContextServicesSupport.

final void deserialize ( ObjectInputStream  ois,
Collection  collection 
) throws IOException, ClassNotFoundException [protected]

Deserialize a collection.

First read a int indicating of number of rest objects, then read the objects one by one.

Parameters:
ois the stream where the collection is read from
collection the collection to hold read objects
Exceptions:
IOException if I/O exception occurs
ClassNotFoundException if class of any read object is not found

void dontUseGui (  ) 

Implements Visibility.

final void fireChildrenAdded ( BeanContextMembershipEvent  event  )  [protected]

Notifies registered BeanContextMembershipListeners that a new child has been added.

Parameters:
event the BeanContextMembershipEvent

final void fireChildrenRemoved ( BeanContextMembershipEvent  event  )  [protected]

Notifies registered BeanContextMembershipListeners that a child has been removed.

Parameters:
event the BeanContextMembershipEvent

BeanContext getBeanContextPeer (  ) 

Returns the peer of this context casted as BeanContext.

Returns:
the peer of this context casted as BeanContext

static final BeanContextChild getChildBeanContextChild ( Object  child  )  [static, protected]

Returns the BeanContextChild related with the given child.

If the child implements BeanContextChild, it is returned. If the child implements BeanContextProxy, the proxy is returned. Otherwise, null is returned.

Parameters:
child a child
Returns:
the BeanContextChild related with the given child
Exceptions:
IllegalStateException if the child implements both BeanContextChild and BeanContextProxy

static final BeanContextMembershipListener getChildBeanContextMembershipListener ( Object  child  )  [static, protected]

Returns the given child casted to BeanContextMembershipListener, or null if it does not implements the interface.

Parameters:
child a child
Returns:
the given child casted to BeanContextMembershipListener, or null if it does not implements the interface

static final PropertyChangeListener getChildPropertyChangeListener ( Object  child  )  [static, protected]

Returns the given child casted to PropertyChangeListener, or null if it does not implements the interface.

Parameters:
child a child
Returns:
the given child casted to PropertyChangeListener, or null if it does not implements the interface

static final Serializable getChildSerializable ( Object  child  )  [static, protected]

Returns the given child casted to Serializable, or null if it does not implements the interface.

Parameters:
child a child
Returns:
the given child casted to Serializable, or null if it does not implements the interface

static final VetoableChangeListener getChildVetoableChangeListener ( Object  child  )  [static, protected]

Returns the given child casted to VetoableChangeListener, or null if it does not implements the interface.

Parameters:
child a child
Returns:
the given child casted to VetoableChangeListener, or null if it does not implements the interface

static final Visibility getChildVisibility ( Object  child  )  [static, protected]

Returns the given child casted to Visibility, or null if it does not implements the interface.

Parameters:
child a child
Returns:
the given child casted to Visibility, or null if it does not implements the interface

Locale getLocale (  ) 

Returns the locale of this context.

Returns:
the locale of this context

URL getResource ( String  resourceName,
BeanContextChild  child 
)

Implements BeanContext.

InputStream getResourceAsStream ( String  resourceName,
BeanContextChild  child 
) throws IllegalArgumentException

Implements BeanContext.

void initialize (  )  [protected]

Initializes all transient fields of this instance, called by constructors and readObject().

Reimplemented in BeanContextServicesSupport.

Object instantiateChild ( String  beanName  )  throws IOException, ClassNotFoundException

Implements BeanContext.

boolean isDesignTime (  ) 

Implements DesignMode.

boolean isEmpty (  ) 

boolean isSerializing (  ) 

Returns true if this context is currently being serialized (by another thread).

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.

See also:
java.util.Collection.iterator()

boolean needsGui (  ) 

Returns true if this context or its children needs GUI to work properly.

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.

See also:
java.beans.Visibility.needsGui()

Implements Visibility.

void okToUseGui (  ) 

Implements Visibility.

void propertyChange ( PropertyChangeEvent  event  ) 

final void readChildren ( ObjectInputStream  ois  )  throws IOException, ClassNotFoundException

Deserializes children from the given object input stream.

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.

Parameters:
ois the object input stream
Exceptions:
IOException if I/O exception occurs
ClassNotFoundException if class of read object is not found

boolean remove ( Object  child  ) 

Removes the given child from this context.

Delegates to remove(child, true).

Parameters:
child a child of this context
Returns:
true if the child is removed; or false if it is not a child of this context
Exceptions:
IllegalArgumentException if the child is null
IllegalStateException if the child is not valid to remove
See also:
java.util.Collection.remove(java.lang.Object)

boolean remove ( Object  child,
boolean  setChildBC 
) [protected]

Removes the given child from this context.

If the given child is not a child of this context, simply returns false. Otherwise, validatePendingRemove() is called. If the removal is valid, the child's beanContext property is updated (if required) and the child and its proxy peer (if there is one) is removed. Last, childJustRemovedHook() is called and listeners are notified.

Parameters:
child a child of this context
setChildBC whether to call setBeanContext() on the child or not
Returns:
true if the child is removed; or false if it is not a child of this context
Exceptions:
IllegalArgumentException if the child is null
IllegalStateException if the child is not valid to remove

boolean removeAll ( Collection  collection  ) 

This method is unsupported, throws UnsupportedOperationException.

See also:
java.util.Collection.removeAll(java.util.Collection)

void removeBeanContextMembershipListener ( BeanContextMembershipListener  listener  ) 

Implements BeanContext.

boolean retainAll ( Collection  collection  ) 

This method is unsupported, throws UnsupportedOperationException.

See also:
java.util.Collection.retainAll(java.util.Collection)

final void serialize ( ObjectOutputStream  oos,
Collection  collection 
) throws IOException [protected]

Serializes the given collection.

First writes a int indicating the number of all serializable elements (implements Serializable, then objects are writtern one by one.

Parameters:
oos the stream where the collection is writtern to
collection the collection to serialize
Exceptions:
IOException if I/O exception occurs

void setDesignTime ( boolean  designTime  ) 

Implements DesignMode.

void setLocale ( Locale  newLocale  )  throws PropertyVetoException

Sets the locale of this context.

VetoableChangeListeners and PropertyChangeListeners are notified.

Parameters:
newLocale the new locale to set
Exceptions:
PropertyVetoException if any VetoableChangeListener vetos this change

int size (  ) 

Returns the number children of this context.

Returns:
the number children of this context
See also:
java.util.Collection.size()

Object [] toArray (  ) 

Returns an array of children of this context.

Returns:
an array of children of this context
See also:
java.util.Collection.toArray()

Object [] toArray ( Object[]  array  ) 

Returns an array of children of this context.

Returns:
an array of children of this context
See also:
java.util.Collection.toArray(java.lang.Object[])

boolean validatePendingAdd ( Object  child  )  [protected]

Validates the pending add of child.

Default implementation always returns true.

Parameters:
child the child to be added
Returns:
true if it is valid to add the child

boolean validatePendingRemove ( Object  child  )  [protected]

Validates the pending removal of child.

Default implementation always returns true.

Parameters:
child the child to be removed
Returns:
true if it is valid to remove the child

void vetoableChange ( PropertyChangeEvent  pce  )  throws PropertyVetoException

final void writeChildren ( ObjectOutputStream  oos  )  throws IOException

Serializes children to the given object input stream.

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.

Parameters:
oos the stream to write
Exceptions:
IOException if I/O exception occurs

void writeObject ( ObjectOutputStream  oos  )  throws IOException [private]

The implementation goes through following steps:.

  1. Writes out non-transient properties by calling defaultWriteObject(), especially the serializable indicating the number of serializable children.
  2. Calls bcsPreSerializationHook().
  3. Writes out children by calling writeChildren() if this context works standalone. Otherwise it is the peer's responsibility to call writeChildren() after this object is serialized.
  4. Writes out serializable membership listeners.

Parameters:
oos the object output stream
Exceptions:
IOException if I/O exception occurs

Reimplemented from BeanContextChildSupport.

Reimplemented in BeanContextServicesSupport.

void readObject ( ObjectInputStream  ois  )  throws IOException, ClassNotFoundException [private]

The implementation goes through following steps:.

  1. Reads non-transient properties by calling defaultReadObject().
  2. Calls bcsPreDeserializationHook().
  3. Reads children by calling readChildren() if this context works standalone. Otherwise it is the peer's responsibility to call readChildren() after this object is deserialized.
  4. Reads serializable membership listeners.

Parameters:
ois the object input stream
Exceptions:
IOException if I/O error occurs
ClassNotFoundException if class of read object is not found

Reimplemented from BeanContextChildSupport.

Reimplemented in BeanContextServicesSupport.


Member Data Documentation

final long serialVersionUID = -4879613978649577204L [static, package]

Reimplemented from BeanContextChildSupport.

Reimplemented in BeanContextServicesSupport.

transient ArrayList bcmListeners [protected]

A list of registered membership listeners.

All access to this object should be synchronized on itself.

transient HashMap children [protected]

A map of children - key is child instance, value is BCSChild instance.

All access to this object should be synchronized on itself.

transient boolean serializing [private]

transient boolean inNeedsGui [private]

transient PropertyChangeListener nonSerPCL [private]

int serializable [private]

Reimplemented in BeanContextServicesSupport.

Locale locale [protected]

The locale of this context.

boolean okToUseGui [protected]

A flag indicating whether this context is allowed to use GUI.

boolean designTime [protected]

A flag indicating whether this context is in design mode.