commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r400286 - /jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java
Date Sat, 06 May 2006 11:17:30 GMT
Author: scolebourne
Date: Sat May  6 04:17:27 2006
New Revision: 400286

URL: http://svn.apache.org/viewcvs?rev=400286&view=rev
Log:
Javadoc and stylistic changes

Modified:
    jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java

Modified: jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java?rev=400286&r1=400285&r2=400286&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java
(original)
+++ jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/iterators/ListIteratorWrapper.java
Sat May  6 04:17:27 2006
@@ -21,34 +21,40 @@
 import java.util.NoSuchElementException;
 
 /**
- * As the wrapped Iterator is traversed, ListIteratorWrapper
- * builds a LinkedList of its values, permitting all required
- * operations of ListIterator.
- * 
+ * Converts an iterator into a list iterator by caching the returned entries.
+ * <p>
+ * The <code>ListIterator</code> interface has additional useful methods
+ * for navigation - <code>previous()</code> and the index methods.
+ * This class allows a regular <code>Iterator</code> to behave as a
+ * <code>ListIterator</code>. It achieves this by building a list internally
+ * of as the underlying iterator is traversed.
+ * <p>
+ * The optional operations of <code>ListIterator</code> are not supported.
+ *
  * @since Commons Collections 2.1
  * @version $Revision$ $Date$
- * 
+ *
  * @author Morgan Delagrange
  * @author Stephen Colebourne
  */
 public class ListIteratorWrapper implements ListIterator {
 
-    /** Holds value of property "iterator" */
+    /** Message used when remove, set or add are called. */
+    private static final String UNSUPPORTED_OPERATION_MESSAGE =
+        "ListIteratorWrapper does not support optional operations of ListIterator.";
+
+    /** The underlying iterator being decorated. */
     private final Iterator iterator;
+    /** The list being used to cache the iterator. */
     private final LinkedList list = new LinkedList();
-    
-    // position of this iterator
+
+    /** The current index of this iterator. */
     private int currentIndex = 0;
-    // position of the wrapped iterator
-    // this Iterator should only be used to populate the list
+    /** The current index of the wrapped iterator. */
     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.
@@ -66,49 +72,45 @@
 
     // ListIterator interface
     //-------------------------------------------------------------------------
-
     /**
-     *  Throws {@link UnsupportedOperationException}.
+     * Throws {@link UnsupportedOperationException}.
      *
-     *  @param o  ignored
-     *  @throws UnsupportedOperationException always
+     * @param obj  the object to add, ignored
+     * @throws UnsupportedOperationException always
      */
-    public void add(Object o) throws UnsupportedOperationException {
+    public void add(Object obj) throws UnsupportedOperationException {
         throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
     }
 
-
     /**
-     *  Returns true if there are more elements in the iterator.
+     * Returns true if there are more elements in the iterator.
      *
-     *  @return true if there are more elements
+     * @return true if there are more elements
      */
     public boolean hasNext() {
         if (currentIndex == wrappedIteratorIndex) {
             return iterator.hasNext();
         }
-
         return true;
     }
 
     /**
-     *  Returns true if there are previous elements in the iterator.
+     * Returns true if there are previous elements in the iterator.
      *
-     *  @return true if there are previous elements
+     * @return true if there are previous elements
      */
     public boolean hasPrevious() {
         if (currentIndex == 0) {
             return false;
         }
-
         return true;
     }
 
     /**
-     *  Returns the next element from the iterator.
+     * Returns the next element from the iterator.
      *
-     *  @return the next element from the iterator
-     *  @throws NoSuchElementException if there are no more elements
+     * @return the next element from the iterator
+     * @throws NoSuchElementException if there are no more elements
      */
     public Object next() throws NoSuchElementException {
         if (currentIndex < wrappedIteratorIndex) {
@@ -124,56 +126,54 @@
     }
 
     /**
-     *  Returns in the index of the next element.
+     * Returns in the index of the next element.
      *
-     *  @return the index of the next element
+     * @return the index of the next element
      */
     public int nextIndex() {
         return currentIndex;
     }
 
     /**
-     *  Returns the the previous element.
+     * Returns the the previous element.
      *
-     *  @return the previous element
-     *  @throws NoSuchElementException  if there are no previous elements
+     * @return the previous element
+     * @throws NoSuchElementException  if there are no previous elements
      */
     public Object previous() throws NoSuchElementException {
         if (currentIndex == 0) {
             throw new NoSuchElementException();
         }
-
         --currentIndex;
         return list.get(currentIndex);    
     }
 
     /**
-     *  Returns the index of the previous element.
+     * Returns the index of the previous element.
      *
-     *  @return  the index of the previous element
+     * @return  the index of the previous element
      */
     public int previousIndex() {
         return currentIndex - 1;
     }
 
     /**
-     *  Throws {@link UnsupportedOperationException}.
+     * Throws {@link UnsupportedOperationException}.
      *
-     *  @throws UnsupportedOperationException always
+     * @throws UnsupportedOperationException always
      */
     public void remove() throws UnsupportedOperationException {
         throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
     }
 
     /**
-     *  Throws {@link UnsupportedOperationException}.
+     * Throws {@link UnsupportedOperationException}.
      *
-     *  @param o  ignored
-     *  @throws UnsupportedOperationException always
+     * @param obj  the object to set, ignored
+     * @throws UnsupportedOperationException always
      */
-    public void set(Object o) throws UnsupportedOperationException {
+    public void set(Object obj) throws UnsupportedOperationException {
         throw new UnsupportedOperationException(UNSUPPORTED_OPERATION_MESSAGE);
     }
 
 }
-



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


Mime
View raw message