Remove trailing spaces.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1477802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
810250d722
commit
7d54ee797c
|
@ -18,14 +18,14 @@ package org.apache.commons.collections4.iterators;
|
|||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provides an implementation of an empty iterator.
|
||||
*
|
||||
* @since 3.1
|
||||
* @version $Id$
|
||||
*/
|
||||
abstract class AbstractEmptyIterator<E> {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.commons.collections4.iterators;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provides an implementation of an empty map iterator.
|
||||
*
|
||||
* @since 4.0
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AbstractListIteratorDecorator<E> implements ListIterator<E> {
|
|||
|
||||
/**
|
||||
* Gets the iterator being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated iterator
|
||||
*/
|
||||
protected ListIterator<E> getListIterator() {
|
||||
|
@ -56,7 +56,7 @@ public class AbstractListIteratorDecorator<E> implements ListIterator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean hasNext() {
|
||||
return iterator.hasNext();
|
||||
|
@ -101,5 +101,5 @@ public class AbstractListIteratorDecorator<E> implements ListIterator<E> {
|
|||
public void add(final E obj) {
|
||||
iterator.add(obj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AbstractMapIteratorDecorator<K, V> implements MapIterator<K, V> {
|
|||
|
||||
/**
|
||||
* Gets the iterator being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated iterator
|
||||
*/
|
||||
protected MapIterator<K, V> getMapIterator() {
|
||||
|
@ -56,7 +56,7 @@ public class AbstractMapIteratorDecorator<K, V> implements MapIterator<K, V> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean hasNext() {
|
||||
return iterator.hasNext();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AbstractOrderedMapIteratorDecorator<K, V> implements OrderedMapIter
|
|||
|
||||
/**
|
||||
* Gets the iterator being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated iterator
|
||||
*/
|
||||
protected OrderedMapIterator<K, V> getOrderedMapIterator() {
|
||||
|
@ -56,7 +56,7 @@ public class AbstractOrderedMapIteratorDecorator<K, V> implements OrderedMapIter
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean hasNext() {
|
||||
return iterator.hasNext();
|
||||
|
@ -81,7 +81,7 @@ public class AbstractOrderedMapIteratorDecorator<K, V> implements OrderedMapIter
|
|||
public void remove() {
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public K getKey() {
|
||||
return iterator.getKey();
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class AbstractUntypedIteratorDecorator<I, O> implements Iterator
|
|||
|
||||
/**
|
||||
* Create a new AbstractUntypedIteratorDecorator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to decorate
|
||||
*/
|
||||
protected AbstractUntypedIteratorDecorator(final Iterator<I> iterator) {
|
||||
|
@ -47,7 +47,7 @@ public abstract class AbstractUntypedIteratorDecorator<I, O> implements Iterator
|
|||
|
||||
/**
|
||||
* Gets the iterator being decorated.
|
||||
*
|
||||
*
|
||||
* @return the decorated iterator
|
||||
*/
|
||||
protected Iterator<I> getIterator() {
|
||||
|
|
|
@ -21,15 +21,15 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Implements an {@link java.util.Iterator Iterator} over any array.
|
||||
* <p>
|
||||
* The array can be either an array of object or of primitives. If you know
|
||||
* that you have an object array, the
|
||||
* The array can be either an array of object or of primitives. If you know
|
||||
* that you have an object array, the
|
||||
* {@link org.apache.commons.collections4.iterators.ObjectArrayIterator ObjectArrayIterator}
|
||||
* class is a better choice, as it will perform better.
|
||||
* <p>
|
||||
* The iterator implements a {@link #reset} method, allowing the reset of
|
||||
* The iterator implements a {@link #reset} method, allowing the reset of
|
||||
* the iterator back to the start if required.
|
||||
*
|
||||
* @since 1.0
|
||||
|
@ -39,7 +39,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
|
||||
// TODO Privatise fields? Mainly read-only access
|
||||
|
||||
/** The array to iterate over */
|
||||
/** The array to iterate over */
|
||||
protected Object array;
|
||||
/** The start index to loop from */
|
||||
protected int startIndex = 0;
|
||||
|
@ -47,7 +47,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
protected int endIndex = 0;
|
||||
/** The current iterator index */
|
||||
protected int index = 0;
|
||||
|
||||
|
||||
// Constructors
|
||||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
public ArrayIterator() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an ArrayIterator that will iterate over the values in the
|
||||
* specified array.
|
||||
|
@ -92,7 +92,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Construct an ArrayIterator that will iterate over a range of values
|
||||
* Construct an ArrayIterator that will iterate over a range of values
|
||||
* in the specified array.
|
||||
*
|
||||
* @param array the array to iterate over.
|
||||
|
@ -117,7 +117,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
|
||||
/**
|
||||
* Checks whether the index is valid or not.
|
||||
*
|
||||
*
|
||||
* @param bound the index to check
|
||||
* @param type the index type (for error messages)
|
||||
* @throws IndexOutOfBoundsException if the index is invalid
|
||||
|
@ -175,7 +175,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
// Properties
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets the array that this iterator is iterating over.
|
||||
* Gets the array that this iterator is iterating over.
|
||||
*
|
||||
* @return the array this iterator iterates over, or <code>null</code> if
|
||||
* the no-arg constructor was used and {@link #setArray(Object)} has never
|
||||
|
@ -184,7 +184,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
public Object getArray() {
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the array that the ArrayIterator should iterate over.
|
||||
* <p>
|
||||
|
@ -209,7 +209,7 @@ public class ArrayIterator<E> implements ResettableIterator<E> {
|
|||
this.array = array;
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the iterator back to the start index.
|
||||
*/
|
||||
|
|
|
@ -23,14 +23,14 @@ import java.util.NoSuchElementException;
|
|||
import org.apache.commons.collections4.ResettableListIterator;
|
||||
|
||||
/**
|
||||
* Implements a {@link ListIterator} over an array.
|
||||
* Implements a {@link ListIterator} over an array.
|
||||
* <p>
|
||||
* The array can be either an array of object or of primitives. If you know
|
||||
* The array can be either an array of object or of primitives. If you know
|
||||
* that you have an object array, the {@link ObjectArrayListIterator}
|
||||
* class is a better choice, as it will perform better.
|
||||
*
|
||||
* <p>
|
||||
* This iterator does not support {@link #add(Object)} or {@link #remove()}, as the array
|
||||
* This iterator does not support {@link #add(Object)} or {@link #remove()}, as the array
|
||||
* cannot be changed in size. The {@link #set(Object)} method is supported however.
|
||||
*
|
||||
* @see org.apache.commons.collections4.iterators.ArrayIterator
|
||||
|
@ -46,7 +46,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
/**
|
||||
* Holds the index of the last item returned by a call to <code>next()</code>
|
||||
* or <code>previous()</code>. This is set to <code>-1</code> if neither method
|
||||
* has yet been invoked. <code>lastItemIndex</code> is used to to implement
|
||||
* has yet been invoked. <code>lastItemIndex</code> is used to to implement
|
||||
* the {@link #set} method.
|
||||
*
|
||||
*/
|
||||
|
@ -92,7 +92,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
}
|
||||
|
||||
/**
|
||||
* Construct an ArrayListIterator that will iterate over a range of values
|
||||
* Construct an ArrayListIterator that will iterate over a range of values
|
||||
* in the specified array.
|
||||
*
|
||||
* @param array the array to iterate over
|
||||
|
@ -121,7 +121,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the previous element from the array.
|
||||
*
|
||||
*
|
||||
* @return the previous element
|
||||
* @throws NoSuchElementException if there is no previous element
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the next element from the array.
|
||||
*
|
||||
*
|
||||
* @return the next element
|
||||
* @throws NoSuchElementException if there is no next element
|
||||
*/
|
||||
|
@ -152,7 +152,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the next index to be retrieved.
|
||||
*
|
||||
*
|
||||
* @return the index of the item to be retrieved next
|
||||
*/
|
||||
public int nextIndex() {
|
||||
|
@ -161,7 +161,7 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the index of the item to be retrieved if {@link #previous()} is called.
|
||||
*
|
||||
*
|
||||
* @return the index of the item to be retrieved next
|
||||
*/
|
||||
public int previousIndex() {
|
||||
|
@ -183,8 +183,8 @@ public class ArrayListIterator<E> extends ArrayIterator<E>
|
|||
/**
|
||||
* Sets the element under the cursor.
|
||||
* <p>
|
||||
* This method sets the element that was returned by the last call
|
||||
* to {@link #next()} of {@link #previous()}.
|
||||
* This method sets the element that was returned by the last call
|
||||
* to {@link #next()} of {@link #previous()}.
|
||||
* <p>
|
||||
* <b>Note:</b> {@link ListIterator} implementations that support
|
||||
* <code>add()</code> and <code>remove()</code> only allow <code>set()</code> to be called
|
||||
|
|
|
@ -75,7 +75,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* Constructs a new <code>CollatingIterator</code> that will used the
|
||||
* specified comparator for ordering. Child iterators will have to be
|
||||
* manually added using the {@link #addIterator(Iterator)} method.
|
||||
*
|
||||
*
|
||||
* @param comp the comparator to use to sort; must not be null,
|
||||
* unless you'll be invoking {@link #setComparator(Comparator)}
|
||||
* later on.
|
||||
|
@ -89,7 +89,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* specified comparator for ordering and have the specified initial
|
||||
* capacity. Child iterators will have to be manually added using the
|
||||
* {@link #addIterator(Iterator)} method.
|
||||
*
|
||||
*
|
||||
* @param comp the comparator to use to sort; must not be null,
|
||||
* unless you'll be invoking {@link #setComparator(Comparator)}
|
||||
* later on.
|
||||
|
@ -105,7 +105,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* Constructs a new <code>CollatingIterator</code> that will use the
|
||||
* specified comparator to provide ordered iteration over the two given
|
||||
* iterators.
|
||||
*
|
||||
*
|
||||
* @param comp the comparator to use to sort; must not be null,
|
||||
* unless you'll be invoking {@link #setComparator(Comparator)}
|
||||
* later on.
|
||||
|
@ -124,7 +124,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* Constructs a new <code>CollatingIterator</code> that will use the
|
||||
* specified comparator to provide ordered iteration over the array of
|
||||
* iterators.
|
||||
*
|
||||
*
|
||||
* @param comp the comparator to use to sort; must not be null,
|
||||
* unless you'll be invoking {@link #setComparator(Comparator)}
|
||||
* later on.
|
||||
|
@ -142,7 +142,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* Constructs a new <code>CollatingIterator</code> that will use the
|
||||
* specified comparator to provide ordered iteration over the collection of
|
||||
* iterators.
|
||||
*
|
||||
*
|
||||
* @param comp the comparator to use to sort; must not be null,
|
||||
* unless you'll be invoking {@link #setComparator(Comparator)}
|
||||
* later on.
|
||||
|
@ -163,7 +163,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
// ----------------------------------------------------------------------
|
||||
/**
|
||||
* Adds the given {@link Iterator} to the iterators being collated.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to add to the collation, must not be null
|
||||
* @throws IllegalStateException if iteration has started
|
||||
* @throws NullPointerException if the iterator is null
|
||||
|
@ -178,7 +178,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Sets the iterator at the given index.
|
||||
*
|
||||
*
|
||||
* @param index index of the Iterator to replace
|
||||
* @param iterator Iterator to place at the given index
|
||||
* @throws IndexOutOfBoundsException if index < 0 or index > size()
|
||||
|
@ -195,7 +195,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Gets the list of Iterators (unmodifiable).
|
||||
*
|
||||
*
|
||||
* @return the unmodifiable list of iterators added
|
||||
*/
|
||||
public List<Iterator<? extends E>> getIterators() {
|
||||
|
@ -204,7 +204,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Gets the {@link Comparator} by which collatation occurs.
|
||||
*
|
||||
*
|
||||
* @return the {@link Comparator}
|
||||
*/
|
||||
public Comparator<? super E> getComparator() {
|
||||
|
@ -217,7 +217,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* if the elements in the iterators are implementing the
|
||||
* {@link java.lang.Comparable} interface), then use the
|
||||
* {@link org.apache.commons.collections4.comparators.ComparableComparator}.
|
||||
*
|
||||
*
|
||||
* @param comp the {@link Comparator} to set
|
||||
* @throws IllegalStateException if iteration has started
|
||||
*/
|
||||
|
@ -230,7 +230,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
// -------------------------------------------------------------------
|
||||
/**
|
||||
* Returns <code>true</code> if any child iterator has remaining elements.
|
||||
*
|
||||
*
|
||||
* @return true if this iterator has remaining elements
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -240,7 +240,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Returns the next ordered element from a child iterator.
|
||||
*
|
||||
*
|
||||
* @return the next ordered element
|
||||
* @throws NoSuchElementException if no child iterator has any more elements
|
||||
*/
|
||||
|
@ -261,7 +261,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
/**
|
||||
* Removes the last returned element from the child iterator that produced
|
||||
* it.
|
||||
*
|
||||
*
|
||||
* @throws IllegalStateException if there is no last returned element, or if
|
||||
* the last returned element has already been removed
|
||||
*/
|
||||
|
@ -274,7 +274,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Returns the index of the iterator that returned the last element.
|
||||
*
|
||||
*
|
||||
* @return the index of the iterator that returned the last element
|
||||
* @throws IllegalStateException if there is no last returned element
|
||||
*/
|
||||
|
@ -282,10 +282,10 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
if (lastReturned == -1) {
|
||||
throw new IllegalStateException("No value has been returned yet");
|
||||
}
|
||||
|
||||
|
||||
return lastReturned;
|
||||
}
|
||||
|
||||
|
||||
// Private Methods
|
||||
// -------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -307,7 +307,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
* <i>i</i> to the next value of the {@link #iterators iterator} at position
|
||||
* <i>i</i>, or clear them if the <i>i</i><sup>th</sup> iterator has no next
|
||||
* value.
|
||||
*
|
||||
*
|
||||
* @return <tt>false</tt> iff there was no value to set
|
||||
*/
|
||||
private boolean set(final int i) {
|
||||
|
@ -334,7 +334,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
/**
|
||||
* Throws {@link IllegalStateException} if iteration has started via
|
||||
* {@link #start}.
|
||||
*
|
||||
*
|
||||
* @throws IllegalStateException if iteration started
|
||||
*/
|
||||
private void checkNotStarted() throws IllegalStateException {
|
||||
|
@ -346,7 +346,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
|||
/**
|
||||
* Returns the index of the least element in {@link #values},
|
||||
* {@link #set(int) setting} any uninitialized values.
|
||||
*
|
||||
*
|
||||
* @throws NullPointerException if no comparator is set
|
||||
*/
|
||||
private int least() {
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provides an implementation of an empty iterator.
|
||||
* <p>
|
||||
* This class provides an implementation of an empty iterator.
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.collections4.iterators;
|
|||
import org.apache.commons.collections4.MapIterator;
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provides an implementation of an empty map iterator.
|
||||
*
|
||||
* @since 3.1
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.collections4.iterators;
|
|||
import org.apache.commons.collections4.OrderedIterator;
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provides an implementation of an empty ordered iterator.
|
||||
*
|
||||
* @since 3.1
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.collections4.iterators;
|
|||
import org.apache.commons.collections4.OrderedMapIterator;
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provides an implementation of an empty ordered map iterator.
|
||||
*
|
||||
* @since 3.1
|
||||
|
|
|
@ -33,20 +33,20 @@ import org.apache.commons.collections4.ResettableIterator;
|
|||
* it.setValue(newValue);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableIterator<K> {
|
||||
|
||||
|
||||
private final Map<K, V> map;
|
||||
private Iterator<Map.Entry<K, V>> iterator;
|
||||
private Map.Entry<K, V> last;
|
||||
private boolean canRemove = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*
|
||||
* @param map the map to iterate over
|
||||
*/
|
||||
public EntrySetMapIterator(final Map<K, V> map) {
|
||||
|
@ -55,7 +55,7 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
|
|||
this.iterator = map.entrySet().iterator();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Checks to see if there are more entries still to be iterated.
|
||||
*
|
||||
|
@ -96,7 +96,7 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
|
|||
last = null;
|
||||
canRemove = false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Gets the current key, which is the key returned by the last call
|
||||
|
@ -152,12 +152,12 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
|
|||
last = null;
|
||||
canRemove = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the iterator as a String.
|
||||
*
|
||||
*
|
||||
* @return a string version of the iterator
|
||||
*/
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (last != null) {
|
||||
|
@ -165,5 +165,5 @@ public class EntrySetMapIterator<K, V> implements MapIterator<K, V>, ResettableI
|
|||
}
|
||||
return "MapIterator[]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Collection;
|
|||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Adapter to make {@link Enumeration Enumeration} instances appear
|
||||
* to be {@link Iterator Iterator} instances.
|
||||
*
|
||||
|
@ -28,14 +28,14 @@ import java.util.Iterator;
|
|||
* @version $Id$
|
||||
*/
|
||||
public class EnumerationIterator<E> implements Iterator<E> {
|
||||
|
||||
|
||||
/** The collection to remove elements from */
|
||||
private final Collection<? super E> collection;
|
||||
/** The enumeration being converted */
|
||||
private Enumeration<? extends E> enumeration;
|
||||
/** The last object retrieved */
|
||||
private E last;
|
||||
|
||||
|
||||
// Constructors
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -134,5 +134,5 @@ public class EnumerationIterator<E> implements Iterator<E> {
|
|||
public void setEnumeration(final Enumeration<? extends E> enumeration) {
|
||||
this.enumeration = enumeration;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.collections4.Predicate;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates another {@link Iterator} using a predicate to filter elements.
|
||||
* <p>
|
||||
* This iterator decorates the underlying iterator, only allowing through
|
||||
|
@ -75,8 +75,8 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the underlying iterator contains an object that
|
||||
/**
|
||||
* Returns true if the underlying iterator contains an object that
|
||||
* matches the predicate.
|
||||
*
|
||||
* @return true if there is another object that matches the predicate
|
||||
|
@ -86,13 +86,13 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
return nextObjectSet || setNextObject();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the next object that matches the predicate.
|
||||
*
|
||||
* @return the next object which matches the given predicate
|
||||
* @throws NullPointerException if either the iterator or predicate are null
|
||||
* @throws NoSuchElementException if there are no more elements that
|
||||
* match the predicate
|
||||
* match the predicate
|
||||
*/
|
||||
public E next() {
|
||||
if (!nextObjectSet) {
|
||||
|
@ -123,7 +123,7 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
/**
|
||||
* Gets the iterator this iterator is using.
|
||||
*
|
||||
* @return the iterator
|
||||
|
@ -132,7 +132,7 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
return iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the iterator for this iterator to use.
|
||||
* If iteration has started, this effectively resets the iterator.
|
||||
*
|
||||
|
@ -145,7 +145,7 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
/**
|
||||
* Gets the predicate this iterator is using.
|
||||
*
|
||||
* @return the predicate
|
||||
|
@ -154,7 +154,7 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
return predicate;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the predicate this the iterator to use.
|
||||
*
|
||||
* @param predicate the predicate to use
|
||||
|
@ -167,7 +167,7 @@ public class FilterIterator<E> implements Iterator<E> {
|
|||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Set nextObject to the next object. If there are no more
|
||||
* Set nextObject to the next object. If there are no more
|
||||
* objects then return false. Otherwise, return true.
|
||||
*/
|
||||
private boolean setNextObject() {
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.collections4.Predicate;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates another {@link ListIterator} using a predicate to filter elements.
|
||||
* <p>
|
||||
* This iterator decorates the underlying iterator, only allowing through
|
||||
|
@ -34,39 +34,39 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
|
||||
/** The iterator being used */
|
||||
private ListIterator<? extends E> iterator;
|
||||
|
||||
|
||||
/** The predicate being used */
|
||||
private Predicate<? super E> predicate;
|
||||
|
||||
/**
|
||||
* The value of the next (matching) object, when
|
||||
* {@link #nextObjectSet} is true.
|
||||
/**
|
||||
* The value of the next (matching) object, when
|
||||
* {@link #nextObjectSet} is true.
|
||||
*/
|
||||
private E nextObject;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Whether or not the {@link #nextObject} has been set
|
||||
* (possibly to <code>null</code>).
|
||||
* (possibly to <code>null</code>).
|
||||
*/
|
||||
private boolean nextObjectSet = false;
|
||||
private boolean nextObjectSet = false;
|
||||
|
||||
/**
|
||||
* The value of the previous (matching) object, when
|
||||
* {@link #previousObjectSet} is true.
|
||||
/**
|
||||
* The value of the previous (matching) object, when
|
||||
* {@link #previousObjectSet} is true.
|
||||
*/
|
||||
private E previousObject;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Whether or not the {@link #previousObject} has been set
|
||||
* (possibly to <code>null</code>).
|
||||
* (possibly to <code>null</code>).
|
||||
*/
|
||||
private boolean previousObjectSet = false;
|
||||
private boolean previousObjectSet = false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The index of the element that would be returned by {@link #next}.
|
||||
*/
|
||||
private int nextIndex = 0;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructs a new <code>FilterListIterator</code> that will not function
|
||||
|
@ -78,7 +78,7 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <code>FilterListIterator</code> that will not
|
||||
* Constructs a new <code>FilterListIterator</code> that will not
|
||||
* function until {@link #setPredicate(Predicate) setPredicate} is invoked.
|
||||
*
|
||||
* @param iterator the iterator to use
|
||||
|
@ -168,19 +168,19 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
/**
|
||||
* Gets the iterator this iterator is using.
|
||||
*
|
||||
*
|
||||
* @return the iterator.
|
||||
*/
|
||||
public ListIterator<? extends E> getListIterator() {
|
||||
return iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the iterator for this iterator to use.
|
||||
* If iteration has started, this effectively resets the iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to use
|
||||
*/
|
||||
public void setListIterator(final ListIterator<? extends E> iterator) {
|
||||
|
@ -188,18 +188,18 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
/**
|
||||
* Gets the predicate this iterator is using.
|
||||
*
|
||||
*
|
||||
* @return the predicate.
|
||||
*/
|
||||
public Predicate<? super E> getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the predicate this the iterator to use.
|
||||
*
|
||||
*
|
||||
* @param predicate the transformer to use
|
||||
*/
|
||||
public void setPredicate(final Predicate<? super E> predicate) {
|
||||
|
@ -214,7 +214,7 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
|
||||
private boolean setNextObject() {
|
||||
// if previousObjectSet,
|
||||
// then we've walked back one step in the
|
||||
// then we've walked back one step in the
|
||||
// underlying list (due to a hasPrevious() call)
|
||||
// so skip ahead one matching object
|
||||
if (previousObjectSet) {
|
||||
|
@ -246,7 +246,7 @@ public class FilterListIterator<E> implements ListIterator<E> {
|
|||
|
||||
private boolean setPreviousObject() {
|
||||
// if nextObjectSet,
|
||||
// then we've walked back one step in the
|
||||
// then we've walked back one step in the
|
||||
// underlying list (due to a hasNext() call)
|
||||
// so skip ahead one matching object
|
||||
if (nextObjectSet) {
|
||||
|
|
|
@ -88,7 +88,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
* <p>
|
||||
* You will normally use {@link #addIterator(Iterator)} to add some more
|
||||
* iterators after using this constructor.
|
||||
*
|
||||
*
|
||||
* @param iterator the first child iterator in the IteratorChain, not null
|
||||
* @throws NullPointerException if the iterator is null
|
||||
*/
|
||||
|
@ -102,7 +102,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
* <p>
|
||||
* This method takes two iterators. The newly constructed iterator will
|
||||
* iterate through each one of the input iterators in turn.
|
||||
*
|
||||
*
|
||||
* @param first the first child iterator in the IteratorChain, not null
|
||||
* @param second the second child iterator in the IteratorChain, not null
|
||||
* @throws NullPointerException if either iterator is null
|
||||
|
@ -118,7 +118,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
* <p>
|
||||
* This method takes an array of iterators. The newly constructed iterator
|
||||
* will iterate through each one of the input iterators in turn.
|
||||
*
|
||||
*
|
||||
* @param iteratorChain the array of iterators, not null
|
||||
* @throws NullPointerException if iterators array is or contains null
|
||||
*/
|
||||
|
@ -135,7 +135,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
* <p>
|
||||
* This method takes a collection of iterators. The newly constructed
|
||||
* iterator will iterate through each one of the input iterators in turn.
|
||||
*
|
||||
*
|
||||
* @param iteratorChain the collection of iterators, not null
|
||||
* @throws NullPointerException if iterators collection is or contains null
|
||||
* @throws ClassCastException if iterators collection doesn't contain an
|
||||
|
@ -151,7 +151,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Add an Iterator to the end of the chain
|
||||
*
|
||||
*
|
||||
* @param iterator Iterator to add
|
||||
* @throws IllegalStateException if I've already started iterating
|
||||
* @throws NullPointerException if the iterator is null
|
||||
|
@ -166,7 +166,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Set the Iterator at the given index
|
||||
*
|
||||
*
|
||||
* @param index index of the Iterator to replace
|
||||
* @param iterator Iterator to place at the given index
|
||||
* @throws IndexOutOfBoundsException if index < 0 or index > size()
|
||||
|
@ -184,7 +184,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Get the list of Iterators (unmodifiable)
|
||||
*
|
||||
*
|
||||
* @return the unmodifiable list of iterators added
|
||||
*/
|
||||
public List<Iterator<? extends E>> getIterators() {
|
||||
|
@ -193,7 +193,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Number of Iterators in the current IteratorChain.
|
||||
*
|
||||
*
|
||||
* @return Iterator count
|
||||
*/
|
||||
public int size() {
|
||||
|
@ -204,7 +204,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
* Determine if modifications can still be made to the IteratorChain.
|
||||
* IteratorChains cannot be modified once they have executed a method from
|
||||
* the Iterator interface.
|
||||
*
|
||||
*
|
||||
* @return true if IteratorChain cannot be modified, false if it can
|
||||
*/
|
||||
public boolean isLocked() {
|
||||
|
@ -257,7 +257,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Return true if any Iterator in the IteratorChain has a remaining element.
|
||||
*
|
||||
*
|
||||
* @return true if elements remain
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -270,7 +270,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Returns the next Object of the current Iterator
|
||||
*
|
||||
*
|
||||
* @return Object from the current Iterator
|
||||
* @throws java.util.NoSuchElementException if all the Iterators are
|
||||
* exhausted
|
||||
|
@ -289,7 +289,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
|||
* underlying Iterator. Therefore, this method may throw an
|
||||
* UnsupportedOperationException if the underlying Iterator does not support
|
||||
* this method.
|
||||
*
|
||||
*
|
||||
* @throws UnsupportedOperationException if the remove operator is not
|
||||
* supported by the underlying Iterator
|
||||
* @throws IllegalStateException if the next method has not yet been called,
|
||||
|
|
|
@ -42,7 +42,7 @@ public class IteratorEnumeration<E> implements Enumeration<E> {
|
|||
/**
|
||||
* Constructs a new <code>IteratorEnumeration</code> that will use the given
|
||||
* iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to use
|
||||
*/
|
||||
public IteratorEnumeration(final Iterator<? extends E> iterator) {
|
||||
|
@ -55,7 +55,7 @@ public class IteratorEnumeration<E> implements Enumeration<E> {
|
|||
|
||||
/**
|
||||
* Returns true if the underlying iterator has more elements.
|
||||
*
|
||||
*
|
||||
* @return true if the underlying iterator has more elements
|
||||
*/
|
||||
public boolean hasMoreElements() {
|
||||
|
@ -64,7 +64,7 @@ public class IteratorEnumeration<E> implements Enumeration<E> {
|
|||
|
||||
/**
|
||||
* Returns the next element from the underlying iterator.
|
||||
*
|
||||
*
|
||||
* @return the next element from the underlying iterator.
|
||||
* @throws java.util.NoSuchElementException if the underlying iterator has
|
||||
* no more elements
|
||||
|
@ -78,7 +78,7 @@ public class IteratorEnumeration<E> implements Enumeration<E> {
|
|||
|
||||
/**
|
||||
* Returns the underlying iterator.
|
||||
*
|
||||
*
|
||||
* @return the underlying iterator
|
||||
*/
|
||||
public Iterator<? extends E> getIterator() {
|
||||
|
@ -87,7 +87,7 @@ public class IteratorEnumeration<E> implements Enumeration<E> {
|
|||
|
||||
/**
|
||||
* Sets the underlying iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the new underlying iterator
|
||||
*/
|
||||
public void setIterator(final Iterator<? extends E> iterator) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.collections4.ResettableIterator;
|
|||
* Adapter to make an {@link Iterator Iterator} instance appear to be an
|
||||
* {@link Iterable Iterable} instance. The iterable can be constructed in one
|
||||
* of two variants: single use, multiple use.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* In the single use iterable case, the iterable is only usable for one
|
||||
* iterative operation over the source iterator. Subsequent iterative
|
||||
|
@ -33,7 +33,7 @@ import org.apache.commons.collections4.ResettableIterator;
|
|||
* Iterable<Integer> iterable = new IteratorIterable<Integer>(iterator);
|
||||
* </pre>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* In the multiple use iterable case, the iterable is usable for any number of
|
||||
* iterative operations over the source iterator. Of special note, even though
|
||||
|
@ -46,7 +46,7 @@ import org.apache.commons.collections4.ResettableIterator;
|
|||
* Iterable<Integer> iterable = new IteratorIterable<Integer>(iterator);
|
||||
* </pre>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* A multiple use iterable can also be explicitly constructed using any
|
||||
* {@link Iterator} and specifying <code>true</code> for the
|
||||
|
@ -56,7 +56,7 @@ import org.apache.commons.collections4.ResettableIterator;
|
|||
* Iterable<Integer> iterable = new IteratorIterable<Integer>(iterator, true);
|
||||
* </pre>
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
* @version $Id$
|
||||
*/
|
||||
|
@ -85,14 +85,14 @@ public class IteratorIterable<E> implements Iterable<E> {
|
|||
|
||||
/** the iterator being adapted into an iterable. */
|
||||
private final Iterator<? extends E> iterator;
|
||||
|
||||
/** the iterator parameterized as the {@link #iterator()} return type. */
|
||||
|
||||
/** the iterator parameterized as the {@link #iterator()} return type. */
|
||||
private final Iterator<E> typeSafeIterator;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>IteratorIterable</code> that will use the given
|
||||
* iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to use.
|
||||
*/
|
||||
public IteratorIterable(final Iterator<? extends E> iterator) {
|
||||
|
@ -102,14 +102,14 @@ public class IteratorIterable<E> implements Iterable<E> {
|
|||
/**
|
||||
* Constructs a new <code>IteratorIterable</code> that will use the given
|
||||
* iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to use.
|
||||
* @param multipleUse <code>true</code> if the new iterable can be used in multiple iterations
|
||||
*/
|
||||
public IteratorIterable(final Iterator<? extends E> iterator, final boolean multipleUse) {
|
||||
super();
|
||||
if (multipleUse && !(iterator instanceof ResettableIterator)) {
|
||||
this.iterator = new ListIteratorWrapper<E>(iterator);
|
||||
this.iterator = new ListIteratorWrapper<E>(iterator);
|
||||
} else {
|
||||
this.iterator = iterator;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ public class IteratorIterable<E> implements Iterable<E> {
|
|||
|
||||
/**
|
||||
* Gets the iterator wrapped by this iterable.
|
||||
*
|
||||
*
|
||||
* @return the iterator
|
||||
*/
|
||||
public Iterator<E> iterator() {
|
||||
|
|
|
@ -105,7 +105,7 @@ public abstract class LazyIteratorChain<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Return true if any Iterator in the chain has a remaining element.
|
||||
*
|
||||
*
|
||||
* @return true if elements remain
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -117,14 +117,14 @@ public abstract class LazyIteratorChain<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Returns the next element of the current Iterator
|
||||
*
|
||||
*
|
||||
* @return element from the current Iterator
|
||||
* @throws java.util.NoSuchElementException if all the Iterators are exhausted
|
||||
*/
|
||||
public E next() {
|
||||
updateCurrentIterator();
|
||||
lastUsedIterator = currentIterator;
|
||||
|
||||
|
||||
return currentIterator.next();
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ public abstract class LazyIteratorChain<E> implements Iterator<E> {
|
|||
* As with next() and hasNext(), this method calls remove() on the underlying Iterator.
|
||||
* Therefore, this method may throw an UnsupportedOperationException if the underlying
|
||||
* Iterator does not support this method.
|
||||
*
|
||||
*
|
||||
* @throws UnsupportedOperationException if the remove operator is not
|
||||
* supported by the underlying Iterator
|
||||
* @throws IllegalStateException if the next method has not yet been called,
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections4.ResettableListIterator;
|
|||
/**
|
||||
* Converts an {@link Iterator} into a {@link ResettableListIterator}.
|
||||
* For plain <code>Iterator</code>s this is accomplished by caching the returned
|
||||
* elements. This class can also be used to simply add
|
||||
* elements. This class can also be used to simply add
|
||||
* {@link org.apache.commons.collections4.ResettableIterator ResettableIterator}
|
||||
* functionality to a given {@link ListIterator}.
|
||||
* <p>
|
||||
|
|
|
@ -25,18 +25,18 @@ import org.apache.commons.collections4.ResettableIterator;
|
|||
/**
|
||||
* An Iterator that restarts when it reaches the end.
|
||||
* <p>
|
||||
* The iterator will loop continuously around the provided elements, unless
|
||||
* The iterator will loop continuously around the provided elements, unless
|
||||
* there are no elements in the collection to begin with, or all the elements
|
||||
* have been {@link #remove removed}.
|
||||
* <p>
|
||||
* Concurrent modifications are not directly supported, and for most collection
|
||||
* implementations will throw a ConcurrentModificationException.
|
||||
* implementations will throw a ConcurrentModificationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
*/
|
||||
public class LoopingIterator<E> implements ResettableIterator<E> {
|
||||
|
||||
|
||||
/** The collection to base the iterator on */
|
||||
private final Collection<? extends E> collection;
|
||||
/** The current iterator */
|
||||
|
@ -47,7 +47,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
|
|||
* <p>
|
||||
* There is no way to reset an Iterator instance without recreating it from
|
||||
* the original source, so the Collection must be passed in.
|
||||
*
|
||||
*
|
||||
* @param coll the collection to wrap
|
||||
* @throws NullPointerException if the collection is null
|
||||
*/
|
||||
|
@ -59,12 +59,12 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
|
|||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Has the iterator any more elements.
|
||||
* <p>
|
||||
* Returns false only if the collection originally had zero elements, or
|
||||
* all the elements have been {@link #remove removed}.
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> if there are more elements
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -75,7 +75,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
|
|||
* Returns the next object in the collection.
|
||||
* <p>
|
||||
* If at the end of the collection, return the first element.
|
||||
*
|
||||
*
|
||||
* @return the next object
|
||||
* @throws NoSuchElementException if there are no elements
|
||||
* at all. Use {@link #hasNext} to avoid this error.
|
||||
|
@ -93,8 +93,8 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
|
|||
/**
|
||||
* Removes the previously retrieved item from the underlying collection.
|
||||
* <p>
|
||||
* This feature is only supported if the underlying collection's
|
||||
* {@link Collection#iterator iterator} method returns an implementation
|
||||
* This feature is only supported if the underlying collection's
|
||||
* {@link Collection#iterator iterator} method returns an implementation
|
||||
* that supports it.
|
||||
* <p>
|
||||
* This method can only be called after at least one {@link #next} method call.
|
||||
|
@ -115,7 +115,7 @@ public class LoopingIterator<E> implements ResettableIterator<E> {
|
|||
|
||||
/**
|
||||
* Gets the size of the collection underlying the iterator.
|
||||
*
|
||||
*
|
||||
* @return the current collection size
|
||||
*/
|
||||
public int size() {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class NodeListIterator implements Iterator<Node> {
|
|||
private int index = 0;
|
||||
|
||||
/**
|
||||
* Convenience constructor, which creates a new NodeListIterator from
|
||||
* Convenience constructor, which creates a new NodeListIterator from
|
||||
* the specified node's childNodes.
|
||||
*
|
||||
* @param node Node, who's child nodes are wrapped by this class. Must not be null
|
||||
|
@ -64,7 +64,7 @@ public class NodeListIterator implements Iterator<Node> {
|
|||
}
|
||||
this.nodeList = nodeList;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNext() {
|
||||
return nodeList == null ? false : index < nodeList.getLength();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
/**
|
||||
* An {@link Iterator} over an array of objects.
|
||||
* <p>
|
||||
* This iterator does not support {@link #remove}, as the object array cannot be
|
||||
|
@ -82,7 +82,7 @@ public class ObjectArrayIterator<E>
|
|||
}
|
||||
|
||||
/**
|
||||
* Construct an ObjectArrayIterator that will iterate over a range of values
|
||||
* Construct an ObjectArrayIterator that will iterate over a range of values
|
||||
* in the specified array.
|
||||
*
|
||||
* @param array the array to iterate over
|
||||
|
@ -151,7 +151,7 @@ public class ObjectArrayIterator<E>
|
|||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets the array that this iterator is iterating over.
|
||||
* Gets the array that this iterator is iterating over.
|
||||
*
|
||||
* @return the array this iterator iterates over, or <code>null</code> if
|
||||
* the no-arg constructor was used and {@link #setArray} has never
|
||||
|
@ -185,7 +185,7 @@ public class ObjectArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the start index to loop from.
|
||||
*
|
||||
*
|
||||
* @return the start index
|
||||
*/
|
||||
public int getStartIndex() {
|
||||
|
@ -194,7 +194,7 @@ public class ObjectArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the end index to loop to.
|
||||
*
|
||||
*
|
||||
* @return the end index
|
||||
*/
|
||||
public int getEndIndex() {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.collections4.ResettableListIterator;
|
|||
/**
|
||||
* Implements a {@link ListIterator} over an array of objects.
|
||||
* <p>
|
||||
* This iterator does not support {@link #add} or {@link #remove}, as the object array
|
||||
* This iterator does not support {@link #add} or {@link #remove}, as the object array
|
||||
* cannot be structurally modified. The {@link #set} method is supported however.
|
||||
* <p>
|
||||
* The iterator implements a {@link #reset} method, allowing the reset of the iterator
|
||||
|
@ -41,7 +41,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
implements ListIterator<E>, ResettableListIterator<E> {
|
||||
|
||||
/**
|
||||
* Holds the index of the last item returned by a call to <code>next()</code>
|
||||
* Holds the index of the last item returned by a call to <code>next()</code>
|
||||
* or <code>previous()</code>. This is set to <code>-1</code> if neither method
|
||||
* has yet been invoked. <code>lastItemIndex</code> is used to to implement the
|
||||
* {@link #set} method.
|
||||
|
@ -81,9 +81,9 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
public ObjectArrayListIterator(final E[] array, final int start) {
|
||||
super(array, start);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct an ObjectArrayListIterator that will iterate over a range of values
|
||||
* Construct an ObjectArrayListIterator that will iterate over a range of values
|
||||
* in the specified array.
|
||||
*
|
||||
* @param array the array to iterate over
|
||||
|
@ -111,7 +111,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the previous element from the array.
|
||||
*
|
||||
*
|
||||
* @return the previous element
|
||||
* @throws NoSuchElementException if there is no previous element
|
||||
*/
|
||||
|
@ -125,7 +125,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the next element from the array.
|
||||
*
|
||||
*
|
||||
* @return the next element
|
||||
* @throws NoSuchElementException if there is no next element
|
||||
*/
|
||||
|
@ -140,7 +140,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the next index to be retrieved.
|
||||
*
|
||||
*
|
||||
* @return the index of the item to be retrieved next
|
||||
*/
|
||||
public int nextIndex() {
|
||||
|
@ -149,7 +149,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
|
||||
/**
|
||||
* Gets the index of the item to be retrieved if {@link #previous()} is called.
|
||||
*
|
||||
*
|
||||
* @return the index of the item to be retrieved next
|
||||
*/
|
||||
public int previousIndex() {
|
||||
|
@ -170,16 +170,16 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
|||
/**
|
||||
* Sets the element under the cursor.
|
||||
* <p>
|
||||
* This method sets the element that was returned by the last call
|
||||
* to {@link #next()} of {@link #previous()}.
|
||||
*
|
||||
* This method sets the element that was returned by the last call
|
||||
* to {@link #next()} of {@link #previous()}.
|
||||
*
|
||||
* <b>Note:</b> {@link ListIterator} implementations that support <code>add()</code>
|
||||
* and <code>remove()</code> only allow <code>set()</code> to be called once per call
|
||||
* and <code>remove()</code> only allow <code>set()</code> to be called once per call
|
||||
* to <code>next()</code> or <code>previous</code> (see the {@link ListIterator}
|
||||
* javadoc for more details). Since this implementation does not support
|
||||
* javadoc for more details). Since this implementation does not support
|
||||
* <code>add()</code> or <code>remove()</code>, <code>set()</code> may be
|
||||
* called as often as desired.
|
||||
*
|
||||
*
|
||||
* @param obj the object to set into the array
|
||||
* @throws IllegalStateException if next() has not yet been called.
|
||||
* @throws ClassCastException if the object type is unsuitable for the array
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
* <p>
|
||||
* The root object can be an iterator, in which case it will be immediately
|
||||
* looped around.
|
||||
*
|
||||
*
|
||||
* @param root the root object, null will result in an empty iterator
|
||||
* @param transformer the transformer to use, null will use a no effect transformer
|
||||
*/
|
||||
|
@ -120,7 +120,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
* be used to iterate over nested iterators. That is to say that the iterator
|
||||
* passed in here contains other iterators, which may in turn contain further
|
||||
* iterators.
|
||||
*
|
||||
*
|
||||
* @param rootIterator the root iterator, null will result in an empty iterator
|
||||
*/
|
||||
public ObjectGraphIterator(final Iterator<? extends E> rootIterator) {
|
||||
|
@ -155,7 +155,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Finds the next object in the iteration given any start object.
|
||||
*
|
||||
*
|
||||
* @param value the value to start from
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -169,10 +169,10 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
hasNext = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the next object in the iteration given an iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to start from
|
||||
*/
|
||||
protected void findNextByIterator(final Iterator<? extends E> iterator) {
|
||||
|
@ -183,7 +183,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
}
|
||||
currentIterator = iterator;
|
||||
}
|
||||
|
||||
|
||||
while (currentIterator.hasNext() && hasNext == false) {
|
||||
E next = currentIterator.next();
|
||||
if (transformer != null) {
|
||||
|
@ -202,7 +202,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Checks whether there are any more elements in the iteration to obtain.
|
||||
*
|
||||
*
|
||||
* @return true if elements remain in the iteration
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -212,7 +212,7 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
|
||||
/**
|
||||
* Gets the next element of the iteration.
|
||||
*
|
||||
*
|
||||
* @return the next element from the iteration
|
||||
* @throws NoSuchElementException if all the Iterators are exhausted
|
||||
*/
|
||||
|
@ -233,8 +233,8 @@ public class ObjectGraphIterator<E> implements Iterator<E> {
|
|||
* <p>
|
||||
* This method calls remove() on the underlying Iterator and it may
|
||||
* throw an UnsupportedOperationException if the underlying Iterator
|
||||
* does not support this method.
|
||||
*
|
||||
* does not support this method.
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* if the remove operator is not supported by the underlying Iterator
|
||||
* @throws IllegalStateException
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.NoSuchElementException;
|
|||
* {@code UnsupportedOperationException}.
|
||||
* <p>
|
||||
* NOTE: in case an empty collection is provided, the iterator will
|
||||
* return exactly one empty list as result, as 0! = 1.
|
||||
* return exactly one empty list as result, as 0! = 1.
|
||||
*
|
||||
* @param <E> the type of the objects being permuted
|
||||
*
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.collections4.ResettableIterator;
|
||||
|
||||
/**
|
||||
* <code>SingletonIterator</code> is an {@link Iterator} over a single
|
||||
/**
|
||||
* <code>SingletonIterator</code> is an {@link Iterator} over a single
|
||||
* object instance.
|
||||
*
|
||||
* @since 2.0
|
||||
|
@ -69,7 +69,7 @@ public class SingletonIterator<E>
|
|||
* Is another object available from the iterator?
|
||||
* <p>
|
||||
* This returns true if the single object hasn't been returned yet.
|
||||
*
|
||||
*
|
||||
* @return true if the single object hasn't been returned yet
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -82,7 +82,7 @@ public class SingletonIterator<E>
|
|||
* This returns the single object if it hasn't been returned yet.
|
||||
*
|
||||
* @return the single object
|
||||
* @throws NoSuchElementException if the single object has already
|
||||
* @throws NoSuchElementException if the single object has already
|
||||
* been returned
|
||||
*/
|
||||
public E next() {
|
||||
|
@ -95,7 +95,7 @@ public class SingletonIterator<E>
|
|||
|
||||
/**
|
||||
* Remove the object from this iterator.
|
||||
*
|
||||
*
|
||||
* @throws IllegalStateException if the <tt>next</tt> method has not
|
||||
* yet been called, or the <tt>remove</tt> method has already
|
||||
* been called after the last call to the <tt>next</tt>
|
||||
|
@ -114,12 +114,12 @@ public class SingletonIterator<E>
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the iterator to the start.
|
||||
*/
|
||||
public void reset() {
|
||||
beforeFirst = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.NoSuchElementException;
|
|||
import org.apache.commons.collections4.ResettableListIterator;
|
||||
|
||||
/**
|
||||
* <code>SingletonIterator</code> is an {@link ListIterator} over a single
|
||||
* <code>SingletonIterator</code> is an {@link ListIterator} over a single
|
||||
* object instance.
|
||||
*
|
||||
* @since 2.1
|
||||
|
@ -49,7 +49,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
* Is another object available from the iterator?
|
||||
* <p>
|
||||
* This returns true if the single object hasn't been returned yet.
|
||||
*
|
||||
*
|
||||
* @return true if the single object hasn't been returned yet
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
|
@ -60,7 +60,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
* Is a previous object available from the iterator?
|
||||
* <p>
|
||||
* This returns true if the single object has been returned.
|
||||
*
|
||||
*
|
||||
* @return true if the single object has been returned
|
||||
*/
|
||||
public boolean hasPrevious() {
|
||||
|
@ -71,7 +71,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
* Returns the index of the element that would be returned by a subsequent
|
||||
* call to <tt>next</tt>.
|
||||
*
|
||||
* @return 0 or 1 depending on current state.
|
||||
* @return 0 or 1 depending on current state.
|
||||
*/
|
||||
public int nextIndex() {
|
||||
return beforeFirst ? 0 : 1;
|
||||
|
@ -82,7 +82,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
* call to <tt>previous</tt>. A return value of -1 indicates that the iterator is currently at
|
||||
* the start.
|
||||
*
|
||||
* @return 0 or -1 depending on current state.
|
||||
* @return 0 or -1 depending on current state.
|
||||
*/
|
||||
public int previousIndex() {
|
||||
return beforeFirst ? -1 : 0;
|
||||
|
@ -94,7 +94,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
* This returns the single object if it hasn't been returned yet.
|
||||
*
|
||||
* @return the single object
|
||||
* @throws NoSuchElementException if the single object has already
|
||||
* @throws NoSuchElementException if the single object has already
|
||||
* been returned
|
||||
*/
|
||||
public E next() {
|
||||
|
@ -112,7 +112,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
* This returns the single object if it has been returned.
|
||||
*
|
||||
* @return the single object
|
||||
* @throws NoSuchElementException if the single object has not already
|
||||
* @throws NoSuchElementException if the single object has not already
|
||||
* been returned
|
||||
*/
|
||||
public E previous() {
|
||||
|
@ -125,8 +125,8 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
|
||||
/**
|
||||
* Remove the object from this iterator.
|
||||
* @throws IllegalStateException if the <tt>next</tt> or <tt>previous</tt>
|
||||
* method has not yet been called, or the <tt>remove</tt> method
|
||||
* @throws IllegalStateException if the <tt>next</tt> or <tt>previous</tt>
|
||||
* method has not yet been called, or the <tt>remove</tt> method
|
||||
* has already been called after the last call to <tt>next</tt>
|
||||
* or <tt>previous</tt>.
|
||||
*/
|
||||
|
@ -138,7 +138,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
removed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add always throws {@link UnsupportedOperationException}.
|
||||
*
|
||||
|
@ -148,12 +148,12 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
public void add(final E obj) {
|
||||
throw new UnsupportedOperationException("add() is not supported by this iterator");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set sets the value of the singleton.
|
||||
*
|
||||
* @param obj the object to set
|
||||
* @throws IllegalStateException if <tt>next</tt> has not been called
|
||||
* @throws IllegalStateException if <tt>next</tt> has not been called
|
||||
* or the object has been removed
|
||||
*/
|
||||
public void set(final E obj) {
|
||||
|
@ -162,7 +162,7 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
}
|
||||
this.object = obj;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the iterator back to the start.
|
||||
*/
|
||||
|
@ -170,5 +170,5 @@ public class SingletonListIterator<E> implements ListIterator<E>, ResettableList
|
|||
beforeFirst = true;
|
||||
nextCalled = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Iterator;
|
|||
|
||||
import org.apache.commons.collections4.Transformer;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates an iterator such that each element returned is transformed.
|
||||
*
|
||||
* @since 1.0
|
||||
|
@ -36,7 +36,7 @@ public class TransformIterator<I, O> implements Iterator<O> {
|
|||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructs a new <code>TransformIterator</code> that will not function
|
||||
* until the {@link #setIterator(Iterator) setIterator} and
|
||||
* until the {@link #setIterator(Iterator) setIterator} and
|
||||
* {@link #setTransformer(Transformer)} methods are invoked.
|
||||
*/
|
||||
public TransformIterator() {
|
||||
|
@ -78,7 +78,7 @@ public class TransformIterator<I, O> implements Iterator<O> {
|
|||
* Gets the next object from the iteration, transforming it using the
|
||||
* current transformer. If the transformer is null, no transformation
|
||||
* occurs and the object from the iterator is returned directly.
|
||||
*
|
||||
*
|
||||
* @return the next object
|
||||
* @throws java.util.NoSuchElementException if there are no more elements
|
||||
*/
|
||||
|
@ -91,19 +91,19 @@ public class TransformIterator<I, O> implements Iterator<O> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
/**
|
||||
* Gets the iterator this iterator is using.
|
||||
*
|
||||
*
|
||||
* @return the iterator.
|
||||
*/
|
||||
public Iterator<? extends I> getIterator() {
|
||||
return iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the iterator for this iterator to use.
|
||||
* If iteration has started, this effectively resets the iterator.
|
||||
*
|
||||
*
|
||||
* @param iterator the iterator to use
|
||||
*/
|
||||
public void setIterator(final Iterator<? extends I> iterator) {
|
||||
|
@ -111,19 +111,19 @@ public class TransformIterator<I, O> implements Iterator<O> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
/**
|
||||
* Gets the transformer this iterator is using.
|
||||
*
|
||||
*
|
||||
* @return the transformer.
|
||||
*/
|
||||
public Transformer<? super I, ? extends O> getTransformer() {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Sets the transformer this the iterator to use.
|
||||
* A null transformer is a no-op transformer.
|
||||
*
|
||||
*
|
||||
* @param transformer the transformer to use
|
||||
*/
|
||||
public void setTransformer(final Transformer<? super I, ? extends O> transformer) {
|
||||
|
|
|
@ -20,10 +20,10 @@ import java.util.Iterator;
|
|||
|
||||
import org.apache.commons.collections4.Unmodifiable;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates an iterator such that it cannot be modified.
|
||||
* <p>
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
|
|
|
@ -20,10 +20,10 @@ import java.util.ListIterator;
|
|||
|
||||
import org.apache.commons.collections4.Unmodifiable;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates a list iterator such that it cannot be modified.
|
||||
* <p>
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
|
@ -51,7 +51,7 @@ public final class UnmodifiableListIterator<E> implements ListIterator<E>, Unmod
|
|||
}
|
||||
return new UnmodifiableListIterator<E>(iterator);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
|
@ -19,10 +19,10 @@ package org.apache.commons.collections4.iterators;
|
|||
import org.apache.commons.collections4.MapIterator;
|
||||
import org.apache.commons.collections4.Unmodifiable;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decorates a map iterator such that it cannot be modified.
|
||||
* <p>
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.collections4.Unmodifiable;
|
|||
/**
|
||||
* Decorates an ordered map iterator such that it cannot be modified.
|
||||
* <p>
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
* Attempts to modify it will result in an UnsupportedOperationException.
|
||||
*
|
||||
* @since 3.0
|
||||
* @version $Id$
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* This package contains implementations of the
|
||||
* {@link java.util.Iterator Iterator} interface.
|
||||
* <p>
|
||||
* You may also consider using
|
||||
* You may also consider using
|
||||
* {@link org.apache.commons.collections4.IteratorUtils IteratorUtils},
|
||||
* which is a single class that uses static methods to construct instances
|
||||
* of the classes in this package.
|
||||
|
|
Loading…
Reference in New Issue