From 7a7932bee26c591ebe846b67b418aaf213dbd650 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Sun, 7 Aug 2011 11:58:00 +0000 Subject: [PATCH] Tweaked toString for STPGAbstrSimple. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@3408 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/explicit/STPGAbstrSimple.java | 79 ++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/prism/src/explicit/STPGAbstrSimple.java b/prism/src/explicit/STPGAbstrSimple.java index 41547d09..6b0fcadb 100644 --- a/prism/src/explicit/STPGAbstrSimple.java +++ b/prism/src/explicit/STPGAbstrSimple.java @@ -927,11 +927,84 @@ public class STPGAbstrSimple extends ModelSimple implements STPG // Standard methods - /** - * Get transition function as string. - */ + // @Override // Move to superclass later + public String toStringGeneric() + { + // General purpose toString(), based on STPG access methods + int s, i, j, ni, nj; + boolean first, firsti, firstTr; + Iterator> it; + String str = ""; + first = true; + str = "[ "; + for (s = 0; s < numStates; s++) { + if (first) + first = false; + else + str += ", "; + str += s + ": "; + ni = getNumChoices(s); + str += "["; + firsti = true; + for (i = 0; i < ni; i++) { + // Do non-nested choices + it = getTransitionsIterator(s, i); + if (it == null) + continue; + if (firsti) + firsti = false; + else + str += ", "; + str += "{"; + firstTr = true; + while (it.hasNext()) { + Entry next = it.next(); + if (firstTr) + firstTr = false; + else + str += ", "; + str += next.getKey() + "=" + next.getValue(); + } + str += "}"; + // Do nested choices + nj = getNumNestedChoices(s, i); + if (nj == 0) + continue; + if (firsti) + firsti = false; + else + str += ", "; + str += "["; + for (j = 0; j < nj; j++) { + it = getNestedTransitionsIterator(s, i, j); + if (it == null) + continue; + if (j > 0) + str += ", "; + str += "{"; + firstTr = true; + while (it.hasNext()) { + Entry next = it.next(); + if (firstTr) + firstTr = false; + else + str += ", "; + str += next.getKey() + "=" + next.getValue(); + } + str += "}"; + } + str += "]"; + } + str += "]"; + } + str += " ]"; + return str; + } + + @Override public String toString() { + // Custom toString() int i; boolean first; String s = "";