commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard StandardModificationHandler.java StandardPreModificationEvent.java StandardPostModificationEvent.java package.html StandardModificationEvent.java
Date Sun, 21 Sep 2003 16:00:29 GMT
scolebourne    2003/09/21 09:00:29

  Modified:    collections/src/java/org/apache/commons/collections/observed
                        ModificationEvent.java package.html
                        ModificationHandler.java
                        ModificationHandlerFactory.java
               collections/src/java/org/apache/commons/collections/observed/standard
                        StandardModificationHandler.java
                        StandardPreModificationEvent.java
                        StandardPostModificationEvent.java package.html
                        StandardModificationEvent.java
  Added:       collections/src/java/org/apache/commons/collections/observed
                        ObservableBuffer.java ObservableList.java
                        ObservableCollection.java ObservableSet.java
                        ObservableBag.java
  Removed:     collections/src/java/org/apache/commons/collections/observed
                        ObservedList.java ObservedBuffer.java
                        ObservedSet.java ObservedCollection.java
                        ObservedBag.java
  Log:
  Rename Observed to Observable
  
  Revision  Changes    Path
  1.3       +8 -8      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ModificationEvent.java
  
  Index: ModificationEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ModificationEvent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ModificationEvent.java	7 Sep 2003 10:33:32 -0000	1.2
  +++ ModificationEvent.java	21 Sep 2003 16:00:28 -0000	1.3
  @@ -73,7 +73,7 @@
   public class ModificationEvent extends EventObject {
   
       /** The source collection */
  -    protected final ObservedCollection collection;
  +    protected final ObservableCollection collection;
       /** The handler */
       protected final ModificationHandler handler;
       /** The event code */
  @@ -89,7 +89,7 @@
        * @param type  the event type
        */
       public ModificationEvent(
  -        final ObservedCollection obsCollection,
  +        final ObservableCollection obsCollection,
           final ModificationHandler handler,
           final int type) {
   
  @@ -105,7 +105,7 @@
        * Gets the collection the event is reporting on.
        * <p>
        * Using this collection will bypass any decorators that have been added
  -     * to the <code>ObservedCollection</code>. For example, if a synchronized
  +     * to the <code>ObservableCollection</code>. For example, if a synchronized
        * decorator was added it will not be called by changes to this collection.
        * <p>
        * For the synchronization case, you are normally OK however. If you
  @@ -115,12 +115,12 @@
        * 
        * @return the collection
        */
  -    public ObservedCollection getObservedCollection() {
  +    public ObservableCollection getObservedCollection() {
           return collection;
       }
   
       /**
  -     * Gets the base collection underlying the observed collection.
  +     * Gets the base collection underlying the observable collection.
        * <p>
        * Using this collection will bypass the event sending mechanism.
        * It will also bypass any other decorators, such as synchronization.
  @@ -161,7 +161,7 @@
        */
       public String toString() {
           StringBuffer buf = new StringBuffer(64);
  -        buf.append("ObservedEvent[type=");
  +        buf.append("ModificationEvent[type=");
           buf.append(ModificationEventType.toString(type));
           buf.append(']');
           return buf.toString();
  
  
  
  1.2       +3 -3      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/package.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- package.html	3 Sep 2003 23:54:26 -0000	1.1
  +++ package.html	21 Sep 2003 16:00:28 -0000	1.2
  @@ -5,10 +5,10 @@
   is supplied, but alternatives can be added, see ModificationHandler.
   <p>
   Each decorator can be constructed using a static <code>decorate()</code> method on
  -the ObservedXxx class. They can also be constructed from the <code>XxxUtils</code>
  +the ObservableXxx class. They can also be constructed from the <code>XxxUtils</code>
   class (where Xxx is the collection type).
   <p>
  -<code>List observedList = ObservedList.decorate(new ArrayList(), listener);</code>
  +<code>List observableList = ObservableList.decorate(new ArrayList(), listener);</code>
   <br />OR<br />
  -<code>List observedList = ListUtils.observedList(new ArrayList(), listener);</code>
  +<code>List observableList = ListUtils.observableList(new ArrayList(), listener);</code>
   </BODY>
  
  
  
  1.6       +9 -9      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ModificationHandler.java
  
  Index: ModificationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ModificationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ModificationHandler.java	7 Sep 2003 16:50:59 -0000	1.5
  +++ ModificationHandler.java	21 Sep 2003 16:00:28 -0000	1.6
  @@ -86,7 +86,7 @@
       static final ModificationHandlerFactory FACTORY = new Factory();
       
       /** The collection being observed */
  -    private ObservedCollection obsCollection = null;
  +    private ObservableCollection obsCollection = null;
       /** The underlying base collection being decorated */
       private Collection baseCollection = null;
       /** The root handler */
  @@ -129,7 +129,7 @@
        * @throws IllegalArgumentException if the collection is null
        * @throws IllegalStateException if init has already been called
        */
  -    void init(final ObservedCollection coll, Collection baseColl) {
  +    void init(final ObservableCollection coll, Collection baseColl) {
           if (coll == null) {
               throw new IllegalArgumentException("Collection must not be null");
           }
  @@ -150,7 +150,7 @@
        * 
        * @return the observed collection
        */
  -    public ObservedCollection getObservedCollection() {
  +    public ObservableCollection getObservedCollection() {
           return obsCollection;
       }
       
  @@ -296,7 +296,7 @@
        */
       protected boolean preEvent(
               int type, int index, Object object, int repeat,
  -            Object previous, ObservedCollection range, int rangeOffset) {
  +            Object previous, ObservableCollection range, int rangeOffset) {
           return true;
       }
   
  @@ -316,7 +316,7 @@
        */
       protected void postEvent(
               boolean modified, int type, int index, Object object, int repeat,
  -            Object previous, ObservedCollection range, int rangeOffset) {
  +            Object previous, ObservableCollection range, int rangeOffset) {
       }
   
       // Event handling
  @@ -773,7 +773,7 @@
            */
           protected boolean preEvent(
                   int type, int index, Object object, int repeat,
  -                Object previous, ObservedCollection ignoredRange, int ignoredOffset) {
  +                Object previous, ObservableCollection ignoredRange, int ignoredOffset) {
   
               return getRootHandler().preEvent(
                   type, index, object, repeat,
  @@ -787,7 +787,7 @@
            */
           protected void postEvent(
                   boolean modified, int type, int index, Object object, int repeat,
  -                Object previous, ObservedCollection ignoredRange, int ignoredOffset) {
  +                Object previous, ObservableCollection ignoredRange, int ignoredOffset) {
   
               getRootHandler().postEvent(
                   modified, type, index, object, repeat,
  
  
  
  1.2       +3 -4      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ModificationHandlerFactory.java
  
  Index: ModificationHandlerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ModificationHandlerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ModificationHandlerFactory.java	3 Sep 2003 23:54:26 -0000	1.1
  +++ ModificationHandlerFactory.java	21 Sep 2003 16:00:28 -0000	1.2
  @@ -59,7 +59,6 @@
   
   import java.util.Collection;
   
  -
   /**
    * Defines a factory for creating ModificationHandler instances.
    * <p>
  @@ -68,7 +67,7 @@
    * fully thread-safe. There are two steps:
    * <ol>
    * <li>A factory must be created that is an implementation of this class
  - * <li>One of the <code>registerFactory</code> methods must be called on ObservedCollection
  + * <li>One of the <code>registerFactory</code> methods must be called on ObservableCollection
    * </ol>
    *
    * @since Commons Collections 3.0
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableBuffer.java
  
  Index: ObservableBuffer.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableBuffer.java,v 1.1 2003/09/21 16:00:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.observed;
  
  import org.apache.commons.collections.Buffer;
  
  /**
   * Decorates a <code>Buffer</code> implementation to observe modifications.
   * <p>
   * Each modifying method call made on this <code>Buffer</code> is forwarded to a
   * {@link ModificationHandler}.
   * The handler manages the event, notifying listeners and optionally vetoing changes.
   * The default handler is {@link StandardModificationHandler}.
   * See this class for details of configuration available.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/09/21 16:00:28 $
   * 
   * @author Stephen Colebourne
   */
  public class ObservableBuffer extends ObservableCollection implements Buffer {
      
      // Factories
      //-----------------------------------------------------------------------
      /**
       * Factory method to create an observable buffer.
       * <p>
       * A {@link StandardModificationHandler} will be created.
       * This can be accessed by {@link #getHandler()} to add listeners.
       *
       * @param buffer  the buffer to decorate, must not be null
       * @return the observed Buffer
       * @throws IllegalArgumentException if the buffer is null
       */
      public static ObservableBuffer decorate(final Buffer buffer) {
          return new ObservableBuffer(buffer, null);
      }
  
      /**
       * Factory method to create an observable buffer using a listener or a handler.
       * <p>
       * A lot of functionality is available through this method.
       * If you don't need the extra functionality, simply implement the
       * {@link org.apache.commons.collections.observed.standard.StandardModificationListener}
       * interface and pass it in as the second parameter.
       * <p>
       * Internally, an <code>ObservableBuffer</code> relies on a {@link 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.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * <p>
       * 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.
       * <p>
       * A <code>null</code> listener will create a {@link StandardModificationHandler}.
       *
       * @param buffer  the buffer to decorate, must not be null
       * @param listener  buffer listener, may be null
       * @return the observed buffer
       * @throws IllegalArgumentException if the buffer is null
       * @throws IllegalArgumentException if there is no valid handler for the listener
       */
      public static ObservableBuffer decorate(
              final Buffer buffer,
              final Object listener) {
          
          if (buffer == null) {
              throw new IllegalArgumentException("Buffer must not be null");
          }
          return new ObservableBuffer(buffer, listener);
      }
  
      // Constructors
      //-----------------------------------------------------------------------
      /**
       * Constructor that wraps (not copies).
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * 
       * @param buffer  the buffer to decorate, must not be null
       * @param listener  the listener, may be null
       * @throws IllegalArgumentException if the buffer is null
       */
      protected ObservableBuffer(
              final Buffer buffer,
              final Object listener) {
          super(buffer, listener);
      }
      
      /**
       * Typecast the collection to a Buffer.
       * 
       * @return the wrapped collection as a Buffer
       */
      private Buffer getBuffer() {
          return (Buffer) getCollection();
      }
  
      // Buffer API
      //-----------------------------------------------------------------------
      public Object get() {
          return getBuffer().get();
      }
  
      //-----------------------------------------------------------------------
      public Object remove() {
          Object result = null;
          if (handler.preRemoveNext()) {
              result = getBuffer().remove();
              handler.postRemoveNext(result);
          }
          return result;
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableList.java
  
  Index: ObservableList.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableList.java,v 1.1 2003/09/21 16:00:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.observed;
  
  import java.util.Collection;
  import java.util.List;
  import java.util.ListIterator;
  
  import org.apache.commons.collections.decorators.AbstractListIteratorDecorator;
  
  /**
   * Decorates a <code>List</code> implementation to observe modifications.
   * <p>
   * Each modifying method call made on this <code>List</code> is forwarded to a
   * {@link ModificationHandler}.
   * The handler manages the event, notifying listeners and optionally vetoing changes.
   * The default handler is {@link StandardModificationHandler}.
   * See this class for details of configuration available.
   * <p>
   * All indices on events returned by <code>subList</code> are relative to the
   * base <code>List</code>.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/09/21 16:00:28 $
   * 
   * @author Stephen Colebourne
   */
  public class ObservableList extends ObservableCollection implements List {
  
      // Factories
      //-----------------------------------------------------------------------
      /**
       * Factory method to create an observable list.
       * <p>
       * A {@link StandardModificationHandler} will be created.
       * This can be accessed by {@link #getHandler()} to add listeners.
       *
       * @param list  the list to decorate, must not be null
       * @return the observed List
       * @throws IllegalArgumentException if the list is null
       */
      public static ObservableList decorate(final List list) {
          return new ObservableList(list, null);
      }
  
      /**
       * Factory method to create an observable list using a listener or a handler.
       * <p>
       * A lot of functionality is available through this method.
       * If you don't need the extra functionality, simply implement the
       * {@link org.apache.commons.collections.observed.standard.StandardModificationListener}
       * interface and pass it in as the second parameter.
       * <p>
       * Internally, an <code>ObservableList</code> relies on a {@link 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.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * <p>
       * 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.
       * <p>
       * A <code>null</code> listener will create a {@link StandardModificationHandler}.
       *
       * @param list  the list to decorate, must not be null
       * @param listener  list listener, may be null
       * @return the observed list
       * @throws IllegalArgumentException if the list is null
       * @throws IllegalArgumentException if there is no valid handler for the listener
       */
      public static ObservableList decorate(
              final List list,
              final Object listener) {
          
          if (list == null) {
              throw new IllegalArgumentException("List must not be null");
          }
          return new ObservableList(list, listener);
      }
  
      // Constructors
      //-----------------------------------------------------------------------
      /**
       * Constructor that wraps (not copies) and takes a handler.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * 
       * @param list  the list to decorate, must not be null
       * @param listener  the listener, may be null
       * @throws IllegalArgumentException if the list is null
       */
      protected ObservableList(
              final List list,
              final Object listener) {
          super(list, listener);
      }
      
      /**
       * Constructor used by subclass views, such as subList.
       * 
       * @param handler  the handler to use, must not be null
       * @param list  the subList to decorate, must not be null
       * @throws IllegalArgumentException if the list is null
       */
      protected ObservableList(
              final ModificationHandler handler,
              final List list) {
          super(handler, list);
      }
      
      /**
       * Typecast the collection to a List.
       * 
       * @return the wrapped collection as a List
       */
      private List getList() {
          return (List) getCollection();
      }
  
      // List API
      //-----------------------------------------------------------------------
      public Object get(int index) {
          return getList().get(index);
      }
  
      public int indexOf(Object object) {
          return getList().indexOf(object);
      }
  
      public int lastIndexOf(Object object) {
          return getList().lastIndexOf(object);
      }
  
      //-----------------------------------------------------------------------
      public void add(int index, Object object) {
          if (handler.preAddIndexed(index, object)) {
              getList().add(index, object);
              handler.postAddIndexed(index, object);
          }
      }
  
      public boolean addAll(int index, Collection coll) {
          boolean result = false;
          if (handler.preAddAllIndexed(index, coll)) {
              result = getList().addAll(index, coll);
              handler.postAddAllIndexed(index, coll, result);
          }
          return result;
      }
  
      public Object remove(int index) {
          Object result = null;
          if (handler.preRemoveIndexed(index)) {
              result = getList().remove(index);
              handler.postRemoveIndexed(index, result);
          }
          return result;
      }
  
      public Object set(int index, Object object) {
          Object result = null;
          if (handler.preSetIndexed(index, object)) {
              result = getList().set(index, object);
              handler.postSetIndexed(index, object, result);
          }
          return result;
      }
  
      public ListIterator listIterator() {
          return new ObservableListIterator(getList().listIterator());
      }
  
      public ListIterator listIterator(int index) {
          return new ObservableListIterator(getList().listIterator(index));
      }
  
      /**
       * Returns a subList view on the original base <code>List</code>.
       * <p>
       * Changes to the subList affect the underlying List. Change events will
       * return change indices relative to the underlying List, not the subList.
       * 
       * @param fromIndex  inclusive start index of the range
       * @param toIndex  exclusive end index of the range
       * @return the subList view
       */
      public List subList(int fromIndex, int toIndex) {
          List subList = getList().subList(fromIndex, toIndex);
          return new ObservableList(subList, getHandler().createSubListHandler(fromIndex, toIndex));
      }
  
      // ListIterator
      //-----------------------------------------------------------------------
      /**
       * Inner class ListIterator for the ObservableList.
       */
      protected class ObservableListIterator extends AbstractListIteratorDecorator {
          
          protected Object last;
          
          protected ObservableListIterator(ListIterator iterator) {
              super(iterator);
          }
          
          public Object next() {
              last = super.next();
              return last;
          }
  
          public Object previous() {
              last = iterator.previous();
              return last;
          }
  
          public void remove() {
              int index = iterator.previousIndex();
              if (handler.preRemoveIterated(index, last)) {
                  iterator.remove();
                  handler.postRemoveIterated(index, last);
              }
          }
          
          public void add(Object object) {
              int index = iterator.nextIndex();
              if (handler.preAddIterated(index, object)) {
                  iterator.add(object);
                  handler.postAddIterated(index, object);
              }
          }
  
          public void set(Object object) {
              int index = iterator.previousIndex();
              if (handler.preSetIterated(index, object, last)) {
                  iterator.set(object);
                  handler.postSetIterated(index, object, last);
              }
          }
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableCollection.java
  
  Index: ObservableCollection.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableCollection.java,v 1.1 2003/09/21 16:00:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.observed;
  
  import java.util.Collection;
  import java.util.Iterator;
  
  import org.apache.commons.collections.decorators.AbstractCollectionDecorator;
  import org.apache.commons.collections.decorators.AbstractIteratorDecorator;
  import org.apache.commons.collections.observed.standard.StandardModificationHandler;
  
  /**
   * Decorates a <code>Collection</code> implementation to observe modifications.
   * <p>
   * Each modifying method call made on this <code>Collection</code> is forwarded to a
   * {@link ModificationHandler}.
   * The handler manages the event, notifying listeners and optionally vetoing changes.
   * The default handler is {@link StandardModificationHandler}.
   * See this class for details of configuration available.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/09/21 16:00:28 $
   * 
   * @author Stephen Colebourne
   */
  public class ObservableCollection extends AbstractCollectionDecorator {
      
      /** The list of registered factories, checked in reverse order */
      private static ModificationHandlerFactory[] factories = new ModificationHandlerFactory[] {
          ModificationHandler.FACTORY,
          StandardModificationHandler.FACTORY
      };
      
      /** The handler to delegate event handling to */
      protected final ModificationHandler handler;
  
      // ObservableCollection factories
      //-----------------------------------------------------------------------
      /**
       * Factory method to create an observable collection.
       * <p>
       * A {@link StandardModificationHandler} will be created.
       * This can be accessed by {@link #getHandler()} to add listeners.
       *
       * @param coll  the collection to decorate, must not be null
       * @return the observed collection
       * @throws IllegalArgumentException if the collection is null
       */
      public static ObservableCollection decorate(final Collection coll) {
          return new ObservableCollection(coll, null);
      }
  
      /**
       * Factory method to create an observable collection using a listener or a handler.
       * <p>
       * A lot of functionality is available through this method.
       * If you don't need the extra functionality, simply implement the
       * {@link org.apache.commons.collections.observed.standard.StandardModificationListener}
       * interface and pass it in as the second parameter.
       * <p>
       * Internally, an <code>ObservableCollection</code> relies on a {@link 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.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * <p>
       * 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.
       * <p>
       * A <code>null</code> listener will create a {@link StandardModificationHandler}.
       *
       * @param coll  the collection to decorate, must not be null
       * @param listener  collection listener, may be null
       * @return the observed collection
       * @throws IllegalArgumentException if the collection is null
       * @throws IllegalArgumentException if there is no valid handler for the listener
       */
      public static ObservableCollection decorate(
              final Collection coll,
              final Object listener) {
          
          if (coll == null) {
              throw new IllegalArgumentException("Collection must not be null");
          }
          return new ObservableCollection(coll, listener);
      }
  
      // Register for ModificationHandlerFactory
      //-----------------------------------------------------------------------
      /**
       * Registers a handler factory to be used for looking up a listener to
       * a handler.
       * <p>
       * This method is used to add your own event handler to the supplied ones.
       * Registering the factory will enable the {@link #decorate(Collection, Object)}
       * method to create your handler.
       * <p>
       * Each handler added becomes the first in the lookup chain. Thus it is
       * possible to override the default setup.
       * Obviously this should be done with care in a shared web environment!
       * <p>
       * This method is not guaranteed to be threadsafe.
       * It should only be called during initialization.
       * Problems will occur if two threads call this method at the same time.
       * 
       * @param factory  the factory to add, may be null
       */
      public static void registerFactory(final ModificationHandlerFactory factory) {
          if (factory != null) {
              // add at end, as checked in reverse order
              ModificationHandlerFactory[] array = new ModificationHandlerFactory[factories.length + 1];
              System.arraycopy(factories, 0, array, 0, factories.length);
              array[factories.length] = factory;
              factories = array;  // atomic operation
          }
      }
  
      // Constructors
      //-----------------------------------------------------------------------
      /**
       * Constructor that wraps (not copies) and takes a handler.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * 
       * @param coll  the collection to decorate, must not be null
       * @param handler  the observing handler, may be null
       * @throws IllegalArgumentException if the collection is null
       */
      protected ObservableCollection(
              final Collection coll,
              final Object listener) {
          super(coll);
          this.handler = createHandler(coll, listener);
          this.handler.init(this, coll);
      }
  
      /**
       * Constructor used by subclass views, such as subList.
       * 
       * @param handler  the observing handler, may be null
       * @param coll  the collection to decorate, must not be null
       * @throws IllegalArgumentException if the collection is null
       */
      protected ObservableCollection(
              final ModificationHandler handler,
              final Collection coll) {
          super(coll);
          this.handler = handler;
      }
  
      /**
       * Creates a handler subclass based on the specified listener.
       * <p>
       * The method is defined in terms of an Object to allow for unusual
       * listeners, such as a Swing model object.
       * 
       * @param listener  a listener object to create a handler for
       * @return an instantiated handler with the listener attached
       * @throws IllegalArgumentException if no suitable handler
       */
      protected ModificationHandler createHandler(final Collection coll, final Object listener) {
          if (listener == null) {
              return new StandardModificationHandler();
          }
          ModificationHandlerFactory[] array = factories;  // atomic operation
          for (int i = array.length - 1; i >= 0 ; i--) {
              ModificationHandler handler = array[i].createHandler(coll, listener);
              if (handler != null) {
                  return handler;
              }
          }
          throw new IllegalArgumentException("Unrecognised listener type: " +
              (listener == null ? "null" : listener.getClass().getName()));
      }
  
      // Handler access
      //-----------------------------------------------------------------------
      /**
       * Gets the handler that is observing this collection.
       * 
       * @return the observing handler, never null
       */
      public ModificationHandler getHandler() {
          return handler;
      }
      
      // Collection
      //-----------------------------------------------------------------------
      public boolean add(Object object) {
          boolean result = false;
          if (handler.preAdd(object)) {
              result = collection.add(object);
              handler.postAdd(object, result);
          }
          return result;
      }
  
      public boolean addAll(Collection coll) {
          boolean result = false;
          if (handler.preAddAll(coll)) {
              result = collection.addAll(coll);
              handler.postAddAll(coll, result);
          }
          return result;
      }
  
      public void clear() {
          if (handler.preClear()) {
              collection.clear();
              handler.postClear();
          }
      }
  
      public Iterator iterator() {
          return new ObservableIterator(collection.iterator());
      }
  
      public boolean remove(Object object) {
          boolean result = false;
          if (handler.preRemove(object)) {
              result = collection.remove(object);
              handler.postRemove(object, result);
          }
          return result;
      }
  
      public boolean removeAll(Collection coll) {
          boolean result = false;
          if (handler.preRemoveAll(coll)) {
              result = collection.removeAll(coll);
              handler.postRemoveAll(coll, result);
          }
          return result;
      }
  
      public boolean retainAll(Collection coll) {
          boolean result = false;
          if (handler.preRetainAll(coll)) {
              result = collection.retainAll(coll);
              handler.postRetainAll(coll, result);
          }
          return result;
      }
  
      // Iterator
      //-----------------------------------------------------------------------
      /**
       * Inner class Iterator for the ObservableCollection.
       */
      protected class ObservableIterator extends AbstractIteratorDecorator {
          
          protected int lastIndex = -1;
          protected Object last;
          
          protected ObservableIterator(Iterator iterator) {
              super(iterator);
          }
          
          public Object next() {
              last = super.next();
              lastIndex++;
              return last;
          }
  
          public void remove() {
              if (handler.preRemoveIterated(lastIndex, last)) {
                  iterator.remove();
                  handler.postRemoveIterated(lastIndex, last);
                  lastIndex--;
              }
          }
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableSet.java
  
  Index: ObservableSet.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableSet.java,v 1.1 2003/09/21 16:00:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.observed;
  
  import java.util.Set;
  
  
  /**
   * Decorates a <code>Set</code> implementation to observe modifications.
   * <p>
   * Each modifying method call made on this <code>Set</code> is forwarded to a
   * {@link ModificationHandler}.
   * The handler manages the event, notifying listeners and optionally vetoing changes.
   * The default handler is {@link StandardModificationHandler}.
   * See this class for details of configuration available.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/09/21 16:00:28 $
   * 
   * @author Stephen Colebourne
   */
  public class ObservableSet extends ObservableCollection implements Set {
      
      // Factories
      //-----------------------------------------------------------------------
      /**
       * Factory method to create an observable set.
       * <p>
       * A {@link StandardModificationHandler} will be created.
       * This can be accessed by {@link #getHandler()} to add listeners.
       *
       * @param set  the set to decorate, must not be null
       * @return the observed Set
       * @throws IllegalArgumentException if the collection is null
       */
      public static ObservableSet decorate(final Set set) {
          return new ObservableSet(set, null);
      }
  
      /**
       * Factory method to create an observable set using a listener or a handler.
       * <p>
       * A lot of functionality is available through this method.
       * If you don't need the extra functionality, simply implement the
       * {@link org.apache.commons.collections.observed.standard.StandardModificationListener}
       * interface and pass it in as the second parameter.
       * <p>
       * Internally, an <code>ObservableSet</code> relies on a {@link 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.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * <p>
       * 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.
       * <p>
       * A <code>null</code> listener will create a {@link StandardModificationHandler}.
       *
       * @param set  the set to decorate, must not be null
       * @param listener  set listener, may be null
       * @return the observed set
       * @throws IllegalArgumentException if the set is null
       * @throws IllegalArgumentException if there is no valid handler for the listener
       */
      public static ObservableSet decorate(
              final Set set,
              final Object listener) {
          
          if (set == null) {
              throw new IllegalArgumentException("Set must not be null");
          }
          return new ObservableSet(set, listener);
      }
  
      // Constructors
      //-----------------------------------------------------------------------
      /**
       * Constructor that wraps (not copies) and takes a handler.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * 
       * @param set  the set to decorate, must not be null
       * @param listener  the listener, may be null
       * @throws IllegalArgumentException if the set is null
       */
      protected ObservableSet(
              final Set set,
              final Object listener) {
          super(set, listener);
      }
  
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableBag.java
  
  Index: ObservableBag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/ObservableBag.java,v 1.1 2003/09/21 16:00:28 scolebourne Exp $
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.collections.observed;
  
  import java.util.Set;
  
  import org.apache.commons.collections.Bag;
  
  /**
   * Decorates a <code>Bag</code> implementation to observe modifications.
   * <p>
   * Each modifying method call made on this <code>Bag</code> is forwarded to a
   * {@link ModificationHandler}.
   * The handler manages the event, notifying listeners and optionally vetoing changes.
   * The default handler is {@link StandardModificationHandler}.
   * See this class for details of configuration available.
   * <p>
   * NOTE: The {@link #uniqueSet()} method returns a <code>Set</code> that is
   * NOT observed. This is because the set should be unmodifiable.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/09/21 16:00:28 $
   * 
   * @author Stephen Colebourne
   */
  public class ObservableBag extends ObservableCollection implements Bag {
      
      // Factories
      //-----------------------------------------------------------------------
      /**
       * Factory method to create an observable bag.
       * <p>
       * A {@link StandardModificationHandler} will be created.
       * This can be accessed by {@link #getHandler()} to add listeners.
       *
       * @param bag  the bag to decorate, must not be null
       * @return the observed Bag
       * @throws IllegalArgumentException if the bag is null
       */
      public static ObservableBag decorate(final Bag bag) {
          return new ObservableBag(bag, null);
      }
  
      /**
       * Factory method to create an observable bag using a listener or a handler.
       * <p>
       * A lot of functionality is available through this method.
       * If you don't need the extra functionality, simply implement the
       * {@link org.apache.commons.collections.observed.standard.StandardModificationListener}
       * interface and pass it in as the second parameter.
       * <p>
       * Internally, an <code>ObservableBag</code> relies on a {@link 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.
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * <p>
       * 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.
       * <p>
       * A <code>null</code> listener will create a {@link StandardModificationHandler}.
       *
       * @param bag  the bag to decorate, must not be null
       * @param listener  bag listener, may be null
       * @return the observed bag
       * @throws IllegalArgumentException if the bag is null
       * @throws IllegalArgumentException if there is no valid handler for the listener
       */
      public static ObservableBag decorate(
              final Bag bag,
              final Object listener) {
          
          if (bag == null) {
              throw new IllegalArgumentException("Bag must not be null");
          }
          return new ObservableBag(bag, listener);
      }
  
      // Constructors
      //-----------------------------------------------------------------------
      /**
       * Constructor that wraps (not copies).
       * <p>
       * The handler implementation is determined by the listener parameter via
       * the registered factories. The listener may be a manually configured 
       * <code>ModificationHandler</code> instance.
       * 
       * @param bag  the bag to decorate, must not be null
       * @param listener  the listener, may be null
       * @throws IllegalArgumentException if the bag is null
       */
      protected ObservableBag(
              final Bag bag,
              final Object listener) {
          super(bag, listener);
      }
      
      /**
       * Typecast the collection to a Bag.
       * 
       * @return the wrapped collection as a Bag
       */
      private Bag getBag() {
          return (Bag) getCollection();
      }
  
      // Bag API
      //-----------------------------------------------------------------------
      public int getCount(Object object) {
          return getBag().getCount(object);
      }
  
      public Set uniqueSet() {
          return getBag().uniqueSet();
      }
  
      //-----------------------------------------------------------------------
      public boolean add(Object object) {
          // override as Bag violates Collection contract
          boolean result = false;
          if (handler.preAdd(object)) {
              result = collection.add(object);
              handler.postAdd(object, true);  // true, as result is misleading
          }
          return result;
      }
  
      public boolean add(Object object, int nCopies) {
          boolean result = false;
          if (handler.preAddNCopies(object, nCopies)) {
              result = getBag().add(object, nCopies);
              handler.postAddNCopies(object, nCopies, result);
          }
          return result;
      }
  
      public boolean remove(Object object, int nCopies) {
          boolean result = false;
          if (handler.preRemoveNCopies(object, nCopies)) {
              result = getBag().remove(object, nCopies);
              handler.postRemoveNCopies(object, nCopies, result);
          }
          return result;
      }
  
  }
  
  
  
  1.5       +11 -11    jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardModificationHandler.java
  
  Index: StandardModificationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardModificationHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StandardModificationHandler.java	7 Sep 2003 10:33:33 -0000	1.4
  +++ StandardModificationHandler.java	21 Sep 2003 16:00:28 -0000	1.5
  @@ -62,7 +62,7 @@
   import org.apache.commons.collections.observed.ModificationEventType;
   import org.apache.commons.collections.observed.ModificationHandler;
   import org.apache.commons.collections.observed.ModificationHandlerFactory;
  -import org.apache.commons.collections.observed.ObservedCollection;
  +import org.apache.commons.collections.observed.ObservableCollection;
   
   /**
    * The standard implementation of a <code>ModificationHandler</code> that
  @@ -111,9 +111,9 @@
       /**
        * Constructor the creates the handler but leaves it invalid.
        * <p>
  -     * The handler can only be used after {@link #init(ObservedCollection)} is
  +     * The handler can only be used after {@link #init(ObservableCollection)} is
        * called. This is normally done automatically by
  -     * {@link ObservedCollection#decorate(Collection, ModificationHandler)}.
  +     * {@link ObservableCollection#decorate(Collection, ModificationHandler)}.
        */
       public StandardModificationHandler() {
           super();
  @@ -122,9 +122,9 @@
       /**
        * Constructor the creates the handler but leaves it invalid.
        * <p>
  -     * The handler can only be used after {@link #init(ObservedCollection)} is
  +     * The handler can only be used after {@link #init(ObservableCollection)} is
        * called. This is normally done automatically by
  -     * {@link ObservedCollection#decorate(Collection, ModificationHandler)}.
  +     * {@link ObservableCollection#decorate(Collection, ModificationHandler)}.
        * 
        * @param pre  the pre listener
        * @param preMask  the mask for the pre listener
  @@ -435,7 +435,7 @@
        */
       protected boolean preEvent(
               int type, int index, Object object,
  -            int repeat, Object previous, ObservedCollection range, int rangeOffset) {
  +            int repeat, Object previous, ObservableCollection range, int rangeOffset) {
   
           preSize = getObservedCollection().size();
           return firePreEvent(type, index, object, repeat, previous, range, rangeOffset);
  @@ -455,7 +455,7 @@
        */
       protected boolean firePreEvent(
               int type, int index, Object object, int repeat,
  -            Object previous, ObservedCollection range, int rangeOffset) {
  +            Object previous, ObservableCollection range, int rangeOffset) {
   
           if ((preMask & type) > 0) {
               StandardPreModificationEvent event = null;
  @@ -492,7 +492,7 @@
        */
       protected void postEvent(
               boolean modified, int type, int index, Object object,
  -            int repeat, Object previous, ObservedCollection range, int rangeOffset) {
  +            int repeat, Object previous, ObservableCollection range, int rangeOffset) {
   
           if (modified) {
               firePostEvent(type, index, object, repeat, previous, range, rangeOffset);
  @@ -512,7 +512,7 @@
        */
       protected void firePostEvent(
               int type, int index, Object object, int repeat,
  -            Object previous, ObservedCollection range, int rangeOffset) {
  +            Object previous, ObservableCollection range, int rangeOffset) {
   
           if ((postMask & type) > 0) {
               StandardPostModificationEvent event = null;
  
  
  
  1.4       +5 -5      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardPreModificationEvent.java
  
  Index: StandardPreModificationEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardPreModificationEvent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardPreModificationEvent.java	7 Sep 2003 10:33:33 -0000	1.3
  +++ StandardPreModificationEvent.java	21 Sep 2003 16:00:28 -0000	1.4
  @@ -58,7 +58,7 @@
   package org.apache.commons.collections.observed.standard;
   
   import org.apache.commons.collections.observed.ModificationHandler;
  -import org.apache.commons.collections.observed.ObservedCollection;
  +import org.apache.commons.collections.observed.ObservableCollection;
   
   /**
    * Event class that encapsulates all the event information for a
  @@ -91,7 +91,7 @@
        * @param previous  the previous value being removed/replaced
        */
       public StandardPreModificationEvent(
  -        final ObservedCollection obsCollection,
  +        final ObservableCollection obsCollection,
           final ModificationHandler handler,
           final int type,
           final int preSize,
  @@ -99,7 +99,7 @@
           final Object object,
           final int repeat,
           final Object previous,
  -        final ObservedCollection range,
  +        final ObservableCollection range,
           final int rangeOffset) {
   
           super(obsCollection, handler, type, preSize, index,
  
  
  
  1.4       +5 -5      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardPostModificationEvent.java
  
  Index: StandardPostModificationEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardPostModificationEvent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardPostModificationEvent.java	7 Sep 2003 10:33:33 -0000	1.3
  +++ StandardPostModificationEvent.java	21 Sep 2003 16:00:28 -0000	1.4
  @@ -58,7 +58,7 @@
   package org.apache.commons.collections.observed.standard;
   
   import org.apache.commons.collections.observed.ModificationHandler;
  -import org.apache.commons.collections.observed.ObservedCollection;
  +import org.apache.commons.collections.observed.ObservableCollection;
   
   /**
    * Event class that encapsulates all the event information for a
  @@ -96,7 +96,7 @@
        * @param rangeOffset  the offset of the range, -1 if unknown
        */
       public StandardPostModificationEvent(
  -        final ObservedCollection obsCollection,
  +        final ObservableCollection obsCollection,
           final ModificationHandler handler,
           final int type,
           final int preSize,
  @@ -104,7 +104,7 @@
           final Object object,
           final int repeat,
           final Object previous,
  -        final ObservedCollection range,
  +        final ObservableCollection range,
           final int rangeOffset) {
   
           super(obsCollection, handler, type, preSize, index,
  
  
  
  1.2       +1 -1      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/package.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- package.html	3 Sep 2003 23:54:26 -0000	1.1
  +++ package.html	21 Sep 2003 16:00:28 -0000	1.2
  @@ -1,5 +1,5 @@
   <BODY>
   <p>
   This package contains a standard implementation of the modification event classes
  -that are used with ObservedCollection.
  +that are used with ObservableCollection et al.
   </BODY>
  
  
  
  1.6       +8 -8      jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardModificationEvent.java
  
  Index: StandardModificationEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/observed/standard/StandardModificationEvent.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardModificationEvent.java	7 Sep 2003 10:33:33 -0000	1.5
  +++ StandardModificationEvent.java	21 Sep 2003 16:00:28 -0000	1.6
  @@ -67,7 +67,7 @@
   import org.apache.commons.collections.observed.ModificationEvent;
   import org.apache.commons.collections.observed.ModificationEventType;
   import org.apache.commons.collections.observed.ModificationHandler;
  -import org.apache.commons.collections.observed.ObservedCollection;
  +import org.apache.commons.collections.observed.ObservableCollection;
   
   /**
    * Event class that encapsulates the event information for a
  @@ -97,7 +97,7 @@
       /** The result of the method call */
       protected final Object previous;
       /** The range that the event came from, null if none */
  -    protected final ObservedCollection range;
  +    protected final ObservableCollection range;
       /** The offset of the range that the event came from, -1 if none */
       protected final int rangeOffset;
   
  @@ -118,7 +118,7 @@
        * @param rangeOffset  the offset of the range, -1 if unknown
        */
       public StandardModificationEvent(
  -        final ObservedCollection obsCollection,
  +        final ObservableCollection obsCollection,
           final ModificationHandler handler,
           final int type,
           final int preSize,
  @@ -126,7 +126,7 @@
           final Object object,
           final int repeat,
           final Object previous,
  -        final ObservedCollection range,
  +        final ObservableCollection range,
           final int rangeOffset) {
   
           super(obsCollection, handler, type);
  @@ -230,7 +230,7 @@
        * 
        * @return the range
        */
  -    public ObservedCollection getRange() {
  +    public ObservableCollection getRange() {
           return range;
       }
   
  @@ -311,7 +311,7 @@
        */
       public String toString() {
           StringBuffer buf = new StringBuffer(64);
  -        buf.append("ObservedEvent[type=");
  +        buf.append("ModificationEvent[type=");
           buf.append(ModificationEventType.toString(type));
           if (index >= 0) {
               buf.append(",index=");
  
  
  

Mime
View raw message