JML

org.jmlspecs.jmlunit.strategies
Class IteratorAbstractAdapter

java.lang.Object
  extended byorg.jmlspecs.jmlunit.strategies.IteratorAbstractAdapter
All Implemented Interfaces:
Cloneable, IndefiniteIterator

public abstract class IteratorAbstractAdapter
extends Object
implements IndefiniteIterator

Make a java.util.Iterator into an IndefiniteIterator.

Author:
Gary T. Leavens

Field Summary
private  boolean atEnd
           
private  Object item
           
private  Iterator iter
          The underlying iterator
 
Constructor Summary
IteratorAbstractAdapter(Iterator iter)
          Initialize this indefinite iterator to iterate over the elements that iter iterates over.
 
Method Summary
 void advance()
          Advance the state of this iteration to the next position.
 boolean atEnd()
          Is this iterator at its end?
abstract  Object clone()
          Return a clone of this iterator adapter, which contains a clone of the underlying iterator.
protected abstract  Iterator cloneIterator(Iterator iter)
          Return a clone of the argument iterator
 Object get()
          Return the current element in this iteration.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iter

private Iterator iter
The underlying iterator


atEnd

private boolean atEnd

item

private Object item
Constructor Detail

IteratorAbstractAdapter

public IteratorAbstractAdapter(Iterator iter)
Initialize this indefinite iterator to iterate over the elements that iter iterates over.

Method Detail

atEnd

public boolean atEnd()
Description copied from interface: IndefiniteIterator
Is this iterator at its end? That is, if we called get(), would it throw an exception?

Specified by:
atEnd in interface IndefiniteIterator

get

public Object get()
Description copied from interface: IndefiniteIterator
Return the current element in this iteration. This method may be called multiple times, and does not advance the state of the iterator when it is called. The idea is to permit several similar copies to be returned (e.g., clones) each time it is called.

Specified by:
get in interface IndefiniteIterator

advance

public void advance()
Description copied from interface: IndefiniteIterator
Advance the state of this iteration to the next position. Note that this never throws an exception.

Specified by:
advance in interface IndefiniteIterator

clone

public abstract Object clone()
Return a clone of this iterator adapter, which contains a clone of the underlying iterator. This has to be done by subclasses.

Specified by:
clone in interface IndefiniteIterator
Overrides:
clone in class Object

cloneIterator

protected abstract Iterator cloneIterator(Iterator iter)
Return a clone of the argument iterator


JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.