commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/iterators ListIteratorWrapper.java
Date Sat, 17 Aug 2002 11:33:09 GMT
scolebourne    2002/08/17 04:33:09

  Modified:    collections/src/java/org/apache/commons/collections/iterators
                        ListIteratorWrapper.java
  Log:
  Added extra null validation
  
  Revision  Changes    Path
  1.2       +26 -25    jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java
  
  Index: ListIteratorWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ListIteratorWrapper.java	15 Aug 2002 23:13:51 -0000	1.1
  +++ ListIteratorWrapper.java	17 Aug 2002 11:33:09 -0000	1.2
  @@ -64,28 +64,45 @@
   import java.util.LinkedList;
   import java.util.ListIterator;
   import java.util.NoSuchElementException;
  -
   /**
    * As the wrapped Iterator is traversed, ListIteratorWrapper
    * builds a LinkedList of its values, permitting all required
    * operations of ListIterator.
    * 
  - * @author Morgan Delagrange
  - * @version $Revision$ $Date$
    * @since 2.1
  + * @author Morgan Delagrange
  + * @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
  + * @version $Id$
    */
   public class ListIteratorWrapper implements ListIterator {
   
  +    /** Holds value of property "iterator" */
  +    private final Iterator iterator;
  +    private final LinkedList list = new LinkedList();
  +    
  +    // position of this iterator
  +    private int currentIndex = 0;
  +    // position of the wrapped iterator
  +    // this Iterator should only be used to populate the list
  +    private int wrappedIteratorIndex = 0;
  +
  +    private static final String UNSUPPORTED_OPERATION_MESSAGE =
  +        "ListIteratorWrapper does not support optional operations of ListIterator.";
  +
       // Constructor
       //-------------------------------------------------------------------------
   
       /**
  -     *  Constructs a new <Code>ListIteratorWrapper</Code> that will wrap
  -     *  the given iterator.
  +     * Constructs a new <Code>ListIteratorWrapper</Code> that will wrap
  +     * the given iterator.
        *
  -     *  @param iterator  the iterator to wrap
  +     * @param iterator  the iterator to wrap
  +     * @throws NullPointerException if the iterator is null
        */
       public ListIteratorWrapper(Iterator iterator) {
  +        if (iterator == null) {
  +            throw new NullPointerException("Iterator must not be null");
  +        }
           this.iterator = iterator;
       }
   
  @@ -199,22 +216,6 @@
       public void set(Object o) throws UnsupportedOperationException {
           throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
       }
  -
  -    // Attributes
  -    //-------------------------------------------------------------------------
  -
  -    /** Holds value of property "iterator". */
  -    private Iterator iterator = null;
  -    private LinkedList list = new LinkedList();
  -    
  -    // position of this iterator
  -    private int currentIndex = 0;
  -    // position of the wrapped iterator
  -    // this Iterator should only be used to populate the list
  -    private int wrappedIteratorIndex = 0;
  -
  -    private static final String UNSUPPORTED_OPERATION_MESSAGE =
  -        "ListIteratorWrapper does not support optional operations of ListIterator.";
   
   }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message