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/test/org/apache/commons/collections/decorators ObservedTestHelper.java TestObservedList.java TestObservedCollection.java TestObservedSet.java
Date Sun, 31 Aug 2003 22:44:54 GMT
scolebourne    2003/08/31 15:44:54

  Modified:    collections/src/java/org/apache/commons/collections/event
                        StandardModificationListener.java
                        ModificationHandler.java
                        StandardModificationHandler.java
               collections/src/java/org/apache/commons/collections/decorators
                        ObservedSet.java ObservedList.java
                        ObservedCollection.java
               collections/src/test/org/apache/commons/collections/decorators
                        ObservedTestHelper.java TestObservedList.java
                        TestObservedCollection.java TestObservedSet.java
  Added:       collections/src/java/org/apache/commons/collections/event
                        ModificationListener.java
                        StandardPostModificationListener.java
                        StandardPreModificationListener.java
  Removed:     collections/src/java/org/apache/commons/collections/event
                        StandardModificationAdaptor.java
  Log:
  Refactor events so pre and post more separated
  
  Revision  Changes    Path
  1.4       +6 -38     jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardModificationListener.java
  
  Index: StandardModificationListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardModificationListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardModificationListener.java	31 Aug 2003 21:09:49 -0000	1.3
  +++ StandardModificationListener.java	31 Aug 2003 22:44:54 -0000	1.4
  @@ -57,48 +57,16 @@
    */
   package org.apache.commons.collections.event;
   
  -import java.util.EventListener;
  -
   /**
  - * A listener that receives events from the <code>StandardModificationHandler</code>.
  - * <p>
  - * This listener has two methods.
  - * <ol>
  - * <li><code>modificationOccurring</code> - called before the modification
  - * occurs and can veto the change.
  - * <li><code>modificationOccurred</code> - called after the change and is
  - * for information.
  - * </ol>
  + * A listener for the <code>StandardModificationHandler</code> that is called
  + * both before the collection is changed and after the change has occurred.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
    * 
    * @author Stephen Colebourne
    */
  -public interface StandardModificationListener extends EventListener {
  +public interface StandardModificationListener 
  +    extends StandardPreModificationListener, StandardPostModificationListener {
   
  -    /**
  -     * A collection modification is occurring.
  -     * <p>
  -     * To veto the change, throw <code>ModicationVetoedException</code>.
  -     * <p>
  -     * This method should be processed quickly, as with all event handling.
  -     * It should also avoid modifying the event source (the collection).
  -     * 
  -     * @param event  the event detail
  -     * @throws ModicationVetoedException to veto
  -     */
  -    public void modificationOccurring(StandardModificationEvent event);
  -    
  -    /**
  -     * A collection modification occurred.
  -     * <p>
  -     * This method should be processed quickly, as with all event handling.
  -     * It should also avoid modifying the event source (the collection).
  -     * Finally it should avoid throwing an exception.
  -     * 
  -     * @param event  the event detail
  -     */
  -    public void modificationOccurred(StandardModificationEvent event);
  -    
   }
  
  
  
  1.4       +58 -9     jakarta-commons/collections/src/java/org/apache/commons/collections/event/ModificationHandler.java
  
  Index: ModificationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/event/ModificationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ModificationHandler.java	31 Aug 2003 21:09:49 -0000	1.3
  +++ ModificationHandler.java	31 Aug 2003 22:44:54 -0000	1.4
  @@ -119,22 +119,22 @@
           return collection;
       }
       
  -    // Listeners
  +    // PreListeners
       //----------------------------------------------------------------------
       /**
  -     * Gets an array of all the listeners active in the handler.
  +     * Gets an array of all the pre listeners active in the handler.
        * <p>
        * This implementation throws UnsupportedOperationException.
        * 
        * @return the listeners
        * @throws UnsupportedOperationException if the handler does not support listeners
        */
  -    public Object[] getModificationListeners() {
  +    public Object[] getPreModificationListeners() {
           throw new UnsupportedOperationException("Listeners not supported by " + getClass().getName());
       }
       
       /**
  -     * Adds a listener to the list held in the handler.
  +     * Adds a pre listener to the list held in the handler.
        * <p>
        * No error occurs if the listener is <code>null</code>.
        * <p>
  @@ -149,12 +149,12 @@
        * @throws ClassCastException if the listener is not of the correct type
        * @throws UnsupportedOperationException if the handler does not support listeners
        */
  -    public void addModificationListener(Object listener) {
  +    public void addPreModificationListener(Object listener) {
           throw new UnsupportedOperationException("Listeners not supported by " + getClass().getName());
       }
       
       /**
  -     * Removes a listener to the list held in the handler.
  +     * Removes a pre listener to the list held in the handler.
        * <p>
        * No error occurs if the listener is not in the list or the type
        * of the listener is incorrect.
  @@ -164,7 +164,56 @@
        * @param listener  the listener to remove, may be null (ignored)
        * @throws UnsupportedOperationException if the handler does not support listeners
        */
  -    public void removeModificationListener(Object listener) {
  +    public void removePreModificationListener(Object listener) {
  +        throw new UnsupportedOperationException("Listeners not supported by " + getClass().getName());
  +    }
  +    
  +    // PostListeners
  +    //----------------------------------------------------------------------
  +    /**
  +     * Gets an array of all the post listeners active in the handler.
  +     * <p>
  +     * This implementation throws UnsupportedOperationException.
  +     * 
  +     * @return the listeners
  +     * @throws UnsupportedOperationException if the handler does not support listeners
  +     */
  +    public Object[] getPostModificationListeners() {
  +        throw new UnsupportedOperationException("Listeners not supported by " + getClass().getName());
  +    }
  +    
  +    /**
  +     * Adds a post listener to the list held in the handler.
  +     * <p>
  +     * No error occurs if the listener is <code>null</code>.
  +     * <p>
  +     * The listener does not necessarily have to be a listener in the classic
  +     * JavaBean sense. It is entirely up to the handler as to how it interprets
  +     * the listener parameter. A ClassCastException is thrown if the handler
  +     * cannot interpret the parameter.
  +     * <p>
  +     * This implementation throws UnsupportedOperationException.
  +     * 
  +     * @param listener  the listener to add, may be null (ignored)
  +     * @throws ClassCastException if the listener is not of the correct type
  +     * @throws UnsupportedOperationException if the handler does not support listeners
  +     */
  +    public void addPostModificationListener(Object listener) {
  +        throw new UnsupportedOperationException("Listeners not supported by " + getClass().getName());
  +    }
  +    
  +    /**
  +     * Removes a post listener to the list held in the handler.
  +     * <p>
  +     * No error occurs if the listener is not in the list or the type
  +     * of the listener is incorrect.
  +     * <p>
  +     * This implementation throws UnsupportedOperationException.
  +     * 
  +     * @param listener  the listener to remove, may be null (ignored)
  +     * @throws UnsupportedOperationException if the handler does not support listeners
  +     */
  +    public void removePostModificationListener(Object listener) {
           throw new UnsupportedOperationException("Listeners not supported by " + getClass().getName());
       }
       
  
  
  
  1.4       +230 -81   jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardModificationHandler.java
  
  Index: StandardModificationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardModificationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardModificationHandler.java	31 Aug 2003 21:09:49 -0000	1.3
  +++ StandardModificationHandler.java	31 Aug 2003 22:44:54 -0000	1.4
  @@ -66,18 +66,8 @@
    * In addition, the <code>size</code> method is used on the collection.
    * All objects used are the real objects from the method calls, not clones.
    * <p>
  - * Each listener can be filtered. There are separate filters for pre events
  - * (modificationOccurring) and post events (modificationOccurred).
  - * <p>
  - * This implementation is the standard one. Most listeners will probably be
  - * content with the events generated from here. However, if you need something
  - * extra then this class can be subclassed or replaced as required. For example:
  - * <ul>
  - * <li>to store the state of the collection before the change
  - * <li>to change the event classes
  - * <li>to change the event dispatch mechanism to something other than listeners
  - * <li>to clone the objects before placing them in the event
  - * </ul>
  + * Each listener can be filtered. There are separate filters for pre and post
  + * modification events.
    *
    * @since Commons Collections 3.0
    * @version $Revision$ $Date$
  @@ -87,14 +77,19 @@
   public class StandardModificationHandler extends ModificationHandler {
   
       /** A reusable empty holders array. */    
  -    protected static final Holder[] EMPTY_HOLDERS = new Holder[0];
  +    protected static final PreHolder[] EMPTY_PRE_HOLDERS = new PreHolder[0];
  +    /** A reusable empty holders array. */    
  +    protected static final PostHolder[] EMPTY_POST_HOLDERS = new PostHolder[0];
       
       /** The event mask as to which event types to send on pre events. */
       protected int preMask = ModificationEventType.GROUP_NONE;
       /** The event mask as to which event types to send on post events. */
       protected int postMask = ModificationEventType.GROUP_NONE;
  +    
       /** The event listeners. */
  -    protected Holder[] holders = EMPTY_HOLDERS;
  +    protected PreHolder[] preHolder = EMPTY_PRE_HOLDERS;
  +    /** The event listeners. */
  +    protected PostHolder[] postHolder = EMPTY_POST_HOLDERS;
       /**
        * Temporary store for the size.
        * This makes the class thread-unsafe, but you should sync collections anyway.
  @@ -114,57 +109,84 @@
           super();
       }
   
  -    // Listeners
  +    /**
  +     * Constructor the creates the handler but leaves it invalid.
  +     * <p>
  +     * The handler can only be used after {@link #init(ObservedCollection)} is
  +     * called. This is normally done automatically by
  +     * {@link ObservedCollection#decorate(Collection, ModificationHandler)}.
  +     * 
  +     * @param pre  the pre listener
  +     * @param preMask  the mask for the pre listener
  +     * @param post  the post listener
  +     * @param postMask  the mask for the post listener
  +     */
  +    public StandardModificationHandler(
  +            StandardPreModificationListener pre, int preMask,
  +            StandardPostModificationListener post, int postMask) {
  +        super();
  +        if (pre != null) {
  +            preHolder = new PreHolder[1];
  +            preHolder[0] = new PreHolder(pre, preMask);
  +            this.preMask = preMask;
  +        }
  +        if (post != null) {
  +            postHolder = new PostHolder[1];
  +            postHolder[0] = new PostHolder(post, postMask);
  +            this.postMask = postMask;
  +        }
  +    }
  +
  +    // Pre Listeners
       //----------------------------------------------------------------------
       /**
  -     * Gets an array of all the listeners active in the handler.
  +     * Gets an array of all the pre listeners active in the handler.
        * <p>
  -     * All listeners will be instances of StandardModificationListener.
  +     * All listeners will be instances of StandardPreModificationListener.
        * 
        * @return the listeners
        */
  -    public synchronized Object[] getModificationListeners() {
  -        Object[] lnrs = new Object[holders.length];
  -        for (int i = 0; i < holders.length; i++) {
  -            lnrs[i] = holders[i].listener;
  +    public synchronized Object[] getPreModificationListeners() {
  +        Object[] lnrs = new Object[preHolder.length];
  +        for (int i = 0; i < preHolder.length; i++) {
  +            lnrs[i] = preHolder[i].listener;
           }
           return lnrs;
       }
       
       /**
  -     * Adds a listener to the list held in the handler.
  +     * Adds a listener to the handler for pre modification events.
        * <p>
        * No error occurs if the listener is <code>null</code>.
        * 
        * @param listener  the listener to add, may be null (ignored)
  -     * @throws ClassCastException if the listener is not a StandardModificationListener
  +     * @throws ClassCastException if the listener is not a StandardPreModificationListener
        */
  -    public void addModificationListener(Object listener) {
  -        addModificationListener((StandardModificationListener) listener, -1, -1);
  +    public void addPreModificationListener(Object listener) {
  +        addPreModificationListener((StandardPreModificationListener) listener, -1);
       }
       
       /**
  -     * Adds a listener to the list held in the handler.
  +     * Adds a pre listener to the list held in the handler.
        * <p>
        * No error occurs if the listener is <code>null</code>.
        * 
        * @param listener  the listener to add, may be null (ignored)
  -     * @param preMask  the mask for pre events (0 for none, -1 for all)
  -     * @param postMask  the mask for post events (0 for none, -1 for all)
  +     * @param mask  the mask for events (0 for none, -1 for all)
        */
  -    public synchronized void addModificationListener(StandardModificationListener listener, int preMask, int postMask) {
  +    public synchronized void addPreModificationListener(StandardPreModificationListener listener, int mask) {
           if (listener != null) {
  -            int oldSize = holders.length;
  -            Holder[] array = new Holder[oldSize + 1];
  -            System.arraycopy(holders, 0, array, 0, oldSize);
  -            array[oldSize] = new Holder(listener, preMask, postMask);
  -            holders = array;
  -            calculateMasks();
  +            int oldSize = preHolder.length;
  +            PreHolder[] array = new PreHolder[oldSize + 1];
  +            System.arraycopy(preHolder, 0, array, 0, oldSize);
  +            array[oldSize] = new PreHolder(listener, mask);
  +            preHolder = array;
  +            calculatePreMask();
           }
       }
       
       /**
  -     * Removes a listener to the list held in the handler.
  +     * Removes a pre listener to the list held in the handler.
        * <p>
        * No error occurs if the listener is not in the list or the type
        * of the listener is incorrect.
  @@ -172,33 +194,33 @@
        * 
        * @param listener  the listener to remove, may be null (ignored)
        */
  -    public synchronized void removeModificationListener(Object listener) {
  +    public synchronized void removePreModificationListener(Object listener) {
           if (listener != null) {
  -            switch (holders.length) {
  +            switch (preHolder.length) {
                   case 0:
                   return;
                   
                   case 1:
  -                if (holders[0].listener == listener) {
  -                    holders = EMPTY_HOLDERS;
  -                    calculateMasks();
  +                if (preHolder[0].listener == listener) {
  +                    preHolder = EMPTY_PRE_HOLDERS;
  +                    calculatePreMask();
                   }
                   return;
                   
                   default:
  -                Holder[] array = new Holder[holders.length - 1];
  +                PreHolder[] array = new PreHolder[preHolder.length - 1];
                   boolean match = false;
  -                for (int i = 0; i < holders.length; i++) {
  +                for (int i = 0; i < preHolder.length; i++) {
                       if (match) {
  -                        array[i - 1] = holders[i];
  -                    } else if (holders[i].listener == listener) {
  +                        array[i - 1] = preHolder[i];
  +                    } else if (preHolder[i].listener == listener) {
                           match = true;
                       } else {
  -                        array[i] = holders[i];
  +                        array[i] = preHolder[i];
                       }
                   }
  -                holders = array;
  -                calculateMasks();
  +                preHolder = array;
  +                calculatePreMask();
                   return;
               }
           }
  @@ -210,56 +232,183 @@
        * No error occurs if the listener is not in the list.
        * The listener is matched using ==.
        * 
  +     * @param listener  the listener to change, may be null
  +     * @param mask  the new mask (0 for none, -1 for all)
        * @return a non-null array of listeners
        */
  -    public synchronized void setModificationListenerMasks(StandardModificationListener listener, int preMask, int postMask) {
  +    public synchronized void setPreModificationListenerMask(StandardPreModificationListener listener, int mask) {
           if (listener != null) {
  -            for (int i = 0; i < holders.length; i++) {
  -                if (holders[i].listener == listener) {
  -                    holders[i].preMask = preMask;
  -                    holders[i].postMask = postMask;
  -                    calculateMasks();
  +            for (int i = 0; i < preHolder.length; i++) {
  +                if (preHolder[i].listener == listener) {
  +                    preHolder[i].mask = mask;
  +                    calculatePreMask();
                       break;
                   }
               }
           }
       }
       
  -    // Holder for listener and masks
  -    //-----------------------------------------------------------------------
  -    protected static class Holder {
  -        StandardModificationListener listener;
  -        int preMask;
  -        int postMask;
  +    /**
  +     * Calculate the combined masks.
  +     */
  +    protected void calculatePreMask() {
  +        preMask = ModificationEventType.GROUP_NONE;
  +        for (int i = 0; i < preHolder.length; i++) {
  +            preMask |= preHolder[i].mask;
  +        }
  +    }
  +    
  +    protected static class PreHolder {
  +        final StandardPreModificationListener listener;
  +        int mask;
           
  -        Holder(StandardModificationListener listener, int preMask, int postMask) {
  +        PreHolder(StandardPreModificationListener listener, int mask) {
               this.listener = listener;
  -            this.preMask = preMask;
  -            this.postMask = postMask;
  +            this.mask = mask;
           }
           
           public String toString() {
  -            return "[" + listener + ","
  -                + ModificationEventType.toString(preMask) + ","
  -                + ModificationEventType.toString(postMask) + "]";
  +            return "[" + listener + "," + ModificationEventType.toString(mask) + "]";
           }
   
       }
       
  -    // Masks
  -    //-----------------------------------------------------------------------
  +    // Post Listeners
  +    //----------------------------------------------------------------------
  +    /**
  +     * Gets an array of all the post listeners active in the handler.
  +     * <p>
  +     * All listeners will be instances of StandardModificationListener.
  +     * 
  +     * @return the listeners
  +     */
  +    public synchronized Object[] getPostModificationListeners() {
  +        Object[] lnrs = new Object[postHolder.length];
  +        for (int i = 0; i < postHolder.length; i++) {
  +            lnrs[i] = postHolder[i].listener;
  +        }
  +        return lnrs;
  +    }
  +    
  +    /**
  +     * Adds a listener to the handler for post modification events.
  +     * <p>
  +     * No error occurs if the listener is <code>null</code>.
  +     * 
  +     * @param listener  the listener to add, may be null (ignored)
  +     * @throws ClassCastException if the listener is not a StandardPreModificationListener
  +     */
  +    public void addPostModificationListener(Object listener) {
  +        addPostModificationListener((StandardPostModificationListener) listener, -1);
  +    }
  +    
  +    /**
  +     * Adds a post listener to the list held in the handler.
  +     * <p>
  +     * No error occurs if the listener is <code>null</code>.
  +     * 
  +     * @param listener  the listener to add, may be null (ignored)
  +     * @param mask  the mask for events (0 for none, -1 for all)
  +     */
  +    public synchronized void addPostModificationListener(StandardPostModificationListener listener, int mask) {
  +        if (listener != null) {
  +            int oldSize = postHolder.length;
  +            PostHolder[] array = new PostHolder[oldSize + 1];
  +            System.arraycopy(postHolder, 0, array, 0, oldSize);
  +            array[oldSize] = new PostHolder(listener, mask);
  +            postHolder = array;
  +            calculatePostMask();
  +        }
  +    }
  +    
  +    /**
  +     * Removes a post listener to the list held in the handler.
  +     * <p>
  +     * No error occurs if the listener is not in the list or the type
  +     * of the listener is incorrect.
  +     * The listener is matched using ==.
  +     * 
  +     * @param listener  the listener to remove, may be null (ignored)
  +     */
  +    public synchronized void removePostModificationListener(Object listener) {
  +        if (listener != null) {
  +            switch (postHolder.length) {
  +                case 0:
  +                return;
  +                
  +                case 1:
  +                if (postHolder[0].listener == listener) {
  +                    postHolder = EMPTY_POST_HOLDERS;
  +                    calculatePostMask();
  +                }
  +                return;
  +                
  +                default:
  +                PostHolder[] array = new PostHolder[postHolder.length - 1];
  +                boolean match = false;
  +                for (int i = 0; i < postHolder.length; i++) {
  +                    if (match) {
  +                        array[i - 1] = postHolder[i];
  +                    } else if (postHolder[i].listener == listener) {
  +                        match = true;
  +                    } else {
  +                        array[i] = postHolder[i];
  +                    }
  +                }
  +                postHolder = array;
  +                calculatePostMask();
  +                return;
  +            }
  +        }
  +    }
  +    
  +    /**
  +     * Sets the masks of a listener.
  +     * <p>
  +     * No error occurs if the listener is not in the list.
  +     * The listener is matched using ==.
  +     * 
  +     * @param listener  the listener to change, may be null
  +     * @param mask  the new mask (0 for none, -1 for all)
  +     * @return a non-null array of listeners
  +     */
  +    public synchronized void setPostModificationListenerMask(StandardPostModificationListener listener, int mask) {
  +        if (listener != null) {
  +            for (int i = 0; i < postHolder.length; i++) {
  +                if (postHolder[i].listener == listener) {
  +                    postHolder[i].mask = mask;
  +                    calculatePostMask();
  +                    break;
  +                }
  +            }
  +        }
  +    }
  +    
       /**
        * Calculate the combined masks.
        */
  -    protected void calculateMasks() {
  -        preMask = ModificationEventType.GROUP_NONE;
  +    protected void calculatePostMask() {
           postMask = ModificationEventType.GROUP_NONE;
  -        for (int i = 0; i < holders.length; i++) {
  -            preMask |= holders[i].preMask;
  -            postMask |= holders[i].postMask;
  +        for (int i = 0; i < postHolder.length; i++) {
  +            postMask |= postHolder[i].mask;
           }
       }
   
  +    protected static class PostHolder {
  +        final StandardPostModificationListener listener;
  +        int mask;
  +        
  +        PostHolder(StandardPostModificationListener listener, int mask) {
  +            this.listener = listener;
  +            this.mask = mask;
  +        }
  +        
  +        public String toString() {
  +            return "[" + listener + "," + ModificationEventType.toString(mask) + "]";
  +        }
  +
  +    }
  +    
       // Pre event sending
       //-----------------------------------------------------------------------
       /**
  @@ -289,9 +438,9 @@
           if ((preMask & type) > 0) {
               StandardModificationEvent event = null;
               synchronized (this) {
  -                for (int i = 0; i < holders.length; i++) {
  -                    Holder holder = holders[i];
  -                    if ((holder.preMask & type) > 0) {
  +                for (int i = 0; i < preHolder.length; i++) {
  +                    PreHolder holder = preHolder[i];
  +                    if ((holder.mask & type) > 0) {
                           if (event == null) {
                               event = new StandardModificationEvent(
                                   getCollection(), this, type, preSize, index, object, repeat, null);
  @@ -350,9 +499,9 @@
           if ((postMask & type) > 0) {
               StandardModificationEvent event = null;
               synchronized (this) {
  -                for (int i = 0; i < holders.length; i++) {
  -                    Holder holder = holders[i];
  -                    if ((holder.postMask & type) > 0) {
  +                for (int i = 0; i < postHolder.length; i++) {
  +                    PostHolder holder = postHolder[i];
  +                    if ((holder.mask & type) > 0) {
                           if (event == null) {
                               event = new StandardModificationEvent(
                                   getCollection(), this, type, preSize, index, object, repeat, result);
  
  
  
  1.4       +0 -0      jakarta-commons/collections/src/java/org/apache/commons/collections/event/ModificationListener.java
  
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardPostModificationListener.java
  
  Index: StandardPostModificationListener.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardPostModificationListener.java,v 1.1 2003/08/31 22:44:54 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.event;
  
  /**
   * A listener for the <code>StandardModificationHandler</code> that is called
   * when a collection has been changed.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/08/31 22:44:54 $
   * 
   * @author Stephen Colebourne
   */
  public interface StandardPostModificationListener extends ModificationListener {
  
      /**
       * A collection modification occurred.
       * <p>
       * This method should be processed quickly, as with all event handling.
       * It should also avoid modifying the event source (the collection).
       * Finally it should avoid throwing an exception.
       * 
       * @param event  the event detail
       */
      public void modificationOccurred(StandardModificationEvent event);
      
  }
  
  
  
  1.1                  jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardPreModificationListener.java
  
  Index: StandardPreModificationListener.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/event/StandardPreModificationListener.java,v 1.1 2003/08/31 22:44:54 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.event;
  
  /**
   * A listener for the <code>StandardModificationHandler</code> that is called
   * when a collection is about to be modified.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/08/31 22:44:54 $
   * 
   * @author Stephen Colebourne
   */
  public interface StandardPreModificationListener extends ModificationListener {
  
      /**
       * A collection modification is occurring.
       * <p>
       * To veto the change, throw <code>ModicationVetoedException</code>.
       * <p>
       * This method should be processed quickly, as with all event handling.
       * It should also avoid modifying the event source (the collection).
       * 
       * @param event  the event detail
       * @throws ModicationVetoedException to veto
       */
      public void modificationOccurring(StandardModificationEvent event);
      
  }
  
  
  
  1.3       +48 -34    jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/ObservedSet.java
  
  Index: ObservedSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/ObservedSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ObservedSet.java	31 Aug 2003 17:24:46 -0000	1.2
  +++ ObservedSet.java	31 Aug 2003 22:44:54 -0000	1.3
  @@ -62,6 +62,8 @@
   import org.apache.commons.collections.event.ModificationHandler;
   import org.apache.commons.collections.event.StandardModificationHandler;
   import org.apache.commons.collections.event.StandardModificationListener;
  +import org.apache.commons.collections.event.StandardPostModificationListener;
  +import org.apache.commons.collections.event.StandardPreModificationListener;
   
   /**
    * <code>ObservedSet</code> decorates a <code>Set</code>
  @@ -104,74 +106,86 @@
   
       /**
        * Factory method to create an observable set and register one
  -     * listener to receive all events.
  +     * listener to receive events before the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
        *
  -     * @param set  the set to decorate, must not be null
  -     * @param listener  the listener, must not be null
  +     * @param coll  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
        */
       public static ObservedSet decorate(
  -            final Set set,
  -            final StandardModificationListener listener) {
  +            final Set coll,
  +            final StandardPreModificationListener listener) {
           
  -        return decorate(set, listener, -1, -1);
  +        if (coll == null) {
  +            throw new IllegalArgumentException("Set must not be null");
  +        }
  +        if (listener == null) {
  +            throw new IllegalArgumentException("Listener must not be null");
  +        }
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            listener, -1, null, 0
  +        );
  +        return new ObservedSet(coll, handler);
       }
   
       /**
        * Factory method to create an observable set and register one
  -     * listener to receive all post events.
  +     * listener to receive events after the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
        *
  -     * @param set  the set to decorate, must not be null
  -     * @param listener  the listener, must not be null
  +     * @param coll  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
        */
  -    public static ObservedSet decoratePostEventsOnly(
  -            final Set set,
  -            final StandardModificationListener listener) {
  +    public static ObservedSet decorate(
  +            final Set coll,
  +            final StandardPostModificationListener listener) {
           
  -        return decorate(set, listener, 0, -1);
  +        if (coll == null) {
  +            throw new IllegalArgumentException("Set must not be null");
  +        }
  +        if (listener == null) {
  +            throw new IllegalArgumentException("Listener must not be null");
  +        }
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            null, 0, listener, -1
  +        );
  +        return new ObservedSet(coll, handler);
       }
   
       /**
  -     * Factory method to create an observable set and
  -     * register one listener using event masks.
  +     * Factory method to create an observable set and register one
  +     * listener to receive events both before and after the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
  -     * The masks are defined in 
  -     * {@link org.apache.commons.collections.event.ModificationEventType ModificationEventType}.
        *
  -     * @param set  the set to decorate, must not be null
  -     * @param listener  the listener, must not be null
  -     * @param preEventMask  mask for pre events (0 for none, -1 for all)
  -     * @param postEventMask  mask for post events (0 for none, -1 for all)
  +     * @param coll  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
        */
       public static ObservedSet decorate(
  -            final Set set,
  -            final StandardModificationListener listener,
  -            final int preEventMask,
  -            final int postEventMask) {
  -            
  -        if (set == null) {
  +            final Set coll,
  +            final StandardModificationListener listener) {
  +        
  +        if (coll == null) {
               throw new IllegalArgumentException("Set must not be null");
           }
           if (listener == null) {
               throw new IllegalArgumentException("Listener must not be null");
           }
  -        StandardModificationHandler handler = new StandardModificationHandler();
  -        ObservedSet oc = new ObservedSet(set, handler);
  -        handler.addModificationListener(listener, preEventMask, postEventMask);
  -        return oc;
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            listener, -1, listener, -1
  +        );
  +        return new ObservedSet(coll, handler);
       }
   
       /**
  @@ -209,7 +223,7 @@
        * 
        * @param set  the set to decorate, must not be null
        * @param handler  the observing handler, may be null
  -     * @throws IllegalArgumentException if the collection is null
  +     * @throws IllegalArgumentException if the set is null
        */
       protected ObservedSet(
               final Set set,
  
  
  
  1.3       +47 -33    jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/ObservedList.java
  
  Index: ObservedList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/ObservedList.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ObservedList.java	31 Aug 2003 17:24:46 -0000	1.2
  +++ ObservedList.java	31 Aug 2003 22:44:54 -0000	1.3
  @@ -64,6 +64,8 @@
   import org.apache.commons.collections.event.ModificationHandler;
   import org.apache.commons.collections.event.StandardModificationHandler;
   import org.apache.commons.collections.event.StandardModificationListener;
  +import org.apache.commons.collections.event.StandardPostModificationListener;
  +import org.apache.commons.collections.event.StandardPreModificationListener;
   
   /**
    * <code>ObservedList</code> decorates a <code>List</code>
  @@ -106,74 +108,86 @@
   
       /**
        * Factory method to create an observable list and register one
  -     * listener to receive all events.
  +     * listener to receive events before the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
        *
  -     * @param list  the list to decorate, must not be null
  -     * @param listener  the listener, must not be null
  +     * @param coll  the list to decorate, must not be null
  +     * @param listener  list listener, must not be null
        * @return the observed list
        * @throws IllegalArgumentException if the list or listener is null
        */
       public static ObservedList decorate(
  -            final List list,
  -            final StandardModificationListener listener) {
  +            final List coll,
  +            final StandardPreModificationListener listener) {
           
  -        return decorate(list, listener, -1, -1);
  +        if (coll == null) {
  +            throw new IllegalArgumentException("List must not be null");
  +        }
  +        if (listener == null) {
  +            throw new IllegalArgumentException("Listener must not be null");
  +        }
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            listener, -1, null, 0
  +        );
  +        return new ObservedList(coll, handler);
       }
   
       /**
        * Factory method to create an observable list and register one
  -     * listener to receive all post events.
  +     * listener to receive events after the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
        *
  -     * @param list  the list to decorate, must not be null
  -     * @param listener  the listener, must not be null
  +     * @param coll  the list to decorate, must not be null
  +     * @param listener  list listener, must not be null
        * @return the observed list
        * @throws IllegalArgumentException if the list or listener is null
        */
  -    public static ObservedList decoratePostEventsOnly(
  -            final List list,
  -            final StandardModificationListener listener) {
  +    public static ObservedList decorate(
  +            final List coll,
  +            final StandardPostModificationListener listener) {
           
  -        return decorate(list, listener, 0, -1);
  +        if (coll == null) {
  +            throw new IllegalArgumentException("List must not be null");
  +        }
  +        if (listener == null) {
  +            throw new IllegalArgumentException("Listener must not be null");
  +        }
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            null, 0, listener, -1
  +        );
  +        return new ObservedList(coll, handler);
       }
   
       /**
  -     * Factory method to create an observable list and
  -     * register one listener using event masks.
  +     * Factory method to create an observable list and register one
  +     * listener to receive events both before and after the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
  -     * The masks are defined in 
  -     * {@link org.apache.commons.collections.event.ModificationEventType ModificationEventType}.
        *
  -     * @param list  the list to decorate, must not be null
  -     * @param listener  the listener, must not be null
  -     * @param preEventMask  mask for pre events (0 for none, -1 for all)
  -     * @param postEventMask  mask for post events (0 for none, -1 for all)
  +     * @param coll  the list to decorate, must not be null
  +     * @param listener  list listener, must not be null
        * @return the observed list
        * @throws IllegalArgumentException if the list or listener is null
        */
       public static ObservedList decorate(
  -            final List list,
  -            final StandardModificationListener listener,
  -            final int preEventMask,
  -            final int postEventMask) {
  -            
  -        if (list == null) {
  +            final List coll,
  +            final StandardModificationListener listener) {
  +        
  +        if (coll == null) {
               throw new IllegalArgumentException("List must not be null");
           }
           if (listener == null) {
               throw new IllegalArgumentException("Listener must not be null");
           }
  -        StandardModificationHandler handler = new StandardModificationHandler();
  -        ObservedList oc = new ObservedList(list, handler);
  -        handler.addModificationListener(listener, preEventMask, postEventMask);
  -        return oc;
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            listener, -1, listener, -1
  +        );
  +        return new ObservedList(coll, handler);
       }
   
       /**
  
  
  
  1.4       +50 -44    jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/ObservedCollection.java
  
  Index: ObservedCollection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/ObservedCollection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ObservedCollection.java	31 Aug 2003 21:09:49 -0000	1.3
  +++ ObservedCollection.java	31 Aug 2003 22:44:54 -0000	1.4
  @@ -63,6 +63,8 @@
   import org.apache.commons.collections.event.ModificationHandler;
   import org.apache.commons.collections.event.StandardModificationHandler;
   import org.apache.commons.collections.event.StandardModificationListener;
  +import org.apache.commons.collections.event.StandardPostModificationListener;
  +import org.apache.commons.collections.event.StandardPreModificationListener;
   
   /**
    * <code>ObservedCollection</code> decorates a <code>Collection</code>
  @@ -108,7 +110,7 @@
   
       /**
        * Factory method to create an observable collection and register one
  -     * listener to receive all events.
  +     * listener to receive events before the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
  @@ -120,14 +122,23 @@
        */
       public static ObservedCollection decorate(
               final Collection coll,
  -            final StandardModificationListener listener) {
  +            final StandardPreModificationListener listener) {
           
  -        return decorate(coll, listener, -1, -1);
  +        if (coll == null) {
  +            throw new IllegalArgumentException("Collection must not be null");
  +        }
  +        if (listener == null) {
  +            throw new IllegalArgumentException("Listener must not be null");
  +        }
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            listener, -1, null, 0
  +        );
  +        return new ObservedCollection(coll, handler);
       }
   
       /**
        * Factory method to create an observable collection and register one
  -     * listener to receive all post events.
  +     * listener to receive events after the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
  @@ -137,45 +148,48 @@
        * @return the observed collection
        * @throws IllegalArgumentException if the collection or listener is null
        */
  -    public static ObservedCollection decoratePostEventsOnly(
  +    public static ObservedCollection decorate(
               final Collection coll,
  -            final StandardModificationListener listener) {
  +            final StandardPostModificationListener listener) {
           
  -        return decorate(coll, listener, 0, -1);
  +        if (coll == null) {
  +            throw new IllegalArgumentException("Collection must not be null");
  +        }
  +        if (listener == null) {
  +            throw new IllegalArgumentException("Listener must not be null");
  +        }
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            null, 0, listener, -1
  +        );
  +        return new ObservedCollection(coll, handler);
       }
   
       /**
  -     * Factory method to create an observable collection and
  -     * register one listener using event masks.
  +     * Factory method to create an observable collection and register one
  +     * listener to receive events both before and after the change is made.
        * <p>
        * A {@link StandardModificationHandler} will be created.
        * The listener will be added to the handler.
  -     * The masks are defined in 
  -     * {@link org.apache.commons.collections.event.ModificationEventType ModificationEventType}.
        *
        * @param coll  the collection to decorate, must not be null
        * @param listener  collection listener, must not be null
  -     * @param preEventMask  mask for pre events (0 for none, -1 for all)
  -     * @param postEventMask  mask for post events (0 for none, -1 for all)
        * @return the observed collection
        * @throws IllegalArgumentException if the collection or listener is null
        */
       public static ObservedCollection decorate(
               final Collection coll,
  -            final StandardModificationListener listener,
  -            final int preEventMask,
  -            final int postEventMask) {
  -            
  +            final StandardModificationListener listener) {
  +        
           if (coll == null) {
               throw new IllegalArgumentException("Collection must not be null");
           }
           if (listener == null) {
               throw new IllegalArgumentException("Listener must not be null");
           }
  -        StandardModificationHandler handler = new StandardModificationHandler();
  -        ObservedCollection oc = new ObservedCollection(coll, handler);
  -        handler.addModificationListener(listener, preEventMask, postEventMask);
  -        return oc;
  +        StandardModificationHandler handler = new StandardModificationHandler(
  +            listener, -1, listener, -1
  +        );
  +        return new ObservedCollection(coll, handler);
       }
   
       /**
  @@ -237,18 +251,7 @@
       // Listener convenience methods
       //----------------------------------------------------------------------
       /**
  -     * Gets an array of all the listeners active in the handler.
  -     * This method simply delegates to the handler.
  -     * 
  -     * @return the listeners
  -     * @throws UnsupportedOperationException if the handler does not support listeners
  -     */
  -    public Object[] getModificationListeners() {
  -        return getHandler().getModificationListeners();
  -    }
  -    
  -    /**
  -     * Adds a listener to the list held in the handler.
  +     * Adds a listener to the handler to receive pre modification events.
        * This method simply delegates to the handler.
        * <p>
        * No error occurs if the listener is <code>null</code>.
  @@ -262,24 +265,27 @@
        * @throws ClassCastException if the listener is not of the correct type
        * @throws UnsupportedOperationException if the handler does not support listeners
        */
  -    public void addModificationListener(Object listener) {
  -        getHandler().addModificationListener(listener);
  +    public void addPreModificationListener(Object listener) {
  +        getHandler().addPreModificationListener(listener);
       }
       
       /**
  -     * Removes a listener to the list held in the handler. 
  +     * Adds a listener to the handler to receive post modification events.
        * This method simply delegates to the handler.
        * <p>
  -     * No error occurs if the listener is not in the list or the type
  -     * of the listener is incorrect.
  +     * No error occurs if the listener is <code>null</code>.
        * <p>
  -     * This implementation throws UnsupportedOperationException.
  +     * The listener does not necessarily have to be a listener in the classic
  +     * JavaBean sense. It is entirely up to the handler as to how it interprets
  +     * the listener parameter. A ClassCastException is thrown if the handler
  +     * cannot interpret the parameter.
        * 
  -     * @param listener  the listener to remove, may be null (ignored)
  +     * @param listener  the listener to add, may be null (ignored)
  +     * @throws ClassCastException if the listener is not of the correct type
        * @throws UnsupportedOperationException if the handler does not support listeners
        */
  -    public void removeModificationListener(Object listener) {
  -        getHandler().removeModificationListener(listener);
  +    public void addPostModificationListener(Object listener) {
  +        getHandler().addPostModificationListener(listener);
       }
       
       // Collection
  
  
  
  1.4       +99 -31    jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/ObservedTestHelper.java
  
  Index: ObservedTestHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/ObservedTestHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ObservedTestHelper.java	31 Aug 2003 21:09:49 -0000	1.3
  +++ ObservedTestHelper.java	31 Aug 2003 22:44:54 -0000	1.4
  @@ -67,6 +67,8 @@
   import org.apache.commons.collections.event.StandardModificationEvent;
   import org.apache.commons.collections.event.StandardModificationHandler;
   import org.apache.commons.collections.event.StandardModificationListener;
  +import org.apache.commons.collections.event.StandardPostModificationListener;
  +import org.apache.commons.collections.event.StandardPreModificationListener;
   
   /**
    * Helper for testing
  @@ -101,8 +103,26 @@
           }
       }
       
  +    public static class PreListener implements StandardPreModificationListener {
  +        public StandardModificationEvent preEvent = null;
  +        
  +        public void modificationOccurring(StandardModificationEvent event) {
  +            this.preEvent = event;
  +        }
  +    }
  +    
  +    public static class PostListener implements StandardPostModificationListener {
  +        public StandardModificationEvent postEvent = null;
  +        
  +        public void modificationOccurred(StandardModificationEvent event) {
  +            this.postEvent = event;
  +        }
  +    }
  +    
       public static final Listener LISTENER = new Listener();
       public static final Listener LISTENER2 = new Listener();
  +    public static final PreListener PRE_LISTENER = new PreListener();
  +    public static final PostListener POST_LISTENER = new PostListener();
       
       public ObservedTestHelper() {
           super();
  @@ -111,52 +131,100 @@
       //-----------------------------------------------------------------------
       public static void doTestFactoryPlain(ObservedCollection coll) {
           Assert.assertEquals(StandardModificationHandler.class, coll.getHandler().getClass());
  -        Assert.assertEquals(0, coll.getModificationListeners().length);
  +        Assert.assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertEquals(0, coll.getHandler().getPostModificationListeners().length);
       }
       
  -    public static void doTestFactoryWithListener(ObservedCollection coll) {
  +    public static void doTestFactoryWithPreListener(ObservedCollection coll) {
           Assert.assertEquals(StandardModificationHandler.class, coll.getHandler().getClass());
  -        Assert.assertEquals(1, coll.getModificationListeners().length);
  -        Assert.assertSame(LISTENER, coll.getModificationListeners()[0]);
  +        Assert.assertEquals(1, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertEquals(0, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(PRE_LISTENER, coll.getHandler().getPreModificationListeners()[0]);
  +        
  +        PRE_LISTENER.preEvent = null;
  +        coll.add(SIX);
  +        Assert.assertTrue(PRE_LISTENER.preEvent != null);
  +    }
  +    
  +    public static void doTestFactoryWithPostListener(ObservedCollection coll) {
  +        Assert.assertEquals(StandardModificationHandler.class, coll.getHandler().getClass());
  +        Assert.assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertEquals(1, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(POST_LISTENER, coll.getHandler().getPostModificationListeners()[0]);
  +        
  +        POST_LISTENER.postEvent = null;
  +        coll.add(SIX);
  +        Assert.assertTrue(POST_LISTENER.postEvent != null);
       }
       
  -    public static void doTestFactoryPostEvents(ObservedCollection coll) {
  +    public static void doTestFactoryWithListener(ObservedCollection coll) {
           Assert.assertEquals(StandardModificationHandler.class, coll.getHandler().getClass());
  -        Assert.assertEquals(1, coll.getModificationListeners().length);
  -        Assert.assertSame(LISTENER, coll.getModificationListeners()[0]);
  +        Assert.assertEquals(1, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertEquals(1, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(LISTENER, coll.getHandler().getPreModificationListeners()[0]);
  +        Assert.assertSame(LISTENER, coll.getHandler().getPostModificationListeners()[0]);
           
           LISTENER.preEvent = null;
           LISTENER.postEvent = null;
           coll.add(SIX);
  -        Assert.assertTrue(LISTENER.preEvent == null);
  +        Assert.assertTrue(LISTENER.preEvent != null);
           Assert.assertTrue(LISTENER.postEvent != null);
       }
       
       //-----------------------------------------------------------------------
  -    public static void doTestAddRemoveGetListeners(ObservedCollection coll) {
  -        Assert.assertEquals(0, coll.getModificationListeners().length);
  -        coll.addModificationListener(LISTENER);
  -        Assert.assertEquals(1, coll.getModificationListeners().length);
  -        Assert.assertSame(LISTENER, coll.getModificationListeners()[0]);
  -        
  -        coll.addModificationListener(LISTENER2);
  -        Assert.assertEquals(2, coll.getModificationListeners().length);
  -        Assert.assertSame(LISTENER, coll.getModificationListeners()[0]);
  -        Assert.assertSame(LISTENER2, coll.getModificationListeners()[1]);
  -        
  -        coll.removeModificationListener(LISTENER);
  -        Assert.assertEquals(1, coll.getModificationListeners().length);
  -        Assert.assertSame(LISTENER2, coll.getModificationListeners()[0]);
  -        
  -        coll.removeModificationListener(LISTENER);  // check no error if not present
  -        Assert.assertEquals(1, coll.getModificationListeners().length);
  -        Assert.assertSame(LISTENER2, coll.getModificationListeners()[0]);
  +    public static void doTestAddRemoveGetPreListeners(ObservedCollection coll) {
  +        Assert.assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        coll.getHandler().addPreModificationListener(LISTENER);
  +        Assert.assertEquals(1, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertSame(LISTENER, coll.getHandler().getPreModificationListeners()[0]);
  +        
  +        coll.getHandler().addPreModificationListener(LISTENER2);
  +        Assert.assertEquals(2, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertSame(LISTENER, coll.getHandler().getPreModificationListeners()[0]);
  +        Assert.assertSame(LISTENER2, coll.getHandler().getPreModificationListeners()[1]);
  +        
  +        coll.getHandler().removePreModificationListener(LISTENER);
  +        Assert.assertEquals(1, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertSame(LISTENER2, coll.getHandler().getPreModificationListeners()[0]);
  +        
  +        coll.getHandler().removePreModificationListener(LISTENER);  // check no error if not present
  +        Assert.assertEquals(1, coll.getHandler().getPreModificationListeners().length);
  +        Assert.assertSame(LISTENER2, coll.getHandler().getPreModificationListeners()[0]);
  +        
  +        coll.getHandler().removePreModificationListener(LISTENER2);
  +        Assert.assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        
  +        try {
  +            coll.getHandler().addPreModificationListener(new Object());
  +            Assert.fail();
  +        } catch (ClassCastException ex) {
  +        }
  +    }
  +    
  +    public static void doTestAddRemoveGetPostListeners(ObservedCollection coll) {
  +        Assert.assertEquals(0, coll.getHandler().getPostModificationListeners().length);
  +        coll.getHandler().addPostModificationListener(LISTENER);
  +        Assert.assertEquals(1, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(LISTENER, coll.getHandler().getPostModificationListeners()[0]);
  +        
  +        coll.getHandler().addPostModificationListener(LISTENER2);
  +        Assert.assertEquals(2, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(LISTENER, coll.getHandler().getPostModificationListeners()[0]);
  +        Assert.assertSame(LISTENER2, coll.getHandler().getPostModificationListeners()[1]);
  +        
  +        coll.getHandler().removePostModificationListener(LISTENER);
  +        Assert.assertEquals(1, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(LISTENER2, coll.getHandler().getPostModificationListeners()[0]);
  +        
  +        coll.getHandler().removePostModificationListener(LISTENER);  // check no error if not present
  +        Assert.assertEquals(1, coll.getHandler().getPostModificationListeners().length);
  +        Assert.assertSame(LISTENER2, coll.getHandler().getPostModificationListeners()[0]);
           
  -        coll.removeModificationListener(LISTENER2);
  -        Assert.assertEquals(0, coll.getModificationListeners().length);
  +        coll.getHandler().removePostModificationListener(LISTENER2);
  +        Assert.assertEquals(0, coll.getHandler().getPostModificationListeners().length);
           
           try {
  -            coll.addModificationListener(new Object());
  +            coll.getHandler().addPostModificationListener(new Object());
               Assert.fail();
           } catch (ClassCastException ex) {
           }
  
  
  
  1.3       +52 -44    jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestObservedList.java
  
  Index: TestObservedList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestObservedList.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestObservedList.java	31 Aug 2003 17:28:42 -0000	1.2
  +++ TestObservedList.java	31 Aug 2003 22:44:54 -0000	1.3
  @@ -65,7 +65,6 @@
   import junit.framework.TestSuite;
   
   import org.apache.commons.collections.TestList;
  -import org.apache.commons.collections.event.ModificationEventType;
   import org.apache.commons.collections.event.StandardModificationHandler;
   
   /**
  @@ -83,6 +82,8 @@
       private static Integer SEVEN = new Integer(7);
       private static Integer EIGHT = new Integer(8);
       private static final ObservedTestHelper.Listener LISTENER = ObservedTestHelper.LISTENER;
  +    private static final ObservedTestHelper.PreListener PRE_LISTENER = ObservedTestHelper.PRE_LISTENER;
  +    private static final ObservedTestHelper.PostListener POST_LISTENER = ObservedTestHelper.POST_LISTENER;
       
       public TestObservedList(String testName) {
           super(testName);
  @@ -116,11 +117,17 @@
           coll = ObservedList.decorate(new ArrayList(), LISTENER);
           ObservedTestHelper.doTestFactoryWithListener(coll);
           
  -        coll = ObservedList.decoratePostEventsOnly(new ArrayList(), LISTENER);
  -        ObservedTestHelper.doTestFactoryPostEvents(coll);
  +        coll = ObservedList.decorate(new ArrayList(), PRE_LISTENER);
  +        ObservedTestHelper.doTestFactoryWithPreListener(coll);
  +        
  +        coll = ObservedList.decorate(new ArrayList(), POST_LISTENER);
  +        ObservedTestHelper.doTestFactoryWithPostListener(coll);
  +        
  +        coll = ObservedList.decorate(new ArrayList());
  +        ObservedTestHelper.doTestAddRemoveGetPreListeners(coll);
           
           coll = ObservedList.decorate(new ArrayList());
  -        ObservedTestHelper.doTestAddRemoveGetListeners(coll);
  +        ObservedTestHelper.doTestAddRemoveGetPostListeners(coll);
           
           coll = ObservedList.decorate(new ArrayList(), LISTENER);
           ObservedTestHelper.doTestAdd(coll);
  @@ -162,44 +169,45 @@
           ObservedList coll = ObservedList.decorate(new ArrayList(), handler);
           
           assertSame(handler, coll.getHandler());
  -        assertEquals(0, coll.getModificationListeners().length);
  -    }
  -    
  -    public void testFactoryWithMasks() {
  -        ObservedList coll = ObservedList.decorate(new ArrayList(), LISTENER, -1, 0);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent == null);
  -        
  -        coll = ObservedList.decorate(new ArrayList(), LISTENER, 0, -1);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent == null);
  -        assertTrue(LISTENER.postEvent != null);
  -        
  -        coll = ObservedList.decorate(new ArrayList(), LISTENER, -1, -1);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent != null);
  -        
  -        coll = ObservedList.decorate(new ArrayList(), LISTENER, 0, 0);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent == null);
  -        assertTrue(LISTENER.postEvent == null);
  -        
  -        coll = ObservedList.decorate(new ArrayList(), LISTENER, ModificationEventType.ADD, ModificationEventType.ADD_ALL);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent == null);
  +        assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        assertEquals(0, coll.getHandler().getPostModificationListeners().length);
       }
       
  +//    public void testFactoryWithMasks() {
  +//        ObservedList coll = ObservedList.decorate(new ArrayList(), LISTENER, -1, 0);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//        
  +//        coll = ObservedList.decorate(new ArrayList(), LISTENER, 0, -1);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent == null);
  +//        assertTrue(LISTENER.postEvent != null);
  +//        
  +//        coll = ObservedList.decorate(new ArrayList(), LISTENER, -1, -1);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent != null);
  +//        
  +//        coll = ObservedList.decorate(new ArrayList(), LISTENER, 0, 0);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent == null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//        
  +//        coll = ObservedList.decorate(new ArrayList(), LISTENER, ModificationEventType.ADD, ModificationEventType.ADD_ALL);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//    }
  +//    
   }
  
  
  
  1.3       +52 -44    jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestObservedCollection.java
  
  Index: TestObservedCollection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestObservedCollection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestObservedCollection.java	31 Aug 2003 17:28:42 -0000	1.2
  +++ TestObservedCollection.java	31 Aug 2003 22:44:54 -0000	1.3
  @@ -66,7 +66,6 @@
   import junit.framework.TestSuite;
   
   import org.apache.commons.collections.TestCollection;
  -import org.apache.commons.collections.event.ModificationEventType;
   import org.apache.commons.collections.event.StandardModificationHandler;
   
   /**
  @@ -84,6 +83,8 @@
       private static Integer SEVEN = new Integer(7);
       private static Integer EIGHT = new Integer(8);
       private static final ObservedTestHelper.Listener LISTENER = ObservedTestHelper.LISTENER;
  +    private static final ObservedTestHelper.PreListener PRE_LISTENER = ObservedTestHelper.PRE_LISTENER;
  +    private static final ObservedTestHelper.PostListener POST_LISTENER = ObservedTestHelper.POST_LISTENER;
       
       public TestObservedCollection(String testName) {
           super(testName);
  @@ -127,11 +128,17 @@
           coll = ObservedCollection.decorate(new ArrayList(), LISTENER);
           ObservedTestHelper.doTestFactoryWithListener(coll);
           
  -        coll = ObservedCollection.decoratePostEventsOnly(new ArrayList(), LISTENER);
  -        ObservedTestHelper.doTestFactoryPostEvents(coll);
  +        coll = ObservedCollection.decorate(new ArrayList(), PRE_LISTENER);
  +        ObservedTestHelper.doTestFactoryWithPreListener(coll);
  +        
  +        coll = ObservedCollection.decorate(new ArrayList(), POST_LISTENER);
  +        ObservedTestHelper.doTestFactoryWithPostListener(coll);
  +        
  +        coll = ObservedCollection.decorate(new ArrayList());
  +        ObservedTestHelper.doTestAddRemoveGetPreListeners(coll);
           
           coll = ObservedCollection.decorate(new ArrayList());
  -        ObservedTestHelper.doTestAddRemoveGetListeners(coll);
  +        ObservedTestHelper.doTestAddRemoveGetPostListeners(coll);
           
           coll = ObservedCollection.decorate(new ArrayList(), LISTENER);
           ObservedTestHelper.doTestAdd(coll);
  @@ -161,44 +168,45 @@
           ObservedCollection coll = ObservedCollection.decorate(new ArrayList(), handler);
           
           assertSame(handler, coll.getHandler());
  -        assertEquals(0, coll.getModificationListeners().length);
  -    }
  -    
  -    public void testFactoryWithMasks() {
  -        ObservedCollection coll = ObservedCollection.decorate(new ArrayList(), LISTENER, -1, 0);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent == null);
  -        
  -        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, 0, -1);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent == null);
  -        assertTrue(LISTENER.postEvent != null);
  -        
  -        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, -1, -1);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent != null);
  -        
  -        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, 0, 0);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent == null);
  -        assertTrue(LISTENER.postEvent == null);
  -        
  -        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, ModificationEventType.ADD, ModificationEventType.ADD_ALL);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent == null);
  +        assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        assertEquals(0, coll.getHandler().getPostModificationListeners().length);
       }
       
  +//    public void testFactoryWithMasks() {
  +//        ObservedCollection coll = ObservedCollection.decorate(new ArrayList(), LISTENER, -1, 0);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//        
  +//        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, 0, -1);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent == null);
  +//        assertTrue(LISTENER.postEvent != null);
  +//        
  +//        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, -1, -1);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent != null);
  +//        
  +//        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, 0, 0);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent == null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//        
  +//        coll = ObservedCollection.decorate(new ArrayList(), LISTENER, ModificationEventType.ADD, ModificationEventType.ADD_ALL);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//    }
  +//    
   }
  
  
  
  1.3       +52 -44    jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestObservedSet.java
  
  Index: TestObservedSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/decorators/TestObservedSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestObservedSet.java	31 Aug 2003 17:28:42 -0000	1.2
  +++ TestObservedSet.java	31 Aug 2003 22:44:54 -0000	1.3
  @@ -65,7 +65,6 @@
   import junit.framework.TestSuite;
   
   import org.apache.commons.collections.TestSet;
  -import org.apache.commons.collections.event.ModificationEventType;
   import org.apache.commons.collections.event.StandardModificationHandler;
   
   /**
  @@ -83,6 +82,8 @@
       private static Integer SEVEN = new Integer(7);
       private static Integer EIGHT = new Integer(8);
       private static final ObservedTestHelper.Listener LISTENER = ObservedTestHelper.LISTENER;
  +    private static final ObservedTestHelper.PreListener PRE_LISTENER = ObservedTestHelper.PRE_LISTENER;
  +    private static final ObservedTestHelper.PostListener POST_LISTENER = ObservedTestHelper.POST_LISTENER;
       
       public TestObservedSet(String testName) {
           super(testName);
  @@ -116,11 +117,17 @@
           coll = ObservedSet.decorate(new HashSet(), LISTENER);
           ObservedTestHelper.doTestFactoryWithListener(coll);
           
  -        coll = ObservedSet.decoratePostEventsOnly(new HashSet(), LISTENER);
  -        ObservedTestHelper.doTestFactoryPostEvents(coll);
  +        coll = ObservedSet.decorate(new HashSet(), PRE_LISTENER);
  +        ObservedTestHelper.doTestFactoryWithPreListener(coll);
  +        
  +        coll = ObservedSet.decorate(new HashSet(), POST_LISTENER);
  +        ObservedTestHelper.doTestFactoryWithPostListener(coll);
  +        
  +        coll = ObservedSet.decorate(new HashSet());
  +        ObservedTestHelper.doTestAddRemoveGetPreListeners(coll);
           
           coll = ObservedSet.decorate(new HashSet());
  -        ObservedTestHelper.doTestAddRemoveGetListeners(coll);
  +        ObservedTestHelper.doTestAddRemoveGetPostListeners(coll);
           
           coll = ObservedSet.decorate(new HashSet(), LISTENER);
           ObservedTestHelper.doTestAdd(coll);
  @@ -150,44 +157,45 @@
           ObservedSet coll = ObservedSet.decorate(new HashSet(), handler);
           
           assertSame(handler, coll.getHandler());
  -        assertEquals(0, coll.getModificationListeners().length);
  -    }
  -    
  -    public void testFactoryWithMasks() {
  -        ObservedSet coll = ObservedSet.decorate(new HashSet(), LISTENER, -1, 0);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent == null);
  -        
  -        coll = ObservedSet.decorate(new HashSet(), LISTENER, 0, -1);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent == null);
  -        assertTrue(LISTENER.postEvent != null);
  -        
  -        coll = ObservedSet.decorate(new HashSet(), LISTENER, -1, -1);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent != null);
  -        
  -        coll = ObservedSet.decorate(new HashSet(), LISTENER, 0, 0);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent == null);
  -        assertTrue(LISTENER.postEvent == null);
  -        
  -        coll = ObservedSet.decorate(new HashSet(), LISTENER, ModificationEventType.ADD, ModificationEventType.ADD_ALL);
  -        LISTENER.preEvent = null;
  -        LISTENER.postEvent = null;
  -        coll.add(SIX);
  -        assertTrue(LISTENER.preEvent != null);
  -        assertTrue(LISTENER.postEvent == null);
  +        assertEquals(0, coll.getHandler().getPreModificationListeners().length);
  +        assertEquals(0, coll.getHandler().getPostModificationListeners().length);
       }
       
  +//    public void testFactoryWithMasks() {
  +//        ObservedSet coll = ObservedSet.decorate(new HashSet(), LISTENER, -1, 0);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//        
  +//        coll = ObservedSet.decorate(new HashSet(), LISTENER, 0, -1);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent == null);
  +//        assertTrue(LISTENER.postEvent != null);
  +//        
  +//        coll = ObservedSet.decorate(new HashSet(), LISTENER, -1, -1);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent != null);
  +//        
  +//        coll = ObservedSet.decorate(new HashSet(), LISTENER, 0, 0);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent == null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//        
  +//        coll = ObservedSet.decorate(new HashSet(), LISTENER, ModificationEventType.ADD, ModificationEventType.ADD_ALL);
  +//        LISTENER.preEvent = null;
  +//        LISTENER.postEvent = null;
  +//        coll.add(SIX);
  +//        assertTrue(LISTENER.preEvent != null);
  +//        assertTrue(LISTENER.postEvent == null);
  +//    }
  +//    
   }
  
  
  

Mime
View raw message