JML

org.jmlspecs.jmlunit.strategies
Class ObjectArrayAbstractIterator

java.lang.Object
  extended byorg.jmlspecs.jmlunit.strategies.ObjectArrayAbstractIterator
All Implemented Interfaces:
Cloneable, IndefiniteIterator
Direct Known Subclasses:
CloneableObjectArrayAbstractIterator, ImmutableObjectArrayIterator

public abstract class ObjectArrayAbstractIterator
extends Object
implements IndefiniteIterator

An indefinite iterator that provides test data from an array of objects passed to its constructor.

This can only handle iterations up to Integer.MAX_VALUE elements.

Author:
Gary T. Leavens

Field Summary
private  Object[] elems
          The elements
private  int next
          The next element's index (zero based)
 
Constructor Summary
ObjectArrayAbstractIterator(Object[] elems)
          Initialize this iterator to iterate over a clone of the array
 
Method Summary
 void advance()
          Advance the state of this iteration to the next position.
 boolean atEnd()
          Is this iterator at its end?
 Object clone()
          Return a copy of this iterator in the same state as this object.
protected abstract  Object duplicateIfNeeded(Object elem)
          Duplicate the argument if needed.
protected  String elementsString()
           
 Object get()
          Return the current element in this iteration.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

next

private int next
The next element's index (zero based)


elems

private Object[] elems
The elements

Constructor Detail

ObjectArrayAbstractIterator

public ObjectArrayAbstractIterator(Object[] elems)
Initialize this iterator to iterate over a clone of the array

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

duplicateIfNeeded

protected abstract Object duplicateIfNeeded(Object elem)
Duplicate the argument if needed. This is a hook for subclasses.

Parameters:
elem - the object to perhaps be duplicated, which may be null

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 Object clone()
Description copied from interface: IndefiniteIterator
Return a copy of this iterator in the same state as this object.

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

toString

public String toString()
Overrides:
toString in class Object

elementsString

protected String elementsString()

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.