JML

org.jmlspecs.samples.list.node2
Class TwoWayNode

java.lang.Object
  extended byorg.jmlspecs.samples.list.node2.OneWayNode
      extended byorg.jmlspecs.samples.list.node2.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.node2.TwoWayNode);
protected represents prevNode <- this.prevNode_;
protected represents nextDL <- (org.jmlspecs.samples.list.node2.TwoWayNode)this.nextNode_;
protected represents prevEntries <- this.prevEntries();
public represents nextDL <- (org.jmlspecs.samples.list.node2.TwoWayNode)this.nextNode;

Specifications inherited from class OneWayNode
protected invariant_redundantly this.nextLink_ != null;
protected invariant this.nextNode_ == this.nextLink_.node;
public invariant_redundantly this.entries != null&&this.allButFirst != null;
public invariant this.entries.equals(this.allButFirst.insertFront(this.theEntry));
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.node2.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.node2.OneWayNode
entry_, nextLink_, nextNode_
 
Constructor Summary
  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.node2.OneWayNode
nextEntries, nextEntries
 
Model methods inherited from class java.lang.Object
hashValue
 
Method Summary
 DualLink getPrevLink()
           
 TwoWayNode getPrevNode()
           
 void insertAfter(nullable Object newEntry)
           
 void insertBefore(nullable Object newEntry)
           
private  void linkTo(nullable TwoWayNode nxtNode)
           
 void removeNextNode()
           
 void removePrevNode()
           
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.node2.OneWayNode
getEntry, getNextLink, getNextNode, hasNext, setEntry, stringOfEntries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Model Field Detail

prevEntries

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

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_.entry_ \into prevEntries
Constructor Detail

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()&&this.allButFirst.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 allButFirst;
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 allButFirst;
ensures \not_modified(prevEntries);
Specifications inherited from overridden method in class OneWayNode:
public normal_behavior
requires !this.allButFirst.isEmpty();
assignable allButFirst;
ensures this.allButFirst.equals(\old(this.allButFirst).trailer());
     also
requires this.allButFirst.isEmpty();
assignable \nothing;
ensures this.allButFirst.isEmpty();

getPrevNode

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

getPrevLink

public DualLink getPrevLink()
Specifications: pure nullable
public normal_behavior
requires this.prevNode != null;
assignable \nothing;
ensures \result .node == this;
     also
requires this.prevNode == null;
assignable \nothing;
ensures \result == null;

insertBefore

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

removePrevNode

public void removePrevNode()

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

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.