org.apache.commons.events.observable
Class ObservableSortedBag
java.lang.Object
org.apache.commons.collections.collection.AbstractCollectionDecorator
org.apache.commons.events.observable.ObservableCollection
org.apache.commons.events.observable.ObservableBag
org.apache.commons.events.observable.ObservableSortedBag
- All Implemented Interfaces:
- Iterable, Collection, org.apache.commons.collections.Bag, org.apache.commons.collections.SortedBag
public class ObservableSortedBag
- extends ObservableBag
- implements org.apache.commons.collections.SortedBag
Decorates a SortedBag
implementation to observe modifications.
Each modifying method call made on this SortedBag
is forwarded to a
ModificationHandler
.
The handler manages the event, notifying listeners and optionally vetoing changes.
The default handler is
StandardModificationHandler
.
See this class for details of configuration available.
- Since:
- Commons Events 1.0
- Version:
- $Revision: 155443 $ $Date: 2005-02-26 13:19:51 +0000 (Sat, 26 Feb 2005) $
- Author:
- Stephen Colebourne
Fields inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator |
collection |
Constructor Summary |
protected |
ObservableSortedBag(org.apache.commons.collections.SortedBag bag,
Object listener)
Constructor that wraps (not copies) and takes a handler. |
Methods inherited from class org.apache.commons.events.observable.ObservableCollection |
addAll, clear, createHandler, decorate, decorate, getHandler, iterator, registerFactory, remove, removeAll, retainAll |
Methods inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator |
contains, containsAll, equals, getCollection, hashCode, isEmpty, size, toArray, toArray, toString |
Methods inherited from interface org.apache.commons.collections.Bag |
add, add, containsAll, getCount, iterator, remove, remove, removeAll, retainAll, size, uniqueSet |
ObservableSortedBag
protected ObservableSortedBag(org.apache.commons.collections.SortedBag bag,
Object listener)
- Constructor that wraps (not copies) and takes a handler.
The handler implementation is determined by the listener parameter via
the registered factories. The listener may be a manually configured
ModificationHandler
instance.
- Parameters:
bag
- the bag to decorate, must not be nulllistener
- the listener, may be null
- Throws:
IllegalArgumentException
- if the bag is null
decorate
public static ObservableSortedBag decorate(org.apache.commons.collections.SortedBag bag)
- Factory method to create an observable bag.
A StandardModificationHandler
will be created.
This can be accessed by ObservableCollection.getHandler()
to add listeners.
- Parameters:
bag
- the bag to decorate, must not be null
- Returns:
- the observed bag
- Throws:
IllegalArgumentException
- if the collection is null
decorate
public static ObservableSortedBag decorate(org.apache.commons.collections.SortedBag bag,
Object listener)
- Factory method to create an observable bag using a listener or a handler.
A lot of functionality is available through this method.
If you don't need the extra functionality, simply implement the
StandardModificationListener
interface and pass it in as the second parameter.
Internally, an ObservableSortedBag
relies on a ModificationHandler
.
The handler receives all the events and processes them, typically by
calling listeners. Different handler implementations can be plugged in
to provide a flexible event system.
The handler implementation is determined by the listener parameter via
the registered factories. The listener may be a manually configured
ModificationHandler
instance.
The listener is defined as an Object for maximum flexibility.
It does not have to be a listener in the classic JavaBean sense.
It is entirely up to the factory and handler as to how the parameter
is interpretted. An IllegalArgumentException is thrown if no suitable
handler can be found for this listener.
A null
listener will create a
StandardModificationHandler
.
- Parameters:
bag
- the bag to decorate, must not be nulllistener
- bag listener, may be null
- Returns:
- the observed bag
- Throws:
IllegalArgumentException
- if the bag is null
IllegalArgumentException
- if there is no valid handler for the listener
comparator
public Comparator comparator()
- Specified by:
comparator
in interface org.apache.commons.collections.SortedBag
first
public Object first()
- Specified by:
first
in interface org.apache.commons.collections.SortedBag
last
public Object last()
- Specified by:
last
in interface org.apache.commons.collections.SortedBag
Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.