org.jcoderz.commons.util
Class SerializableIterator

java.lang.Object
  extended by org.jcoderz.commons.util.SerializableIterator
All Implemented Interfaces:
Serializable, Iterator

public final class SerializableIterator
extends Object
implements Iterator, Serializable

Provides a serializable iterator over a collection (which may be either a Collection or an array of Objects. The remove() operation is not supported in this implementation. NOTE: It is the caller's responsibility to ensure that all objects in the arguments passed to the factory methods are serializable. The implementation does not check this.

Author:
Albrecht Messner
See Also:
Serialized Form

Method Summary
static SerializableIterator fromArray(Object[] array)
          Construct a new iterator from the given array.
static SerializableIterator fromCollection(Collection collection)
          Construct a new iterator from the given collection.
 boolean hasNext()
          
 Object next()
          
 void remove()
          This operation is not supported in this implementation.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

fromCollection

public static SerializableIterator fromCollection(Collection collection)
Construct a new iterator from the given collection. All elements of the collection will be copied to an internal list.

Parameters:
collection - the collection for which an iterator should be created. All elements in the collection must be serializable.
Returns:
a serializable iterator over the given collection

fromArray

public static SerializableIterator fromArray(Object[] array)
Construct a new iterator from the given array. All elements of the array will be copied to an internal list.

Parameters:
array - the object array for which an iterator should be created. All elements in the array must be serializable.
Returns:
a new iterator from the given array.

remove

public void remove()
            throws UnsupportedOperationException
This operation is not supported in this implementation.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - whenever this method is called.
See Also:
Iterator.remove()

hasNext

public boolean hasNext()

Specified by:
hasNext in interface Iterator

next

public Object next()

Specified by:
next in interface Iterator

toString

public String toString()

Overrides:
toString in class Object


Copyright 2007 The jCoderZ Project.