org.apache.commons.events.observable
Class ObservableSortedSet

java.lang.Object
  extended by org.apache.commons.collections.collection.AbstractCollectionDecorator
      extended by org.apache.commons.events.observable.ObservableCollection
          extended by org.apache.commons.events.observable.ObservableSet
              extended by org.apache.commons.events.observable.ObservableSortedSet
All Implemented Interfaces:
Iterable, Collection, Set, SortedSet

public class ObservableSortedSet
extends ObservableSet
implements SortedSet

Decorates a SortedSet implementation to observe modifications.

Each modifying method call made on this SortedSet 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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.events.observable.ObservableCollection
ObservableCollection.ObservableIterator
 
Field Summary
 
Fields inherited from class org.apache.commons.events.observable.ObservableCollection
handler
 
Fields inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator
collection
 
Constructor Summary
protected ObservableSortedSet(SortedSet set, Object listener)
          Constructor that wraps (not copies) and takes a handler.
 
Method Summary
 Comparator comparator()
           
static ObservableSortedSet decorate(SortedSet set)
          Factory method to create an observable set.
static ObservableSortedSet decorate(SortedSet set, Object listener)
          Factory method to create an observable set using a listener or a handler.
 Object first()
           
 SortedSet headSet(Object toElement)
           
 Object last()
           
 SortedSet subSet(Object fromElement, Object toElement)
           
 SortedSet tailSet(Object fromElement)
           
 
Methods inherited from class org.apache.commons.events.observable.ObservableSet
decorate, decorate
 
Methods inherited from class org.apache.commons.events.observable.ObservableCollection
add, 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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

ObservableSortedSet

protected ObservableSortedSet(SortedSet set,
                              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:
set - the set to decorate, must not be null
listener - the listener, may be null
Throws:
IllegalArgumentException - if the set is null
Method Detail

decorate

public static ObservableSortedSet decorate(SortedSet set)
Factory method to create an observable set.

A StandardModificationHandler will be created. This can be accessed by ObservableCollection.getHandler() to add listeners.

Parameters:
set - the set to decorate, must not be null
Returns:
the observed Set
Throws:
IllegalArgumentException - if the collection is null

decorate

public static ObservableSortedSet decorate(SortedSet set,
                                           Object listener)
Factory method to create an observable set 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 ObservableSortedSet 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:
set - the set to decorate, must not be null
listener - set listener, may be null
Returns:
the observed set
Throws:
IllegalArgumentException - if the set is null
IllegalArgumentException - if there is no valid handler for the listener

comparator

public Comparator comparator()
Specified by:
comparator in interface SortedSet

first

public Object first()
Specified by:
first in interface SortedSet

last

public Object last()
Specified by:
last in interface SortedSet

subSet

public SortedSet subSet(Object fromElement,
                        Object toElement)
Specified by:
subSet in interface SortedSet

headSet

public SortedSet headSet(Object toElement)
Specified by:
headSet in interface SortedSet

tailSet

public SortedSet tailSet(Object fromElement)
Specified by:
tailSet in interface SortedSet


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.