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
-
BEANBAGMODEL_ADD
- Indicates that a bean was added to the BeanBagModel instance.
-
BEANBAGMODEL_CHANGE
- Indicates that a bean was modified in the BeanBagModel instance.
-
BEANBAGMODEL_REMOVE
- Indicates that a bean was removed from the BeanBagModel instance.
-
BeanBagModel()
- Constructs a BeanBagModel that is initially empty.
-
BeanBagModel(BeanBagModel)
- Constructs a BeanBagModel instance from an existing BeanBagModel
instance.
-
BeanBagModel(Class, String)
- Constructs a BeanBagModel instance containing the managed beans
from the specified Repository.
-
BeanBagModel(Vector)
- Constructs a BeanBagModel instance containing the specified beans.
-
add(Object)
- Ensures that this Collection contains the specified element.
-
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.
-
addItemListener(ItemListener)
- Add a listener to recieve item events when the state of an item changes.
-
addModelChangeListener(ModelChangeListener)
- Adds a model change listener to the list of listeners.
-
clear()
- Removes all of the elements from the model.
-
clone()
- Clones the BeanBagModel.
-
contains(Object)
- Indicates whether the model contains the specified element.
-
deselect(Object)
- De-selects the specified managed bean.
-
deselect(Vector)
- De-selects the specified managed beans.
-
doAdd(Vector)
- Adds the specified managed beans to the model.
-
doCopyToRepository(Class, String)
- Copies the currently-selected managed beans to the specified repository.
-
doDeleteFromRepository(Class, String)
- Deletes the currently-selected managed beans from
the specified repository.
-
doGetAll()
- Returns all the managed beans contained in the model.
-
doGetSelected()
- Returns the managed beans that are currently selected.
-
doRemove()
- Removes all the currently-selected managed beans from the model.
-
doUnbindFromRepository()
- Removes any association with a repository from the
currently-selected managed beans.
-
elements()
- Gets an enumeration of the elements in the collection.
-
equals(Object)
- Tests for equality with the passed object.
-
fireBeanBagModelChangeEvent(ModelEvent, int)
- Propagates a ModelEvent to registered model
change listeners.
-
fireItemStateChanged(ItemEvent)
- Propagates an ItemEvent to registered ItemListener objects.
-
getRepositoryAccessMode()
- Gets the access mode used when repositories are loaded.
-
getSelectedObjects()
- Returns the selected items, or null if no items are selected.
-
hashCode()
- Gets a hash code for an instance of this class.
-
isEmpty()
- Indicates whether the model contains no elements.
-
isSelected(ManagedBean)
- Queries whether the specified managed bean is currently selected.
-
loadBeanClass(String, String)
- Adds to the BeanBagModel the specified bean from the specified class.
-
loadBeanClassInJar(String, String)
- Adds to the BeanBagModel the specified bean from the specified jar file.
-
loadDirOfJars(String)
- Adds to the BeanBagModel all the beans in all the
jars in the specified directory.
-
loadFromRepository(Class, String)
- Adds to the model all the managed beans contained
in the specified Repository.
-
remove(Object)
- Removes a single instance of the specified element from the model,
if it is present.
-
removeItemListener(ItemListener)
- Removes an item listener.
-
removeModelChangeListener(ModelChangeListener)
- Removes a model change listener from the list of listeners.
-
select(Object)
- Selects the specified managed bean.
-
select(Vector)
- Selects the specified managed beans.
-
selectAll()
- Selects all managed beans in the BeanBagModel object.
-
selectAllFromRepository(Class, String)
- Selects all managed beans that are associated with
the specified repository.
-
selectAllFromRepositoryClass(Class)
- Selects all managed beans that are associated with any repository
of the specified class.
-
selectAllFromRepositoryName(String)
- Selects all managed beans that are associated with the
specified repository.
-
selectBound()
- Selects all beans that are associated with any repository.
-
selectNone()
- De-selects all managed beans.
-
selectUnbound()
- Selects all managed beans that are not associated with any repository.
-
selectWithFilter(ManagedBeanFilter)
- Selects all managed beans that meet the criteria
imposed by the specified ManagedBeanFilter object.
-
setRepositoryAccessMode(int)
- Sets the access mode to be used when repositories are loaded.
-
size()
- Returns the number of elements in the bean bag model.
-
toArray()
-
Returns an array containing all of the elements in the model.
BEANBAGMODEL_ADD
protected static final int BEANBAGMODEL_ADD
- Indicates that a bean was added to the BeanBagModel instance.
BEANBAGMODEL_REMOVE
protected static final int BEANBAGMODEL_REMOVE
- Indicates that a bean was removed from the BeanBagModel instance.
BEANBAGMODEL_CHANGE
protected static final int BEANBAGMODEL_CHANGE
- Indicates that a bean was modified in the BeanBagModel instance.
BeanBagModel
public BeanBagModel()
- Constructs a BeanBagModel that is initially empty.
The repository access mode is set to read-only by default.
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.
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).
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.
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).
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).
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.
selectUnbound
public void selectUnbound()
- Selects all managed beans that are not associated with any repository.
Any previously selected beans remain selected.
selectBound
public void selectBound()
- Selects all beans that are associated with any repository.
Any previously selected beans remain selected.
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.
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.
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.
deselect
public void deselect(Object newSelection)
- De-selects the specified managed bean.
- Parameters:
- newSelection - The managed bean to be removed from the selection.
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.
selectAll
public void selectAll()
- Selects all managed beans in the BeanBagModel object.
selectNone
public void selectNone()
- De-selects all managed beans.
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.
doUnbindFromRepository
public void doUnbindFromRepository()
- Removes any association with a repository from the
currently-selected managed beans.
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).
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).
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.
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.
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.
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.
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).
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.
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.
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.
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.
getRepositoryAccessMode
public int getRepositoryAccessMode()
- Gets the access mode used when repositories are loaded.
- Returns:
- The access mode.
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
hashCode
public int hashCode()
- Gets a hash code for an instance of this class.
- Returns:
- The hash value.
- Overrides:
- hashCode in class Object
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
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
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
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.
fireItemStateChanged
protected void fireItemStateChanged(ItemEvent e)
- Propagates an ItemEvent to registered ItemListener objects.
- Parameters:
- e - The event to propagate.
getSelectedObjects
public Object[] getSelectedObjects()
- Returns the selected items, or null if no items are selected.
- Returns:
- The currently-selected objects.
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.
removeItemListener
public void removeItemListener(ItemListener l)
- Removes an item listener.
- Parameters:
- l - The listener to be removed.
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.
size
public int size()
- Returns the number of elements in the bean bag model.
- Returns:
- The number of elements in the bean bag model.
isEmpty
public boolean isEmpty()
- Indicates whether the model contains no elements.
- Returns:
- true if the model is empty, false otherwise.
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.
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.
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.
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.
clear
public void clear()
- Removes all of the elements from the model.
The model will be empty after this call returns.
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