JML

org.jmlspecs.jmlunit.strategies
Class ShortCompositeIterator

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

public class ShortCompositeIterator
extends ShortAbstractIterator

Composition of several ShortIterators.

Author:
Gary T. Leavens
See Also:
ShortIterator

Class Specifications
public invariant 0 <= this.currentIterator&&this.currentIterator <= this.iters.length;
public invariant \nonnullelements(this.iters);
public invariant ( \forall int i; 0 <= i&&i < this.currentIterator; this.iters[i].atEnd());
public constraint ( \forall int i; 0 <= i&&i < this.iters.length; this.iters[i] == \old(this.iters[i]));

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
[spec_public] private  int currentIterator
          What iterator we are working with now.
[spec_public] private  ShortIterator[] iters
          The iterators that are being sequenced
 
Constructor Summary
protected ShortCompositeIterator(int currentIterator, non_null ShortIterator[] iters)
          Initialize this composite to iterate over clones of the given iterators, in order, starting at the given current iterator.
  ShortCompositeIterator(non_null ShortIterator iter)
          Initialize this composite to iterate over the given iterator.
  ShortCompositeIterator(non_null ShortIterator iter1, non_null ShortIterator iter2)
          Initialize this composite to iterate over the given iterators, in order.
  ShortCompositeIterator(non_null ShortIterator[] iters)
          Initialize this composite to iterate over clones of the given iterators, in order.
 
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.
 short getShort()
          Return the next element in this iteration.
private  void setCurrentIterator()
          Set the current iterator to the next one that has elements, if any.
 String toString()
           
 
Methods inherited from class org.jmlspecs.jmlunit.strategies.ShortAbstractIterator
get
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentIterator

private int currentIterator
What iterator we are working with now.

Specifications: spec_public
is in groups: objectState

iters

private final ShortIterator[] iters
The iterators that are being sequenced

Specifications: spec_public non_null
is in groups: objectState
maps iters[*].objectState \into objectState
Constructor Detail

ShortCompositeIterator

public ShortCompositeIterator(non_null ShortIterator iter)
Initialize this composite to iterate over the given iterator.

Specifications:
assignable iters, currentIterator, owner;
ensures (* this.iters is a deep clone of new ShortIterator[] {iter} *);
ensures this.owner == null;

ShortCompositeIterator

public ShortCompositeIterator(non_null ShortIterator iter1,
                              non_null ShortIterator iter2)
Initialize this composite to iterate over the given iterators, in order.

Specifications:
assignable iters, currentIterator, owner;
ensures (* this.iters is a deep clone of new IndefiniteIterator[] {iter1, iter2} *);
ensures this.owner == null;

ShortCompositeIterator

public ShortCompositeIterator(non_null ShortIterator[] iters)
Initialize this composite to iterate over clones of the given iterators, in order.

Specifications:
requires \nonnullelements(iters);
assignable this.iters, currentIterator, owner;
ensures (* this.iters is a deep clone of iters *);
ensures this.iters != iters;
ensures this.iters.length == iters.length;
ensures ( \forall int i; 0 <= i&&i < iters.length; this.iters[i] != iters[i]&&this.iters[i].atEnd() == iters[i].atEnd()&&(!this.iters[i].atEnd() ==> new java.lang.Short(this.iters[i].getShort()).equals(new java.lang.Short(iters[i].getShort()))));
ensures this.owner == null;

ShortCompositeIterator

protected ShortCompositeIterator(int currentIterator,
                                 non_null ShortIterator[] iters)
Initialize this composite to iterate over clones of the given iterators, in order, starting at the given current iterator.

Specifications:
requires 0 <= currentIterator&&currentIterator <= iters.length;
requires ( \forall int i; 0 <= i&&i < currentIterator; iters[i].atEnd());
requires \nonnullelements(iters);
assignable this.iters, this.currentIterator, owner;
ensures (* this.iters is a deep clone of iters *);
ensures this.iters != iters;
ensures this.iters.length == iters.length;
ensures ( \forall int i; 0 <= i&&i < iters.length; this.iters[i] != iters[i]&&this.iters[i].atEnd() == iters[i].atEnd()&&(!this.iters[i].atEnd() ==> new java.lang.Short(this.iters[i].getShort()).equals(new java.lang.Short(iters[i].getShort()))));
ensures this.currentIterator == currentIterator;
ensures this.owner == null;
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?

Specifications: (inherited)pure
Specifications inherited from overridden method in interface IndefiniteIterator:
       pure

getShort

public short getShort()
               throws NoSuchElementException
Return the next element in this iteration.

Throws:
NoSuchElementException;
NoSuchElementException
Specifications: pure
     also
public behavior
assignable \nothing;
signals_only java.util.NoSuchElementException;
Specifications inherited from overridden method in interface ShortIterator:
       pure
public behavior
assignable \nothing;
ensures_redundantly this.atEnd() == \old(this.atEnd());
signals_only java.util.NoSuchElementException;
signals (java.util.NoSuchElementException) \old(this.atEnd());

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.

Specifications inherited from overridden method in interface IndefiniteIterator:
public normal_behavior
assignable objectState;

setCurrentIterator

private void setCurrentIterator()
Set the current iterator to the next one that has elements, if any.

Specifications:
assignable currentIterator;

clone

public Object clone()
Description copied from interface: ShortIterator
Return a copy of this iterator in the same state as this object.

Specified by:
clone in interface ShortIterator
Overrides:
clone in class ShortAbstractIterator
Specifications: non_null (inherited)pure
Specifications inherited from overridden method in class ShortAbstractIterator:
       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 ShortIterator:
       pure
     also
public normal_behavior
assignable \nothing;
ensures \fresh(\result )&&\result instanceof org.jmlspecs.jmlunit.strategies.ShortIterator;
ensures \result != this;
ensures_redundantly \result != null;
ensures ((org.jmlspecs.jmlunit.strategies.ShortIterator)\result ).atEnd() == this.atEnd();
ensures !this.atEnd() ==> new java.lang.Short(((org.jmlspecs.jmlunit.strategies.ShortIterator)\result ).getShort()).equals(new java.lang.Short(this.getShort()));
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();

toString

public String toString()
Overrides:
toString in class Object
Specifications: non_null
Specifications inherited from overridden method in class Object:
       non_null
public normal_behavior
assignable objectState;
ensures \result != null&&\result .equals(this.theString);
ensures (* \result is a string representation of this object *);
     also
public code normal_behavior
assignable \nothing;
ensures \result != null&&(* \result is the instance's class name, followed by an @, followed by the instance's hashcode in hex *);
     also
public code model_program { ... }
    implies_that
assignable objectState;
ensures \result != null;

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.