JML

org.jmlspecs.samples.list.node
Class TwoWayNode

java.lang.Object
  extended byorg.jmlspecs.samples.list.node.OneWayNode
      extended byorg.jmlspecs.samples.list.node.TwoWayNode

public class TwoWayNode
extends OneWayNode


Class Specifications
protected invariant (this.prevNode == null)||(this.prevNode.nextNode == this);
protected invariant (this.nextNode == null)||(this.nextDL.prevNode == this);
public invariant (this.nextNode == null||this.nextNode instanceof org.jmlspecs.samples.list.node.TwoWayNode);
public invariant_redundantly this.prevEntries != null;
protected represents prevNode <- this.prevNode_;
protected represents prevEntries <- this.prevEntries();
public represents nextDL <- (org.jmlspecs.samples.list.node.TwoWayNode)this.nextNode;

Specifications inherited from class OneWayNode
public invariant_redundantly this.entries != null&&this.allButFirst != null;
protected represents theEntry <- this.entry_;
protected represents nextNode <- this.nextNode_;
protected represents entries <- this.nextEntries().insertFront(this.entry_);
protected represents allButFirst <- this.nextEntries();

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

Model Field Summary
 TwoWayNode nextDL
           
 JMLObjectSequence prevEntries
           
 TwoWayNode prevNode
           
 
Model fields inherited from class org.jmlspecs.samples.list.node.OneWayNode
allButFirst, entries, nextNode, theEntry
 
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
protected  TwoWayNode prevNode_
           
 
Fields inherited from class org.jmlspecs.samples.list.node.OneWayNode
entry_, nextNode_
 
Constructor Summary
  TwoWayNode()
           
  TwoWayNode(nullable Object ent)
           
protected TwoWayNode(nullable Object ent, nullable TwoWayNode prvNode, nullable TwoWayNode nxtNode)
           
 
Model Method Summary
 JMLObjectSequence prevEntries()
           
 JMLObjectSequence prevEntries(nullable TwoWayNode curr)
           
 
Model methods inherited from class org.jmlspecs.samples.list.node.OneWayNode
nextEntries, nextEntries
 
Model methods inherited from class java.lang.Object
hashValue
 
Method Summary
 Object clone()
           
protected  TwoWayNode cloneNext()
           
protected  TwoWayNode clonePrevious()
           
 TwoWayNode getPrevNode()
           
 void insertAfter(nullable Object newEntry)
           
 void insertBefore(nullable Object newEntry)
           
private  void linkTo(nullable TwoWayNode nxtNode)
           
 void removeNextNode()
           
protected  String stringOfPrevEntries(nullable TwoWayNode curr)
          The first invocation of this method should be with curr == prevNode_.
 String toString()
           
 
Methods inherited from class org.jmlspecs.samples.list.node.OneWayNode
getEntry, getNextNode, hasNext, setEntry, stringOfEntries
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Model Field Detail

prevEntries

public JMLObjectSequence prevEntries
Specifications:
is in groups: entries
datagroup contains: prevNode prevNode_.prevEntries prevNode_.theEntry

nextDL

public TwoWayNode nextDL
Specifications: nullable
is in groups: nextNode

prevNode

public TwoWayNode prevNode
Specifications: nullable
is in groups: prevEntries
datagroup contains: prevNode_
Field Detail

prevNode_

protected TwoWayNode prevNode_
Specifications: nullable
is in groups: prevNode
maps prevNode_.prevEntries \into prevEntries, prevNode_.theEntry \into prevEntries
Constructor Detail

TwoWayNode

public TwoWayNode()
Specifications:
public normal_behavior
assignable entries;
ensures this.theEntry == null&&this.entries.itemAt(0) == null&&this.entries.int_size() == 1&&this.prevEntries.isEmpty();

TwoWayNode

public TwoWayNode(nullable Object ent)
Specifications:
public normal_behavior
assignable entries;
ensures this.theEntry == ent&&this.entries.itemAt(0) == ent&&this.entries.int_size() == 1&&this.prevEntries.isEmpty();

TwoWayNode

protected TwoWayNode(nullable Object ent,
                     nullable TwoWayNode prvNode,
                     nullable TwoWayNode nxtNode)
Specifications:
protected normal_behavior
requires (prvNode == null||prvNode.nextNode == null||prvNode.nextNode == nxtNode)&&(nxtNode == null||nxtNode.prevNode == null||nxtNode.prevNode == prvNode);
assignable entries;
ensures this.theEntry == ent&&this.entries.itemAt(0) == ent&&this.prevNode == prvNode&&this.nextNode == nxtNode;
Model Method Detail

prevEntries

public JMLObjectSequence prevEntries()
Specifications: pure

prevEntries

public JMLObjectSequence prevEntries(nullable TwoWayNode curr)
Specifications: pure
Method Detail

insertAfter

public void insertAfter(nullable Object newEntry)
Overrides:
insertAfter in class OneWayNode
Specifications:
     also
public normal_behavior
assignable entries;
ensures \not_modified(prevEntries);
Specifications inherited from overridden method insertAfter(Object newEntry) in class OneWayNode:
public normal_behavior
assignable allButFirst;
ensures this.allButFirst.equals(\old(this.allButFirst).insertFront(newEntry));

removeNextNode

public void removeNextNode()
Overrides:
removeNextNode in class OneWayNode
Specifications:
     also
public normal_behavior
assignable entries;
ensures \not_modified(prevEntries);
Specifications inherited from overridden method in class OneWayNode:
public normal_behavior
requires !this.allButFirst.isEmpty();
assignable entries;
ensures this.allButFirst.equals(\old(this.allButFirst).trailer());
     also
requires this.allButFirst.isEmpty();
assignable \nothing;
ensures \not_modified(entries);

getPrevNode

public TwoWayNode getPrevNode()
Specifications: pure nullable
public normal_behavior
assignable \nothing;
ensures \result == this.prevNode;

insertBefore

public void insertBefore(nullable Object newEntry)
Specifications:
public normal_behavior
assignable prevEntries;
ensures this.prevEntries.equals(\old(this.prevEntries).insertBack(newEntry))&&(this.nextNode != null ==> \not_modified(nextNode.entries));

toString

public String toString()
Overrides:
toString in class OneWayNode
Specifications: (inherited)pure
Specifications inherited from overridden method in class OneWayNode:
       pure
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;

stringOfPrevEntries

protected String stringOfPrevEntries(nullable TwoWayNode curr)
The first invocation of this method should be with curr == prevNode_. If this is done, then the string returned will be a concatentation of all nodes prior to this node up to and excluding the end of the chain or this, which ever is reached first (i.e. this method will terminate even for circular lists).

Specifications: pure

clone

public Object clone()
Overrides:
clone in class OneWayNode
Specifications:
     also
public normal_behavior
assignable \nothing;
ensures \result instanceof org.jmlspecs.samples.list.node.TwoWayNode&&((org.jmlspecs.samples.list.node.TwoWayNode)\result ).entries.equals(this.entries)&&((org.jmlspecs.samples.list.node.TwoWayNode)\result ).prevEntries.equals(this.prevEntries);
Specifications inherited from overridden method in class OneWayNode:
     also
public normal_behavior
assignable \nothing;
ensures \result instanceof org.jmlspecs.samples.list.node.OneWayNode&&((org.jmlspecs.samples.list.node.OneWayNode)\result ).entries.equals(this.entries);
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]);

cloneNext

protected TwoWayNode cloneNext()
Specifications: pure

clonePrevious

protected TwoWayNode clonePrevious()
Specifications: pure

linkTo

private void linkTo(nullable TwoWayNode nxtNode)
Specifications: helper
private normal_behavior
requires nxtNode != null;
assignable nextNode, nxtNode.prevNode;
ensures this.nextNode == nxtNode&&this.nextDL.prevNode == this;
     also
requires nxtNode == null;
assignable nextNode;
ensures this.nextNode == 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.