Browse Source

Additional toString in Values class.

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10152 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 11 years ago
parent
commit
a298807d5d
  1. 40
      prism/src/parser/Values.java

40
prism/src/parser/Values.java

@ -26,11 +26,15 @@
package parser;
import java.util.*;
import java.text.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import parser.type.*;
import parser.ast.ModulesFile;
import parser.type.Type;
import parser.type.TypeBool;
import parser.type.TypeDouble;
import parser.type.TypeInt;
import prism.PrismLangException;
/**
@ -414,16 +418,30 @@ public class Values //implements Comparable
@Override
public String toString()
{
int i, n;
String s;
return toString(true, ",");
}
/**
* Return a string representation of this Values object, e.g. "x=1,y=2".
* If {@code printNames} is false, the "x="s are omitted.
* The separator ("," above) can be specified in {@code separator}.
* @param printNames Print variable/constant names?
* @param separator String used to separate values in the list
*/
public String toString(boolean printNames, String separator)
{
// Build string of form "x=1,y=2"
n = getNumValues();
s = "";
for (i = 0; i < n; i++) {
s += getName(i) + "=" + valToString(getValue(i));
if (i < n-1) s += ",";
int n = getNumValues();
String s = "";
for (int i = 0; i < n; i++) {
if (printNames) {
s += getName(i) + "=";
}
s += valToString(getValue(i));
if (i < n-1) {
s += separator;
}
}
return s;
}

Loading…
Cancel
Save