JML

org.jmlspecs.jmlunit.strategies
Class NewObjectAbstractIterator

java.lang.Object
  extended byorg.jmlspecs.jmlunit.strategies.NewObjectAbstractIterator
All Implemented Interfaces:
Cloneable, IndefiniteIterator
Direct Known Subclasses:
EmptyNewObjectIterator, NewObjectAbstractExtensibleStrategyDecorator.NewObjectAbstractExtensibleStrategyDecorator$1.NewIter, NewObjectAbstractIterator_JML_TestData.NewObjectAbstractIterator_JML_TestData$2.NewObjectAbstractIterator_JML_TestData$2$1, NewObjectAbstractIterator_JML_TestData.NewObjectAbstractIterator_JML_TestData$2.NewObjectAbstractIterator_JML_TestData$2$2, NewObjectAbstractStrategy.NewObjectAbstractStrategy$1

public abstract class NewObjectAbstractIterator
extends Object
implements IndefiniteIterator

An iterator that provides test data by creating (in general) the objects each time the get() method is called. The idea is to track a number for what item to return, and to pass that to a "make" method which creates the required object, or throws an exception if there are no more.

If you want to have aliasing, arrange it so that the same object is returned multiple times by the get() method.

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

Author:
Gary T. Leavens

Field Summary
private  boolean atEnd
          Is this iteration at it's end?
private  int cursor
          The number of the current data item to return.
 
Constructor Summary
NewObjectAbstractIterator()
           
 
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.
 Object get()
          Return the current element in this iteration.
 void initialize()
          Initialize this iterator.
abstract  Object make(int n)
          Return the nth test data item.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

atEnd

private boolean atEnd
Is this iteration at it's end?


cursor

private int cursor
The number of the current data item to return.

Constructor Detail

NewObjectAbstractIterator

public NewObjectAbstractIterator()
Method Detail

initialize

public void initialize()
Initialize this iterator. This must be called if the iterator can start off at its end, which is unusual but possible.

See Also:
NewObjectAbstractStrategy

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

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

make

public abstract Object make(int n)
Return the nth test data item.


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

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.