You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/09/28 23:54:36 UTC

cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections SetUtils.java BagUtils.java

scolebourne    2003/09/28 14:54:36

  Modified:    collections/src/java/org/apache/commons/collections
                        SetUtils.java BagUtils.java
  Log:
  Add ObservableSortedBag/Set
  
  Revision  Changes    Path
  1.18      +23 -2     jakarta-commons/collections/src/java/org/apache/commons/collections/SetUtils.java
  
  Index: SetUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/SetUtils.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SetUtils.java	21 Sep 2003 16:26:08 -0000	1.17
  +++ SetUtils.java	28 Sep 2003 21:54:35 -0000	1.18
  @@ -77,6 +77,7 @@
   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
  @@ -381,6 +382,26 @@
        */
       public static SortedSet transformedSortedSet(SortedSet set, Transformer transformer) {
           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);
       }
       
   }
  
  
  
  1.14      +23 -2     jakarta-commons/collections/src/java/org/apache/commons/collections/BagUtils.java
  
  Index: BagUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/BagUtils.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BagUtils.java	21 Sep 2003 16:26:08 -0000	1.13
  +++ BagUtils.java	28 Sep 2003 21:54:35 -0000	1.14
  @@ -69,6 +69,7 @@
   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
  @@ -297,6 +298,26 @@
        */
       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);
       }
           
   }