JML

org.jmlspecs.models
Class JMLEnumerationToIterator

java.lang.Object
  extended byorg.jmlspecs.models.JMLEnumerationToIterator
All Implemented Interfaces:
Cloneable, Iterator, JMLIterator, JMLType, Serializable

public class JMLEnumerationToIterator
extends Object
implements JMLIterator

A wrapper that makes any JMLEnumeration into a JMLIterator that does not support the remove operation.

Version:
$Revision: 1.27 $
Author:
Gary T. Leavens
See Also:
JMLEnumeration, JMLIterator, Iterator

Class Specifications
public represents moreElements <- this.theEnumeration.hasMoreElements();
public represents_redundantly moreElements <- this.theEnumeration.moreElements;

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

Specifications inherited from interface JMLIterator
instance public represents moreElements <- this.hasNext();

Specifications inherited from interface Iterator
public invariant this.moreElements == this.hasNext(0);

Model Field Summary
 
Model fields inherited from class java.lang.Object
_getClass, objectState, theString
 
Model fields inherited from interface java.util.Iterator
moreElements
 
Ghost Field Summary
 
Ghost fields inherited from class java.lang.Object
objectTimesFinalized, owner
 
Ghost fields inherited from interface java.util.Iterator
elementType, remove_called_since, returnsNull
 
Field Summary
[spec_public] protected  JMLEnumeration theEnumeration
           
 
Constructor Summary
JMLEnumerationToIterator(non_null JMLEnumeration e)
          Initialize this iterator with the given Enumeration.
 
Model Method Summary
 
Model methods inherited from class java.lang.Object
hashValue
 
Model methods inherited from interface java.util.Iterator
hasNext, nthNextElement
 
Method Summary
 Object clone()
          Return a clone of this iterator.
 boolean equals(nullable Object oth)
          Return true just when this iterator has the same state as the given argument.
 int hashCode()
          Return a hash code for this iterator.
 boolean hasNext()
          Tells whether this has more uniterated elements.
 Object next()
          Return the next element in this, if there is one.
 void remove()
          The remove operation is not supported in this type.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theEnumeration

protected final JMLEnumeration theEnumeration
Specifications: spec_public non_null
maps theEnumeration.objectState \into objectState
Constructor Detail

JMLEnumerationToIterator

public JMLEnumerationToIterator(non_null JMLEnumeration e)
Initialize this iterator with the given Enumeration. The enumeration is cloned.

Specifications: pure
public normal_behavior
requires e != null;
assignable owner, theEnumeration, elementType, moreElements;
assignable returnsNull;
ensures this.theEnumeration.equals(e);
ensures this.owner == null;
Method Detail

hasNext

public boolean hasNext()
Tells whether this has more uniterated elements.

Specified by:
hasNext in interface JMLIterator
Specifications: pure
     also
public normal_behavior
ensures \result == this.theEnumeration.moreElements;
ensures_redundantly \result == this.theEnumeration.moreElements;
Specifications inherited from overridden method in interface JMLIterator:
       pure
     also
assignable \nothing;
Specifications inherited from overridden method in interface Iterator:
public normal_behavior
assignable objectState;
ensures \result <==> this.moreElements;

next

public Object next()
            throws JMLNoSuchElementException
Return the next element in this, if there is one.

Specified by:
next in interface Iterator
Throws:
JMLNoSuchElementException - when this is empty.
Specifications:
     also
public normal_behavior
requires this.moreElements;
requires_redundantly this.hasNext();
assignable objectState, moreElements, remove_called_since;
     also
public exceptional_behavior
requires !this.moreElements;
requires_redundantly !this.hasNext();
assignable \nothing;
signals_only org.jmlspecs.models.JMLNoSuchElementException;
Specifications inherited from overridden method in interface Iterator:
public normal_behavior
requires this.moreElements;
requires_redundantly this.hasNext(0);
assignable objectState, remove_called_since, moreElements;
ensures !this.remove_called_since;
ensures (\result == null)||\typeof(\result ) <: this.elementType;
ensures !this.returnsNull ==> (\result != null);
     also
public exceptional_behavior
requires !this.moreElements;
assignable \nothing;
signals_only java.util.NoSuchElementException;

remove

public void remove()
            throws UnsupportedOperationException
The remove operation is not supported in this type. So remove always throws an UnsupportedOperationException.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException
Specifications:
     also
signals_only java.lang.UnsupportedOperationException;
Specifications inherited from overridden method in interface Iterator:
public behavior
assignable objectState, remove_called_since;
ensures !\old(this.remove_called_since)&&this.remove_called_since;
signals_only java.lang.UnsupportedOperationException, java.lang.IllegalStateException;
signals (java.lang.UnsupportedOperationException) (* if this iterator does not support removing elements *);
signals (java.lang.IllegalStateException) \old(this.remove_called_since);

clone

public Object clone()
Return a clone of this iterator.

Specified by:
clone in interface JMLIterator
Overrides:
clone in class Object
Specifications: 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 JMLIterator:
      --- None ---
Specifications inherited from overridden method in interface JMLType:
       pure
     also
public normal_behavior
ensures \result != null;
ensures \result instanceof org.jmlspecs.models.JMLType;
ensures ((org.jmlspecs.models.JMLType)\result ).equals(this);
    implies_that
ensures \result != null&&\typeof(\result ) <: \type(org.jmlspecs.models.JMLType);

equals

public boolean equals(nullable Object oth)
Return true just when this iterator has the same state as the given argument.

Specified by:
equals in interface JMLType
Overrides:
equals in class Object
Specifications: pure
     also
public normal_behavior
ensures \result <==> oth != null&&oth instanceof org.jmlspecs.models.JMLEnumerationToIterator&&this.theEnumeration.equals(((org.jmlspecs.models.JMLEnumerationToIterator)oth).theEnumeration);
Specifications inherited from overridden method equals(Object obj) in class Object:
       pure
public normal_behavior
requires obj != null;
ensures (* \result is true when obj is "equal to" this object *);
     also
public normal_behavior
requires this == obj;
ensures \result ;
     also
public code normal_behavior
requires obj != null;
ensures \result <==> this == obj;
     also
diverges false;
ensures obj == null ==> !\result ;
Specifications inherited from overridden method equals(Object ob2) in interface JMLType:
       pure
     also
public normal_behavior
ensures \result ==> ob2 != null&&(* ob2 is not distinguishable from this, except by using mutation or == *);
    implies_that
public normal_behavior
{|
requires ob2 != null&&ob2 instanceof org.jmlspecs.models.JMLType;
ensures ((org.jmlspecs.models.JMLType)ob2).equals(this) == \result ;
also
requires ob2 == this;
ensures \result <==> true;
|}

hashCode

public int hashCode()
Return a hash code for this iterator.

Specified by:
hashCode in interface JMLType
Overrides:
hashCode in class Object
Specifications: pure
Specifications inherited from overridden method in class Object:
public behavior
assignable objectState;
ensures (* \result is a hash code for this object *);
     also
public code normal_behavior
assignable \nothing;
Specifications inherited from overridden method in interface JMLType:
       pure

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.