| org.apache.commons.events.observable.BoundCollection org.apache.commons.events.observable.BoundList
BoundList | public class BoundList extends BoundCollection implements List(Code) | | Decorates a List interface with a bound property called
"collection".
Each modifying method call made on this List is
handled as a change to the "collection" property. This
facility serves to notify subscribers of a change to the collection
but does not allow users the option of vetoing the change. To
gain the ability to veto the change, use a
ConstrainedList decorater.
Registered listeners must implement the
java.beans.PropertyChangeListener interface. Each change request causes a
CollectionChangeEvent to be fired after the request
has been executed. The
CollectionChangeEvent provides an
indication of the type of change, the element participating in the
change, and whether or not the List was actually affected by the
change request. As such, receiving a CollectionChangeEvent
is merely an indication that a change was attempted, not that the
List is actually different.
See Also: BoundCollection See Also: CollectionChangeEvent since: Commons Events 1.0 version: $Revision$ $Date$ author: Stephen Colebourne, Bryce Nordgren |
Inner Class :protected class BoundListIterator extends AbstractListIteratorDecorator | |
BoundList | protected BoundList(List source)(Code) | | Constructor that wraps (not copies.)
Parameters: source - the List to decorate, must not be null throws: IllegalArgumentException - if the collection is null |
add | public void add(int index, Object object)(Code) | |
Inserts an object at the specified index (optional operation).
This method is assumed
to succeed if no exceptions are thrown. It is important to note that
it is impossible to document all cases where an exception is
thrown, as this is totally determined by the implementation class
of the decorated List. See the documentation for the decorated
List for details.
This method will only fire a CollectionChangeEvent
if the operation succeeds. Therefore, calling this method will
always result in a CollectionChangeEvent or an
exception from the decorated list. An exception prevents the
CollectionChangeEvent from being fired.
Parameters: index - The index at which to insert the object. Parameters: object - The object to insert in the list. throws: IndexOutOfBoundsException - if the index does not represent a position in the List. throws: UnsupportedOperationException - if the decorated list doesnot support this optional operation. |
addAll | public boolean addAll(int index, Collection coll)(Code) | |
Inserts all of the elements in the specified collection into this
list at the specified position (optional operation).
This method will only fire a CollectionChangeEvent
if the decorated list completes the call normally. Therefore,
calling this method will
always result in a CollectionChangeEvent or an
exception from the decorated list. An exception prevents the
CollectionChangeEvent from being fired. Unlike the
BoundList.add(int index,Object object) method, however, an event
may be fired when the collection has not changed. It is therefore
important to check the
CollectionChangeEvent.isChanged()
flag.
Parameters: index - The index at which to insert the collection. Parameters: coll - The collection of objects to insert in the list. throws: IndexOutOfBoundsException - if the index does not represent a position in the List. throws: UnsupportedOperationException - if the decorated list doesnot support this optional operation. |
remove | public Object remove(int index)(Code) | |
Removes the element at the specified position in this list
(optional operation). Shifts any subsequent elements to the left
(subtracts one from their indices). Returns the element that was
removed from the list.
This method will only fire a CollectionChangeEvent
if the operation succeeds. Therefore, calling this method will
always result in a CollectionChangeEvent or an
exception from the decorated list. An exception prevents the
CollectionChangeEvent from being fired.
Parameters: index - The index of the element to remove. The object which was removed from the list. throws: IndexOutOfBoundsException - if the index does not represent a position in the List. throws: UnsupportedOperationException - if the decorated list doesnot support this optional operation. |
set | public Object set(int index, Object object)(Code) | |
Replaces the element at the specified position in this list with
the specified element (optional operation).
This method will only fire a CollectionChangeEvent
if the operation succeeds. Therefore, calling this method will
always result in a CollectionChangeEvent or an
exception from the decorated list. An exception prevents the
CollectionChangeEvent from being fired.
Parameters: index - The index of the element to change. Parameters: object - The new value to place at location index . The object formerly at location index . throws: IndexOutOfBoundsException - if the index does not represent a position in the List. throws: UnsupportedOperationException - if the decorated list doesnot support this optional operation. |
subList | public List subList(int fromIndex, int toIndex)(Code) | |
Returns a view of the portion of this list between fromIndex,
inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal,
the returned list is empty.) The returned list is backed by this list,
so changes in the returned list are reflected in this list, and
vice-versa. The returned list supports all of the optional list
operations supported by this list.
Because changes in the subList are reflected in the list, this
decorator implementation ensures that listeners registered with this
list are notified of changes made through the sublist interface.
Changes caused by the sub list view will create events which have the
sub list as the source property. This is likely to
be important as the view causing the change will impact the
indicies of any indexed events. The indices are consistent with the
List view specified as the source object.
Listeners may be added or removed
from the main list before or after the sub list is created. Events
will be fired to listeners registered at the time of the event, not
at the time the sublist was created. Listeners may also be added
separately to the sublist, if desired.
Parameters: fromIndex - first index included in the sublist view Parameters: toIndex - first index not included in the sublist view. The sublist view backed by this list. |
|
|