scolebourne    2003/12/03 04:27:37

  Modified:    collections/src/java/org/apache/commons/collections/list
                        UnmodifiableList.java
               collections/src/java/org/apache/commons/collections/buffer
                        UnmodifiableBuffer.java
                        UnmodifiablePriorityQueue.java
               collections/src/java/org/apache/commons/collections/map
                        UnmodifiableSortedMap.java UnmodifiableMap.java
                        UnmodifiableOrderedMap.java
               collections/src/java/org/apache/commons/collections/iterators
                        UnmodifiableListIterator.java
                        UnmodifiableMapIterator.java
                        UnmodifiableOrderedMapIterator.java
                        UnmodifiableIterator.java
               collections/src/java/org/apache/commons/collections/set
                        UnmodifiableSortedSet.java UnmodifiableSet.java
               collections/src/java/org/apache/commons/collections
                        BeanMap.java
               collections/src/java/org/apache/commons/collections/collection
                        UnmodifiableBoundedCollection.java
                        UnmodifiableCollection.java
               collections/src/java/org/apache/commons/collections/bag
                        UnmodifiableSortedBag.java UnmodifiableBag.java
  Added:       collections/src/java/org/apache/commons/collections/map
                        UnmodifiableEntrySet.java
  Log:
  Update and make consistent the Unmodifiable decorators
  
  Revision  Changes    Path
  1.3       +4 -25     
jakarta-commons/collections/src/java/org/apache/commons/collections/list/UnmodifiableList.java
  
  Index: UnmodifiableList.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/list/UnmodifiableList.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableList.java     3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableList.java     3 Dec 2003 12:27:36 -0000       1.3
  @@ -74,7 +74,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableList extends AbstractListDecorator implements Unmodifiable 
{
  +public final class UnmodifiableList extends AbstractListDecorator implements 
Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable list.
  @@ -96,19 +96,10 @@
        * @param list  the list to decorate, must not be null
        * @throws IllegalArgumentException if list is null
        */
  -    protected UnmodifiableList(List list) {
  +    private UnmodifiableList(List list) {
           super(list);
       }
   
  -    /**
  -     * Gets the list being decorated.
  -     * 
  -     * @return the list being decorated
  -     */
  -    protected List getList() {
  -        return (List) getCollection();
  -    }
  -
       //-----------------------------------------------------------------------
       public Iterator iterator() {
           return UnmodifiableIterator.decorate(getCollection().iterator());
  @@ -139,18 +130,6 @@
       }
   
       //-----------------------------------------------------------------------
  -    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 ListIterator listIterator() {
           return UnmodifiableListIterator.decorate(getList().listIterator());
       }
  
  
  
  1.3       +4 -4      
jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java
  
  Index: UnmodifiableBuffer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableBuffer.java   3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableBuffer.java   3 Dec 2003 12:27:36 -0000       1.3
  @@ -72,7 +72,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableBuffer extends AbstractBufferDecorator implements 
Unmodifiable {
  +public final class UnmodifiableBuffer extends AbstractBufferDecorator implements 
Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable buffer.
  @@ -94,7 +94,7 @@
        * @param buffer  the buffer to decorate, must not be null
        * @throws IllegalArgumentException if buffer is null
        */
  -    protected UnmodifiableBuffer(Buffer buffer) {
  +    private UnmodifiableBuffer(Buffer buffer) {
           super(buffer);
       }
   
  
  
  
  1.3       +8 -7      
jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/UnmodifiablePriorityQueue.java
  
  Index: UnmodifiablePriorityQueue.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/buffer/UnmodifiablePriorityQueue.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiablePriorityQueue.java    3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiablePriorityQueue.java    3 Dec 2003 12:27:36 -0000       1.3
  @@ -71,7 +71,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiablePriorityQueue implements PriorityQueue, Unmodifiable {
  +public final class UnmodifiablePriorityQueue implements PriorityQueue, Unmodifiable 
{
   
       /** The priority queue to decorate */
       protected final PriorityQueue priorityQueue;
  @@ -86,6 +86,9 @@
           if (priorityQueue instanceof Unmodifiable) {
               return priorityQueue;
           }
  +        if (priorityQueue == null) {
  +            throw new IllegalArgumentException("PriorityQueue must not be null");
  +        }
           return new UnmodifiablePriorityQueue(priorityQueue);
       }
       
  @@ -95,10 +98,8 @@
        *
        * @param priorityQueue  the priority queue to synchronize
        */
  -    protected UnmodifiablePriorityQueue(PriorityQueue priorityQueue) {
  -        if (priorityQueue == null) {
  -            throw new IllegalArgumentException("PriorityQueue must not be null");
  -        }
  +    private UnmodifiablePriorityQueue(PriorityQueue priorityQueue) {
  +        super();
           this.priorityQueue = priorityQueue;
       }
   
  
  
  
  1.3       +4 -5      
jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableSortedMap.java
  
  Index: UnmodifiableSortedMap.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableSortedMap.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableSortedMap.java        20 Nov 2003 22:35:50 -0000      1.2
  +++ UnmodifiableSortedMap.java        3 Dec 2003 12:27:36 -0000       1.3
  @@ -65,7 +65,6 @@
   
   import org.apache.commons.collections.Unmodifiable;
   import org.apache.commons.collections.collection.UnmodifiableCollection;
  -import org.apache.commons.collections.map.UnmodifiableMap.UnmodifiableEntrySet;
   import org.apache.commons.collections.set.UnmodifiableSet;
   
   /**
  @@ -98,7 +97,7 @@
        * @param map  the map to decorate, must not be null
        * @throws IllegalArgumentException if map is null
        */
  -    protected UnmodifiableSortedMap(SortedMap map) {
  +    private UnmodifiableSortedMap(SortedMap map) {
           super(map);
       }
   
  @@ -121,7 +120,7 @@
   
       public Set entrySet() {
           Set set = super.entrySet();
  -        return new UnmodifiableEntrySet(set);
  +        return UnmodifiableEntrySet.decorate(set);
       }
   
       public Set keySet() {
  
  
  
  1.6       +4 -89     
jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableMap.java
  
  Index: UnmodifiableMap.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableMap.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- UnmodifiableMap.java      2 Dec 2003 23:51:50 -0000       1.5
  +++ UnmodifiableMap.java      3 Dec 2003 12:27:36 -0000       1.6
  @@ -57,9 +57,7 @@
    */
   package org.apache.commons.collections.map;
   
  -import java.lang.reflect.Array;
   import java.util.Collection;
  -import java.util.Iterator;
   import java.util.Map;
   import java.util.Set;
   
  @@ -67,10 +65,8 @@
   import org.apache.commons.collections.MapIterator;
   import org.apache.commons.collections.Unmodifiable;
   import org.apache.commons.collections.collection.UnmodifiableCollection;
  -import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
   import org.apache.commons.collections.iterators.EntrySetMapIterator;
   import org.apache.commons.collections.iterators.UnmodifiableMapIterator;
  -import org.apache.commons.collections.pairs.AbstractMapEntryDecorator;
   import org.apache.commons.collections.set.UnmodifiableSet;
   
   /**
  @@ -103,7 +99,7 @@
        * @param map  the map to decorate, must not be null
        * @throws IllegalArgumentException if map is null
        */
  -    protected UnmodifiableMap(Map map) {
  +    private UnmodifiableMap(Map map) {
           super(map);
       }
   
  @@ -136,7 +132,7 @@
   
       public Set entrySet() {
           Set set = super.entrySet();
  -        return new UnmodifiableEntrySet(set);
  +        return UnmodifiableEntrySet.decorate(set);
       }
   
       public Set keySet() {
  @@ -147,87 +143,6 @@
       public Collection values() {
           Collection coll = super.values();
           return UnmodifiableCollection.decorate(coll);
  -    }
  -
  -    //-----------------------------------------------------------------------
  -    /**
  -     * Implementation of an entry set that checks (predicates) additions.
  -     */
  -    protected static class UnmodifiableEntrySet extends UnmodifiableSet {
  -        
  -        protected UnmodifiableEntrySet(Set set) {
  -            super(set);
  -        }
  -
  -        public Iterator iterator() {
  -            return new UnmodifiableEntrySetIterator(collection.iterator());
  -        }
  -        
  -        public Object[] toArray() {
  -            Object[] array = collection.toArray();
  -            for (int i = 0; i < array.length; i++) {
  -                array[i] = new UnmodifiableEntry((Map.Entry) array[i]);
  -            }
  -            return array;
  -        }
  -        
  -        public Object[] toArray(Object array[]) {
  -            Object[] result = array;
  -            if (array.length > 0) {
  -                // we must create a new array to handle multi-threaded situations
  -                // where another thread could access data before we decorate it
  -                result = (Object[]) 
Array.newInstance(array.getClass().getComponentType(), 0);
  -            }
  -            result = collection.toArray(result);
  -            for (int i = 0; i < result.length; i++) {
  -                result[i] = new UnmodifiableEntry((Map.Entry) result[i]);
  -            }
  -
  -            // check to see if result should be returned straight
  -            if (result.length > array.length) {
  -                return result;
  -            }
  -
  -            // copy back into input array to fulfil the method contract
  -            System.arraycopy(result, 0, array, 0, result.length);
  -            if (array.length > result.length) {
  -                array[result.length] = null;
  -            }
  -            return array;
  -        }
  -    }
  -
  -    /**
  -     * Implementation of an entry set iterator.
  -     */
  -    protected static class UnmodifiableEntrySetIterator extends 
AbstractIteratorDecorator {
  -        
  -        protected UnmodifiableEntrySetIterator(Iterator iterator) {
  -            super(iterator);
  -        }
  -        
  -        public Object next() {
  -            Map.Entry entry = (Map.Entry) iterator.next();
  -            return new UnmodifiableEntry(entry);
  -        }
  -        
  -        public void remove() {
  -            throw new UnsupportedOperationException();
  -        }
  -    }
  -
  -    /**
  -     * Implementation of a map entry that is unmodifiable.
  -     */
  -    protected static class UnmodifiableEntry extends AbstractMapEntryDecorator {
  -
  -        protected UnmodifiableEntry(Map.Entry entry) {
  -            super(entry);
  -        }
  -
  -        public Object setValue(Object o) {
  -            throw new UnsupportedOperationException();
  -        }
       }
   
   }
  
  
  
  1.4       +4 -5      
jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java
  
  Index: UnmodifiableOrderedMap.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableOrderedMap.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnmodifiableOrderedMap.java       1 Dec 2003 22:48:59 -0000       1.3
  +++ UnmodifiableOrderedMap.java       3 Dec 2003 12:27:36 -0000       1.4
  @@ -68,7 +68,6 @@
   import org.apache.commons.collections.collection.UnmodifiableCollection;
   import org.apache.commons.collections.iterators.UnmodifiableMapIterator;
   import org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator;
  -import org.apache.commons.collections.map.UnmodifiableMap.UnmodifiableEntrySet;
   import org.apache.commons.collections.set.UnmodifiableSet;
   
   /**
  @@ -101,7 +100,7 @@
        * @param map  the map to decorate, must not be null
        * @throws IllegalArgumentException if map is null
        */
  -    protected UnmodifiableOrderedMap(OrderedMap map) {
  +    private UnmodifiableOrderedMap(OrderedMap map) {
           super(map);
       }
   
  @@ -134,7 +133,7 @@
   
       public Set entrySet() {
           Set set = super.entrySet();
  -        return new UnmodifiableEntrySet(set);
  +        return UnmodifiableEntrySet.decorate(set);
       }
   
       public Set keySet() {
  
  
  
  1.1                  
jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java
  
  Index: UnmodifiableEntrySet.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/map/UnmodifiableEntrySet.java,v
 1.1 2003/12/03 12:27:36 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 [EMAIL PROTECTED]
   *
   * 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.map;
  
  import java.lang.reflect.Array;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Set;
  
  import org.apache.commons.collections.Unmodifiable;
  import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
  import org.apache.commons.collections.pairs.AbstractMapEntryDecorator;
  import org.apache.commons.collections.set.AbstractSetDecorator;
  
  /**
   * Decorates a map entry <code>Set</code> to ensure it can't be altered.
   *
   * @since Commons Collections 3.0
   * @version $Revision: 1.1 $ $Date: 2003/12/03 12:27:36 $
   * 
   * @author Stephen Colebourne
   */
  public final class UnmodifiableEntrySet extends AbstractSetDecorator implements 
Unmodifiable {
      
      /**
       * Factory method to create an unmodifiable set of Map Entry objects.
       * 
       * @param set  the set to decorate, must not be null
       * @throws IllegalArgumentException if set is null
       */
      public static Set decorate(Set set) {
          if (set instanceof Unmodifiable) {
              return set;
          }
          return new UnmodifiableEntrySet(set);
      }
  
      //-----------------------------------------------------------------------
      /**
       * Constructor that wraps (not copies).
       * 
       * @param set  the set to decorate, must not be null
       * @throws IllegalArgumentException if set is null
       */
      private UnmodifiableEntrySet(Set set) {
          super(set);
      }
  
      //-----------------------------------------------------------------------
      public boolean add(Object object) {
          throw new UnsupportedOperationException();
      }
  
      public boolean addAll(Collection coll) {
          throw new UnsupportedOperationException();
      }
  
      public void clear() {
          throw new UnsupportedOperationException();
      }
  
      public boolean remove(Object object) {
          throw new UnsupportedOperationException();
      }
  
      public boolean removeAll(Collection coll) {
          throw new UnsupportedOperationException();
      }
  
      public boolean retainAll(Collection coll) {
          throw new UnsupportedOperationException();
      }
  
      //-----------------------------------------------------------------------
      public Iterator iterator() {
          return new UnmodifiableEntrySetIterator(collection.iterator());
      }
      
      public Object[] toArray() {
          Object[] array = collection.toArray();
          for (int i = 0; i < array.length; i++) {
              array[i] = new UnmodifiableEntry((Map.Entry) array[i]);
          }
          return array;
      }
      
      public Object[] toArray(Object array[]) {
          Object[] result = array;
          if (array.length > 0) {
              // we must create a new array to handle multi-threaded situations
              // where another thread could access data before we decorate it
              result = (Object[]) 
Array.newInstance(array.getClass().getComponentType(), 0);
          }
          result = collection.toArray(result);
          for (int i = 0; i < result.length; i++) {
              result[i] = new UnmodifiableEntry((Map.Entry) result[i]);
          }
  
          // check to see if result should be returned straight
          if (result.length > array.length) {
              return result;
          }
  
          // copy back into input array to fulfil the method contract
          System.arraycopy(result, 0, array, 0, result.length);
          if (array.length > result.length) {
              array[result.length] = null;
          }
          return array;
      }
      
      //-----------------------------------------------------------------------
      /**
       * Implementation of an entry set iterator.
       */
      final static class UnmodifiableEntrySetIterator extends 
AbstractIteratorDecorator {
          
          protected UnmodifiableEntrySetIterator(Iterator iterator) {
              super(iterator);
          }
          
          public Object next() {
              Map.Entry entry = (Map.Entry) iterator.next();
              return new UnmodifiableEntry(entry);
          }
          
          public void remove() {
              throw new UnsupportedOperationException();
          }
      }
  
      //-----------------------------------------------------------------------
      /**
       * Implementation of a map entry that is unmodifiable.
       */
      final static class UnmodifiableEntry extends AbstractMapEntryDecorator {
  
          protected UnmodifiableEntry(Map.Entry entry) {
              super(entry);
          }
  
          public Object setValue(Object o) {
              throw new UnsupportedOperationException();
          }
      }
  
  }
  
  
  
  1.2       +3 -3      
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java
  
  Index: UnmodifiableListIterator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableListIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnmodifiableListIterator.java     2 Nov 2003 17:26:36 -0000       1.1
  +++ UnmodifiableListIterator.java     3 Dec 2003 12:27:37 -0000       1.2
  @@ -97,7 +97,7 @@
        *
        * @param iterator  the iterator to decoarate
        */
  -    protected UnmodifiableListIterator(ListIterator iterator) {
  +    private UnmodifiableListIterator(ListIterator iterator) {
           super();
           this.iterator = iterator;
       }
  
  
  
  1.4       +3 -3      
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java
  
  Index: UnmodifiableMapIterator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableMapIterator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnmodifiableMapIterator.java      1 Dec 2003 22:49:00 -0000       1.3
  +++ UnmodifiableMapIterator.java      3 Dec 2003 12:27:37 -0000       1.4
  @@ -96,7 +96,7 @@
        *
        * @param iterator  the iterator to decoarate
        */
  -    protected UnmodifiableMapIterator(MapIterator iterator) {
  +    private UnmodifiableMapIterator(MapIterator iterator) {
           super();
           this.iterator = iterator;
       }
  
  
  
  1.3       +3 -3      
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java
  
  Index: UnmodifiableOrderedMapIterator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableOrderedMapIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableOrderedMapIterator.java       1 Dec 2003 22:49:00 -0000       1.2
  +++ UnmodifiableOrderedMapIterator.java       3 Dec 2003 12:27:37 -0000       1.3
  @@ -96,7 +96,7 @@
        *
        * @param iterator  the iterator to decoarate
        */
  -    protected UnmodifiableOrderedMapIterator(OrderedMapIterator iterator) {
  +    private UnmodifiableOrderedMapIterator(OrderedMapIterator iterator) {
           super();
           this.iterator = iterator;
       }
  
  
  
  1.2       +3 -3      
jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java
  
  Index: UnmodifiableIterator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/UnmodifiableIterator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnmodifiableIterator.java 2 Nov 2003 17:26:36 -0000       1.1
  +++ UnmodifiableIterator.java 3 Dec 2003 12:27:37 -0000       1.2
  @@ -99,7 +99,7 @@
        *
        * @param iterator  the iterator to decoarate
        */
  -    protected UnmodifiableIterator(Iterator iterator) {
  +    private UnmodifiableIterator(Iterator iterator) {
           super();
           this.iterator = iterator;
       }
  
  
  
  1.3       +4 -4      
jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java
  
  Index: UnmodifiableSortedSet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableSortedSet.java        3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableSortedSet.java        3 Dec 2003 12:27:37 -0000       1.3
  @@ -72,7 +72,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableSortedSet extends AbstractSortedSetDecorator implements 
Unmodifiable {
  +public final class UnmodifiableSortedSet extends AbstractSortedSetDecorator 
implements Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable set.
  @@ -94,7 +94,7 @@
        * @param set  the set to decorate, must not be null
        * @throws IllegalArgumentException if set is null
        */
  -    protected UnmodifiableSortedSet(SortedSet set) {
  +    private UnmodifiableSortedSet(SortedSet set) {
           super(set);
       }
   
  
  
  
  1.3       +4 -4      
jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSet.java
  
  Index: UnmodifiableSet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/set/UnmodifiableSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableSet.java      3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableSet.java      3 Dec 2003 12:27:37 -0000       1.3
  @@ -72,7 +72,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableSet extends AbstractSetDecorator implements Unmodifiable {
  +public final class UnmodifiableSet extends AbstractSetDecorator implements 
Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable set.
  @@ -94,7 +94,7 @@
        * @param set  the set to decorate, must not be null
        * @throws IllegalArgumentException if set is null
        */
  -    protected UnmodifiableSet(Set set) {
  +    private UnmodifiableSet(Set set) {
           super(set);
       }
   
  
  
  
  1.24      +6 -25     
jakarta-commons/collections/src/java/org/apache/commons/collections/BeanMap.java
  
  Index: BeanMap.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/BeanMap.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- BeanMap.java      3 Dec 2003 11:37:44 -0000       1.23
  +++ BeanMap.java      3 Dec 2003 12:27:37 -0000       1.24
  @@ -456,33 +456,14 @@
        * @return the unmodifiable set of mappings
        */
       public Set entrySet() {
  -        return new AbstractSet() {
  +        return UnmodifiableSet.decorate(new AbstractSet() {
               public Iterator iterator() {
  -                return new Iterator() {
  -
  -                    Iterator methodIter = 
  -                      BeanMap.this.readMethods.keySet().iterator();
  -
  -                    public boolean hasNext() {
  -                        return methodIter.hasNext();
  -                    }
  -
  -                    public Object next() {
  -                        Object key = (Object)methodIter.next();
  -                        return new MyMapEntry( BeanMap.this, key, get(key) );
  -                    }
  -
  -                    public void remove() {
  -                      throw new UnsupportedOperationException
  -                        ("remove() not supported from BeanMap.entrySet()");
  -                    }
  -                };
  +                return entryIterator();
               }
  -
               public int size() {
                 return BeanMap.this.readMethods.size();
               }
  -        };
  +        });
       }
   
       /**
  @@ -559,7 +540,7 @@
               }            
               public Object next() {
                   Object key = iter.next();
  -                Object value = get( (String) key );
  +                Object value = get(key);
                   return new MyMapEntry( BeanMap.this, key, value );
               }            
               public void remove() {
  
  
  
  1.4       +35 -4     
jakarta-commons/collections/src/java/org/apache/commons/collections/collection/UnmodifiableBoundedCollection.java
  
  Index: UnmodifiableBoundedCollection.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/collection/UnmodifiableBoundedCollection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnmodifiableBoundedCollection.java        29 Nov 2003 18:14:20 -0000      1.3
  +++ UnmodifiableBoundedCollection.java        3 Dec 2003 12:27:37 -0000       1.4
  @@ -58,8 +58,10 @@
   package org.apache.commons.collections.collection;
   
   import java.util.Collection;
  +import java.util.Iterator;
   
   import org.apache.commons.collections.BoundedCollection;
  +import org.apache.commons.collections.iterators.UnmodifiableIterator;
   
   /**
    * <code>UnmodifiableBoundedCollection</code> decorates another 
<code>BoundedCollection</code>
  @@ -75,7 +77,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableBoundedCollection extends UnmodifiableCollection 
implements BoundedCollection {
  +public final class UnmodifiableBoundedCollection extends 
AbstractCollectionDecorator implements BoundedCollection {
       
       /**
        * Factory method to create an unmodifiable bounded collection.
  @@ -126,8 +128,37 @@
        * @param coll  the collection to decorate, must not be null
        * @throws IllegalArgumentException if coll is null
        */
  -    protected UnmodifiableBoundedCollection(BoundedCollection coll) {
  +    private UnmodifiableBoundedCollection(BoundedCollection coll) {
           super(coll);
  +    }
  +
  +    //-----------------------------------------------------------------------
  +    public Iterator iterator() {
  +        return UnmodifiableIterator.decorate(getCollection().iterator());
  +    }
  +
  +    public boolean add(Object object) {
  +        throw new UnsupportedOperationException();
  +    }
  +
  +    public boolean addAll(Collection coll) {
  +        throw new UnsupportedOperationException();
  +    }
  +
  +    public void clear() {
  +        throw new UnsupportedOperationException();
  +    }
  +
  +    public boolean remove(Object object) {
  +        throw new UnsupportedOperationException();
  +    }
  +
  +    public boolean removeAll(Collection coll) {
  +        throw new UnsupportedOperationException();
  +    }
  +
  +    public boolean retainAll(Collection coll) {
  +        throw new UnsupportedOperationException();
       }
   
       //-----------------------------------------------------------------------    
  
  
  
  1.3       +4 -4      
jakarta-commons/collections/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java
  
  Index: UnmodifiableCollection.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableCollection.java       3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableCollection.java       3 Dec 2003 12:27:37 -0000       1.3
  @@ -71,7 +71,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableCollection extends AbstractCollectionDecorator implements 
Unmodifiable {
  +public final class UnmodifiableCollection extends AbstractCollectionDecorator 
implements Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable collection.
  @@ -93,7 +93,7 @@
        * @param coll  the collection to decorate, must not be null
        * @throws IllegalArgumentException if collection is null
        */
  -    protected UnmodifiableCollection(Collection coll) {
  +    private UnmodifiableCollection(Collection coll) {
           super(coll);
       }
   
  
  
  
  1.3       +4 -4      
jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java
  
  Index: UnmodifiableSortedBag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableSortedBag.java        3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableSortedBag.java        3 Dec 2003 12:27:37 -0000       1.3
  @@ -72,7 +72,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableSortedBag extends AbstractSortedBagDecorator implements 
Unmodifiable {
  +public final class UnmodifiableSortedBag extends AbstractSortedBagDecorator 
implements Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable bag.
  @@ -94,7 +94,7 @@
        * @param bag  the bag to decorate, must not be null
        * @throws IllegalArgumentException if bag is null
        */
  -    protected UnmodifiableSortedBag(SortedBag bag) {
  +    private UnmodifiableSortedBag(SortedBag bag) {
           super(bag);
       }
   
  
  
  
  1.3       +4 -4      
jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java
  
  Index: UnmodifiableBag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnmodifiableBag.java      3 Dec 2003 11:19:10 -0000       1.2
  +++ UnmodifiableBag.java      3 Dec 2003 12:27:37 -0000       1.3
  @@ -74,7 +74,7 @@
    * 
    * @author Stephen Colebourne
    */
  -public class UnmodifiableBag extends AbstractBagDecorator implements Unmodifiable {
  +public final class UnmodifiableBag extends AbstractBagDecorator implements 
Unmodifiable {
   
       /**
        * Factory method to create an unmodifiable bag.
  @@ -96,7 +96,7 @@
        * @param bag  the bag to decorate, must not be null
        * @throws IllegalArgumentException if bag is null
        */
  -    protected UnmodifiableBag(Bag bag) {
  +    private UnmodifiableBag(Bag bag) {
           super(bag);
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to