All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.mb.BeanBagModel

java.lang.Object
   |
   +----com.ibm.beans.mb.BeanBagModel

public class BeanBagModel
extends Object
implements Serializable, Cloneable, ModelSelectable
This class contains the function for manipulating a selectable collection of managed beans. The contents of the collection can be loaded from Repository objects.

See Also:
Serializable, Cloneable, Repository

Variable Index

 o BEANBAGMODEL_ADD
Indicates that a bean was added to the BeanBagModel instance.
 o BEANBAGMODEL_CHANGE
Indicates that a bean was modified in the BeanBagModel instance.
 o BEANBAGMODEL_REMOVE
Indicates that a bean was removed from the BeanBagModel instance.

Constructor Index

 o BeanBagModel()
Constructs a BeanBagModel that is initially empty.
 o BeanBagModel(BeanBagModel)
Constructs a BeanBagModel instance from an existing BeanBagModel instance.
 o BeanBagModel(Class, String)
Constructs a BeanBagModel instance containing the managed beans from the specified Repository.
 o BeanBagModel(Vector)
Constructs a BeanBagModel instance containing the specified beans.

Method Index

 o add(Object)
Ensures that this Collection contains the specified element.
 o addAll(Vector)
Adds all of the elements in the specified collection to this collection, in the order they are returned by the specified collection's iterator.
 o addItemListener(ItemListener)
Add a listener to recieve item events when the state of an item changes.
 o addModelChangeListener(ModelChangeListener)
Adds a model change listener to the list of listeners.
 o clear()
Removes all of the elements from the model.
 o clone()
Clones the BeanBagModel.
 o contains(Object)
Indicates whether the model contains the specified element.
 o deselect(Object)
De-selects the specified managed bean.
 o deselect(Vector)
De-selects the specified managed beans.
 o doAdd(Vector)
Adds the specified managed beans to the model.
 o doCopyToRepository(Class, String)
Copies the currently-selected managed beans to the specified repository.
 o doDeleteFromRepository(Class, String)
Deletes the currently-selected managed beans from the specified repository.
 o doGetAll()
Returns all the managed beans contained in the model.
 o doGetSelected()
Returns the managed beans that are currently selected.
 o doRemove()
Removes all the currently-selected managed beans from the model.
 o doUnbindFromRepository()
Removes any association with a repository from the currently-selected managed beans.
 o elements()
Gets an enumeration of the elements in the collection.
 o equals(Object)
Tests for equality with the passed object.
 o fireBeanBagModelChangeEvent(ModelEvent, int)
Propagates a ModelEvent to registered model change listeners.
 o fireItemStateChanged(ItemEvent)
Propagates an ItemEvent to registered ItemListener objects.
 o getRepositoryAccessMode()
Gets the access mode used when repositories are loaded.
 o getSelectedObjects()
Returns the selected items, or null if no items are selected.
 o hashCode()
Gets a hash code for an instance of this class.
 o isEmpty()
Indicates whether the model contains no elements.
 o isSelected(ManagedBean)
Queries whether the specified managed bean is currently selected.
 o loadBeanClass(String, String)
Adds to the BeanBagModel the specified bean from the specified class.
 o loadBeanClassInJar(String, String)
Adds to the BeanBagModel the specified bean from the specified jar file.
 o loadDirOfJars(String)
Adds to the BeanBagModel all the beans in all the jars in the specified directory.
 o loadFromRepository(Class, String)
Adds to the model all the managed beans contained in the specified Repository.
 o remove(Object)
Removes a single instance of the specified element from the model, if it is present.
 o removeItemListener(ItemListener)
Removes an item listener.
 o removeModelChangeListener(ModelChangeListener)
Removes a model change listener from the list of listeners.
 o select(Object)
Selects the specified managed bean.
 o select(Vector)
Selects the specified managed beans.
 o selectAll()
Selects all managed beans in the BeanBagModel object.
 o selectAllFromRepository(Class, String)
Selects all managed beans that are associated with the specified repository.
 o selectAllFromRepositoryClass(Class)
Selects all managed beans that are associated with any repository of the specified class.
 o selectAllFromRepositoryName(String)
Selects all managed beans that are associated with the specified repository.
 o selectBound()
Selects all beans that are associated with any repository.
 o selectNone()
De-selects all managed beans.
 o selectUnbound()
Selects all managed beans that are not associated with any repository.
 o selectWithFilter(ManagedBeanFilter)
Selects all managed beans that meet the criteria imposed by the specified ManagedBeanFilter object.
 o setRepositoryAccessMode(int)
Sets the access mode to be used when repositories are loaded.
 o size()
Returns the number of elements in the bean bag model.
 o toArray()
Returns an array containing all of the elements in the model.

Variables

 o BEANBAGMODEL_ADD
 protected static final int BEANBAGMODEL_ADD
Indicates that a bean was added to the BeanBagModel instance.

 o BEANBAGMODEL_REMOVE
 protected static final int BEANBAGMODEL_REMOVE
Indicates that a bean was removed from the BeanBagModel instance.

 o BEANBAGMODEL_CHANGE
 protected static final int BEANBAGMODEL_CHANGE
Indicates that a bean was modified in the BeanBagModel instance.

Constructors

 o BeanBagModel
 public BeanBagModel()
Constructs a BeanBagModel that is initially empty. The repository access mode is set to read-only by default.

 o BeanBagModel
 public BeanBagModel(Vector mbeans)
Constructs a BeanBagModel instance containing the specified beans. The repository access mode is set to read-only by default.

Parameters:
mbeans - The initial set of managed beans to be contained in the model.
 o BeanBagModel
 public BeanBagModel(Class repoClass,
                     String repoName)
Constructs a BeanBagModel instance containing the managed beans from the specified Repository. The repository is accessed in read-only mode.

Parameters:
repoClass - This parameter is unused and should be null.
repoName - The name of the Repository (typically the location of a directory or JAR file in the file system).
 o BeanBagModel
 public BeanBagModel(BeanBagModel model)
Constructs a BeanBagModel instance from an existing BeanBagModel instance. The new and old BeanBagModel objects will share the same ManagedBean objects. The new BeanBagModel will initially have the same selection and repository access mode as the original. Listeners of the input BeanBagModel are not copied to the new BeanBagModel. If the input model reference is null, a NullPointerException is thrown.

Parameters:
model - The BeanBagModel instance to be copied.

Methods

 o selectAllFromRepository
 public void selectAllFromRepository(Class repoClass,
                                     String repoName)
Selects all managed beans that are associated with the specified repository. Any previously selected beans remain selected.

Parameters:
repoClass - The class of the repository (any subclass of com.ibm.beans.mb.RepositoryModel).
repoName - The name of the repository (typically the location of a directory or JAR file in the file system).
 o selectAllFromRepositoryClass
 public void selectAllFromRepositoryClass(Class repoClass)
Selects all managed beans that are associated with any repository of the specified class. Any previously selected beans remain selected.

Parameters:
repoClass - The class of the repository (any subclass of com.ibm.beans.mb.RepositoryModel).
 o selectAllFromRepositoryName
 public void selectAllFromRepositoryName(String repoName)
Selects all managed beans that are associated with the specified repository. Any previously selected beans remain selected.

Parameters:
repoName - The name of the repository.
 o selectUnbound
 public void selectUnbound()
Selects all managed beans that are not associated with any repository. Any previously selected beans remain selected.

 o selectBound
 public void selectBound()
Selects all beans that are associated with any repository. Any previously selected beans remain selected.

 o selectWithFilter
 public void selectWithFilter(ManagedBeanFilter filter)
Selects all managed beans that meet the criteria imposed by the specified ManagedBeanFilter object. Any previously selected beans remain selected.

Parameters:
filter - The object providing the filter method used to determine the selection.
 o select
 public void select(Vector newSelection)
Selects the specified managed beans. Any previously selected beans remain selected. Objects that are not in the model cannot be selected and are ignored. An ItemEvent is fired if any beans are added to the selection that were not previously in the selection. The fired ItemEvent contains the Vector of newly selected beans. If the specified newSelection is null, a NullPointerException is thrown.

Parameters:
newSelection - The managed beans to be added to the selection.
 o select
 public void select(Object newSelection)
Selects the specified managed bean. Any previously selected beans remain selected.

Parameters:
newSelection - The managed bean to be added to the selection.
 o deselect
 public void deselect(Object newSelection)
De-selects the specified managed bean.

Parameters:
newSelection - The managed bean to be removed from the selection.
 o deselect
 public void deselect(Vector newSelection)
De-selects the specified managed beans. An ItemEvent is fired only if at least one of the specified managed beans was previously selected. The fired ItemEvent contains the Vector of beans that were actually deselected.

Parameters:
newSelection - The managed beans to be removed from the selection.
 o selectAll
 public void selectAll()
Selects all managed beans in the BeanBagModel object.

 o selectNone
 public void selectNone()
De-selects all managed beans.

 o isSelected
 public boolean isSelected(ManagedBean mbean)
Queries whether the specified managed bean is currently selected.

Parameters:
mbean - The managed bean for which selection information is desired.
Returns:
true if the specified managed bean is currently selected; false otherwise.
 o doUnbindFromRepository
 public void doUnbindFromRepository()
Removes any association with a repository from the currently-selected managed beans.

 o doCopyToRepository
 public void doCopyToRepository(Class repoClass,
                                String repoName)
Copies the currently-selected managed beans to the specified repository. The managed beans are copied by reference, rather than cloned. If the specified repository cannot be opened, an error is logged but no exception is thrown. If no beans are currently selected, this method does nothing. After copying the selected beans to the specified repository, a ModelEvent is fired to signify a model change, containing a Vector of all copied beans.

Parameters:
repoClass - This parameter is unused and should be null.
repoName - The name of the repository (typically the location of a directory or JAR file in the file system).
 o doDeleteFromRepository
 public void doDeleteFromRepository(Class repoClass,
                                    String repoName)
Deletes the currently-selected managed beans from the specified repository. If the specified repository cannot be opened, an error is logged but no exception is thrown. If no beans are currently selected, this method does nothing. After deleting the selected beans from the specified repository, a ModelEvent is fired to signify a model change, containing a Vector of the beans deleted from the specified repository.

Parameters:
repoClass - This parameter is unused and should be null.
repoName - The name of the repository (typically the location of a directory or JAR file in the file system).
 o doRemove
 public void doRemove()
Removes all the currently-selected managed beans from the model. A ModelEvent is fired if at least one bean is removed. The fired ModelEvent contains a Vector of all removed beans.

 o doAdd
 public void doAdd(Vector newMbeans)
Adds the specified managed beans to the model. Beans that already exist in the model and objects that are not ManagedBean objects are ignored. If some new beans are added to the model, then a ModelEvent is fired, containing the Vector of all beans added to the model.

Parameters:
mbeans - The managed beans to be added to the model.
 o doGetSelected
 public Vector doGetSelected()
Returns the managed beans that are currently selected. The Vector is a clone that the caller can freely manipulate, but the ManagedBean objects contained in the Vector are not cloned.

Returns:
The current selection of managed beans.
 o doGetAll
 public Vector doGetAll()
Returns all the managed beans contained in the model. The Vector is a clone that the caller can freely manipulate, but the ManagedBean objects contained in the Vector are not cloned.

Returns:
All of the managed beans in the model.
 o loadFromRepository
 public void loadFromRepository(Class repoClass,
                                String repoName)
Adds to the model all the managed beans contained in the specified Repository. If the specified repository cannot be opened, then an error is logged but no exception is thrown.

Parameters:
repoClass - This parameter is unused and should be null.
repoName - The name of the repository (typically the location of of directory or JAR file in the file system).
 o loadDirOfJars
 public void loadDirOfJars(String dirOfJars) throws FileNotFoundException
Adds to the BeanBagModel all the beans in all the jars in the specified directory.

Parameters:
dirOfJars - The name of the directory containing the jars.
Throws: FileNotFoundException
Thrown when the specified directory does not exist or contains no jar files.
 o loadBeanClassInJar
 public void loadBeanClassInJar(String beanMoniker,
                                String jarFilename) throws IOException
Adds to the BeanBagModel the specified bean from the specified jar file.

Parameters:
beanMoniker - The moniker string of the bean to add to the model.
jarFilename - The name of the jar file containing the bean.
Throws: IOException
Thrown when the specified jarFilename is invalid or the specified bean is not found in the specified file.
 o loadBeanClass
 public void loadBeanClass(String beanMoniker,
                           String classFilename) throws IOException
Adds to the BeanBagModel the specified bean from the specified class.

Parameters:
beanMoniker - The moniker string of the bean to add to the model.
classFilename - The name of the bean's class file.
Throws: IOException
Thrown when the specified classFilename is invalid or the specified bean is not found in the specified file.
 o setRepositoryAccessMode
 public void setRepositoryAccessMode(int mode)
Sets the access mode to be used when repositories are loaded. The default setting is RepositoryModel.READ_ONLY. If the new mode differs from the previous mode and is valid, then a ModelEvent is fired with a null Vector. If the specified mode is not valid, no action is performed.

Parameters:
mode - The access mode. This value must be one of RepositoryModel.READ_ONLY, RepositoryModel.WRITE_ONLY, or RepositoryModel.READ_WRITE, and must equal the access mode of all repositories associated with all managed beans already contained in the model.
 o getRepositoryAccessMode
 public int getRepositoryAccessMode()
Gets the access mode used when repositories are loaded.

Returns:
The access mode.
 o equals
 public boolean equals(Object obj)
Tests for equality with the passed object. Two models are equal only if the repository-access mode, the Vector containing the managed beans, the Vector containing the currently-selected managed beans, and the listeners are all the same.

Cloned BeanBagModel instances are not equal to their source BeanBagModel instances. For example:

bbm.equals(bbm.clone()) 
 
is always false. Although the Vectors that are compared contain identical elements, the Vectors themselves are unique, and the listener Vectors typically will not be equal because cloning does not copy the listeners.

Returns:
true if the passed object is equivalent to the called object; false otherwise.
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Gets a hash code for an instance of this class.

Returns:
The hash value.
Overrides:
hashCode in class Object
 o clone
 public Object clone() throws CloneNotSupportedException
Clones the BeanBagModel.

The returned clone of the BeanBagModel instance is a shallow clone, not a deep clone. The cloned Vectors hold the same instances of ManagedBeans as the Vectors that are owned by the original object.

The Vectors containing the listeners to the model and selection are not cloned, but are empty. Therefore, these listener Vectors have no listeners in the cloned object.

Cloned BeanBagModel instances are not equal to their source BeanBagModel instances. For example:

(bbm.equals(bbm.clone())) ||
(bbm.hashCode == (((BeanBagModel)bbm.clone()).hashCode())
 
always is false. The Vectors that are compared contain identical elements, but the Vectors themselves are unique; and the listener Vectors typically will not have identical elements because the listener Vectors for the clone are empty.

Returns:
The shallow clone of the BeanBagModel instance.
Throws: CloneNotSupportedException
Thrown on error.
Overrides:
clone in class Object
 o addModelChangeListener
 public void addModelChangeListener(ModelChangeListener l)
Adds a model change listener to the list of listeners.

Parameters:
l - The listener to add.
See Also:
ModelChangeListener
 o removeModelChangeListener
 public void removeModelChangeListener(ModelChangeListener l)
Removes a model change listener from the list of listeners.

Parameters:
l - The listener to remove.
See Also:
ModelChangeListener
 o fireBeanBagModelChangeEvent
 protected void fireBeanBagModelChangeEvent(ModelEvent e,
                                            int listenerMethod)
Propagates a ModelEvent to registered model change listeners.

Parameters:
e - The event to propagate.
listenerMethod - The listener method to which the event is dispatched. This value must be one of BEANBAGMODEL_ADD, BEANBAGMODEL_REMOVE, or BEANBAGMODEL_CHANGE.
 o fireItemStateChanged
 protected void fireItemStateChanged(ItemEvent e)
Propagates an ItemEvent to registered ItemListener objects.

Parameters:
e - The event to propagate.
 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns the selected items, or null if no items are selected.

Returns:
The currently-selected objects.
 o addItemListener
 public void addItemListener(ItemListener l)
Add a listener to recieve item events when the state of an item changes.

Parameters:
l - The listener to receive events.
 o removeItemListener
 public void removeItemListener(ItemListener l)
Removes an item listener.

Parameters:
l - The listener to be removed.
 o add
 public void add(Object o) throws NullPointerException, ClassCastException
Ensures that this Collection contains the specified element. The specified object must be a ManagedBean object and must not be null.

Parameters:
o - The ManagedBean object whose presence in the bean bag model is to be ensured.
Throws: NullPointerException
Thrown when the specified object to be added is null.
Throws: ClassCastException
Thrown when the specified object is not a ManagedBean object.
 o size
 public int size()
Returns the number of elements in the bean bag model.

Returns:
The number of elements in the bean bag model.
 o isEmpty
 public boolean isEmpty()
Indicates whether the model contains no elements.

Returns:
true if the model is empty, false otherwise.
 o contains
 public boolean contains(Object o)
Indicates whether the model contains the specified element.

Parameters:
o - The element whose presence in the model is to be tested.
Returns:
true if and only if the model contains at least one element e such that e.equals(o); false otherwise.
 o toArray
 public Object[] toArray()
Returns an array containing all of the elements in the model. The returned array will be "safe" in that no references to it are maintained by the model. The caller is thus free to modify the returned array. This method acts as bridge between array-based and Collection-based APIs.

Returns:
An array containing all the elements in the model.
 o remove
 public boolean remove(Object o)
Removes a single instance of the specified element from the model, if it is present. More formally, removes an element e such that e.equals(o), if the model contains one or more such elements.

Parameters:
o - The object to be removed from the model, if present.
Returns:
true if the model contained the specified element, false otherwise.
 o addAll
 public void addAll(Vector v) throws NullPointerException, ClassCastException
Adds all of the elements in the specified collection to this collection, in the order they are returned by the specified collection's iterator. The elements in the input collection must be ManagedBean objects and must not be null. If any of the elements is invalid, then none of the elements is added and an exception is thrown.

Parameters:
v - The collection of elements to add to the model.
Throws: NullPointerException
Thrown when one of the elements in the input collection is null.
Throws: ClassCastException
Thrown when one of the elements in the input collection is not a ManagedBean object.
 o clear
 public void clear()
Removes all of the elements from the model. The model will be empty after this call returns.

 o elements
 public Enumeration elements()
Gets an enumeration of the elements in the collection. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Returns:
An enumeration of the components of this collection.

All Packages  Class Hierarchy  This Package  Previous  Next  Index