You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/04/29 23:51:51 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util Enumerator.java

remm        2003/04/29 14:51:51

  Modified:    catalina/src/share/org/apache/catalina/util Enumerator.java
  Log:
  - Clone the iterator in Session.getAttributeNames to allow the (common)
    cleanup use case (bug 19103). IMO it is more a spec bug, but ...
  - Submitted by Tim Funk <funkman at joedog.org>
  
  Revision  Changes    Path
  1.2       +55 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/Enumerator.java
  
  Index: Enumerator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/Enumerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Enumerator.java	18 Jul 2002 16:47:45 -0000	1.1
  +++ Enumerator.java	29 Apr 2003 21:51:51 -0000	1.2
  @@ -68,6 +68,8 @@
   import java.util.Collection;
   import java.util.Enumeration;
   import java.util.Iterator;
  +import java.util.List;
  +import java.util.LinkedList;
   import java.util.Map;
   import java.util.NoSuchElementException;
   
  @@ -101,6 +103,19 @@
   
   
       /**
  +     * Return an Enumeration over the values of the specified Collection.
  +     *
  +     * @param collection Collection whose values should be enumerated
  +     * @param clone true to clone iterator
  +     */
  +    public Enumerator(Collection collection, boolean clone) {
  +
  +        this(collection.iterator(), clone);
  +
  +    }
  +
  +
  +    /**
        * Return an Enumeration over the values returned by the
        * specified Iterator.
        *
  @@ -115,6 +130,29 @@
   
   
       /**
  +     * Return an Enumeration over the values returned by the
  +     * specified Iterator.
  +     *
  +     * @param iterator Iterator to be wrapped
  +     * @param clone true to clone iterator
  +     */
  +    public Enumerator(Iterator iterator, boolean clone) {
  +
  +        super();
  +        if (clone) {
  +            this.iterator = iterator;
  +        } else {
  +            List list = new LinkedList();
  +            while(iterator.hasNext()) {
  +                list.add(iterator.next());
  +            }
  +            this.iterator = list.iterator();   
  +        }
  +
  +    }
  +
  +
  +    /**
        * Return an Enumeration over the values of the specified Map.
        *
        * @param map Map whose values should be enumerated
  @@ -122,6 +160,19 @@
       public Enumerator(Map map) {
   
           this(map.values().iterator());
  +
  +    }
  +
  +
  +    /**
  +     * Return an Enumeration over the values of the specified Map.
  +     *
  +     * @param map Map whose values should be enumerated
  +     * @param clone true to clone iterator
  +     */
  +    public Enumerator(Map map, boolean clone) {
  +
  +        this(map.values().iterator(), clone);
   
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org