Add ObservableSortedBag/Set

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131201 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-09-28 21:54:35 +00:00
parent 52f05aba78
commit 1c4942acca
2 changed files with 46 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.13 2003/09/21 16:26:08 scolebourne Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.14 2003/09/28 21:54:35 scolebourne Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@ -69,13 +69,14 @@ import org.apache.commons.collections.decorators.UnmodifiableBag;
import org.apache.commons.collections.decorators.UnmodifiableSortedBag;
import org.apache.commons.collections.observed.ModificationListener;
import org.apache.commons.collections.observed.ObservableBag;
import org.apache.commons.collections.observed.ObservableSortedBag;
/**
* Provides utility methods and decorators for
* {@link Bag} and {@link SortedBag} instances.
*
* @since Commons Collections 2.1
* @version $Revision: 1.13 $ $Date: 2003/09/21 16:26:08 $
* @version $Revision: 1.14 $ $Date: 2003/09/28 21:54:35 $
*
* @author Paul Jack
* @author Stephen Colebourne
@ -298,5 +299,25 @@ public class BagUtils {
public static SortedBag transformedSortedBag(SortedBag bag, Transformer transformer) {
return TransformedSortedBag.decorate(bag, transformer);
}
/**
* Returns an observable sorted bag where changes are notified to listeners.
* <p>
* This method creates an observable sorted bag and attaches the specified listener.
* If more than one listener or other complex setup is required then the
* ObservableSortedBag class should be accessed directly.
*
* @param bag the bag to decorate, must not be null
* @param listener bag listener, must not be null
* @return the observed bag
* @throws IllegalArgumentException if the bag or listener is null
* @throws IllegalArgumentException if there is no valid handler for the listener
*/
public static ObservableSortedBag observableSortedBag(SortedBag bag, ModificationListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Listener must not be null");
}
return ObservableSortedBag.decorate(bag, listener);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/SetUtils.java,v 1.17 2003/09/21 16:26:08 scolebourne Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/SetUtils.java,v 1.18 2003/09/28 21:54:35 scolebourne Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@ -77,13 +77,14 @@ import org.apache.commons.collections.decorators.UnmodifiableSet;
import org.apache.commons.collections.decorators.UnmodifiableSortedSet;
import org.apache.commons.collections.observed.ModificationListener;
import org.apache.commons.collections.observed.ObservableSet;
import org.apache.commons.collections.observed.ObservableSortedSet;
/**
* Provides utility methods and decorators for
* {@link Set} and {@link SortedSet} instances.
*
* @since Commons Collections 2.1
* @version $Revision: 1.17 $ $Date: 2003/09/21 16:26:08 $
* @version $Revision: 1.18 $ $Date: 2003/09/28 21:54:35 $
*
* @author Paul Jack
* @author Stephen Colebourne
@ -383,4 +384,24 @@ public class SetUtils {
return TransformedSortedSet.decorate(set, transformer);
}
/**
* Returns an observable sorted set where changes are notified to listeners.
* <p>
* This method creates an observable set and attaches the specified listener.
* If more than one listener or other complex setup is required then the
* ObservableSortedSet class should be accessed directly.
*
* @param set the set to decorate, must not be null
* @param listener set listener, must not be null
* @return the observed set
* @throws IllegalArgumentException if the set or listener is null
* @throws IllegalArgumentException if there is no valid handler for the listener
*/
public static ObservableSortedSet observableSortedSet(SortedSet set, ModificationListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Listener must not be null");
}
return ObservableSortedSet.decorate(set, listener);
}
}