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

Class Specifications

Specifications inherited from class Object
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT;
public represents _getClass <- \typeof(this);

Model Field Summary
 
Model fields inherited from class java.lang.Object
_getClass, objectState, theString
 
Ghost Field Summary
 
Ghost fields inherited from class java.lang.Object
objectTimesFinalized, owner
 
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()
           
 
Model Method Summary
 
Model methods inherited from class java.lang.Object
hashValue
 
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?

Specifications:
is in groups: objectState

cursor

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

Specifications:
is in groups: objectState
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
Specifications:
assignable objectState;

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
Specifications inherited from overridden method in interface IndefiniteIterator:
public normal_behavior
assignable objectState;

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
Specifications: pure
Specifications inherited from overridden method in interface IndefiniteIterator:
       pure

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
Specifications: pure nullable
Specifications inherited from overridden method in interface IndefiniteIterator:
       pure nullable
public behavior
assignable \nothing;
ensures_redundantly this.atEnd() == \old(this.atEnd());
signals (java.lang.Exception e) e instanceof java.util.NoSuchElementException&&this.atEnd();

make

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

Specifications: pure nullable
public behavior
requires 0 <= n;
assignable \nothing;
signals_only java.util.NoSuchElementException;

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
Specifications: (inherited)pure
Specifications inherited from overridden method in class Object:
       non_null
protected normal_behavior
requires this instanceof java.lang.Cloneable;
assignable \nothing;
ensures \result != null;
ensures \typeof(\result ) == \typeof(this);
ensures (* \result is a clone of this *);
     also
protected normal_behavior
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
     also
requires this.getClass().isArray();
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures java.lang.reflect.Array.getLength(\result ) == java.lang.reflect.Array.getLength(this);
ensures ( \forall int i; 0 <= i&&i < java.lang.reflect.Array.getLength(this); ( \exists java.lang.Object result_i; result_i == java.lang.reflect.Array.get(\result ,i); (result_i == null&&java.lang.reflect.Array.get(this,i) == null)||(result_i != null&&result_i.equals(java.lang.reflect.Array.get(this,i)))));
     also
protected exceptional_behavior
requires !(this instanceof java.lang.Cloneable);
assignable \nothing;
signals_only java.lang.CloneNotSupportedException;
     also
protected normal_behavior
requires \elemtype(\typeof(this)) <: \type(java.lang.Object);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((java.lang.Object[])\result ).length == ((java.lang.Object[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((java.lang.Object[])this).length; ((java.lang.Object[])\result )[i] == ((java.lang.Object[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(int);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((int[])\result ).length == ((int[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((int[])this).length; ((int[])\result )[i] == ((int[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(byte);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((byte[])\result ).length == ((byte[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((byte[])this).length; ((byte[])\result )[i] == ((byte[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(char);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((char[])\result ).length == ((char[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((char[])this).length; ((char[])\result )[i] == ((char[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(long);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((long[])\result ).length == ((long[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((long[])this).length; ((long[])\result )[i] == ((long[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(short);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((short[])\result ).length == ((short[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((short[])this).length; ((short[])\result )[i] == ((short[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(boolean);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((boolean[])\result ).length == ((boolean[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((boolean[])this).length; ((boolean[])\result )[i] == ((boolean[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(float);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((float[])\result ).length == ((float[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((float[])this).length; (java.lang.Float.isNaN(((float[])\result )[i])&&java.lang.Float.isNaN(((float[])this)[i]))||((float[])\result )[i] == ((float[])this)[i]);
     also
protected normal_behavior
requires \elemtype(\typeof(this)) == \type(double);
assignable \nothing;
ensures \elemtype(\typeof(\result )) == \elemtype(\typeof(this));
ensures ((double[])\result ).length == ((double[])this).length;
ensures ( \forall int i; 0 <= i&&i < ((double[])this).length; (java.lang.Double.isNaN(((double[])\result )[i])&&java.lang.Double.isNaN(((double[])this)[i]))||((double[])\result )[i] == ((double[])this)[i]);
Specifications inherited from overridden method in interface IndefiniteIterator:
       pure
     also
public normal_behavior
assignable \nothing;
ensures \fresh(\result )&&\result instanceof org.jmlspecs.jmlunit.strategies.IndefiniteIterator;
ensures \result != this;
ensures_redundantly \result != null;
ensures ((org.jmlspecs.jmlunit.strategies.IndefiniteIterator)\result ).atEnd() == this.atEnd();

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.