|
|
@ -134,19 +134,30 @@ public class StateValuesDV implements StateValues |
|
|
String s; |
|
|
String s; |
|
|
int lineNum = 0, count = 0; |
|
|
int lineNum = 0, count = 0; |
|
|
double d; |
|
|
double d; |
|
|
|
|
|
boolean hasIndices = false; |
|
|
int size = values.getSize(); |
|
|
int size = values.getSize(); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
// open file for reading |
|
|
|
|
|
|
|
|
// Open file for reading |
|
|
in = new BufferedReader(new FileReader(file)); |
|
|
in = new BufferedReader(new FileReader(file)); |
|
|
// read remaining lines |
|
|
|
|
|
|
|
|
// Read remaining lines |
|
|
s = in.readLine(); |
|
|
s = in.readLine(); |
|
|
lineNum++; |
|
|
lineNum++; |
|
|
while (s != null) { |
|
|
while (s != null) { |
|
|
s = s.trim(); |
|
|
s = s.trim(); |
|
|
if (!("".equals(s))) { |
|
|
if (!("".equals(s))) { |
|
|
if (count + 1 > size) |
|
|
|
|
|
|
|
|
// If entry is of form "i=x", use i as index not count |
|
|
|
|
|
// (otherwise, assume line i contains value for state index i) |
|
|
|
|
|
if (s.contains("=")) { |
|
|
|
|
|
hasIndices = true; |
|
|
|
|
|
String ss[] = s.split("="); |
|
|
|
|
|
count = Integer.parseInt(ss[0]); |
|
|
|
|
|
s = ss[1]; |
|
|
|
|
|
} |
|
|
|
|
|
if (count + 1 > size) { |
|
|
|
|
|
in.close(); |
|
|
throw new PrismException("Too many values in file \"" + file + "\" (more than " + size + ")"); |
|
|
throw new PrismException("Too many values in file \"" + file + "\" (more than " + size + ")"); |
|
|
|
|
|
} |
|
|
d = Double.parseDouble(s); |
|
|
d = Double.parseDouble(s); |
|
|
setElement(count, d); |
|
|
setElement(count, d); |
|
|
count++; |
|
|
count++; |
|
|
@ -154,10 +165,10 @@ public class StateValuesDV implements StateValues |
|
|
s = in.readLine(); |
|
|
s = in.readLine(); |
|
|
lineNum++; |
|
|
lineNum++; |
|
|
} |
|
|
} |
|
|
// close file |
|
|
|
|
|
|
|
|
// Close file |
|
|
in.close(); |
|
|
in.close(); |
|
|
// check size |
|
|
|
|
|
if (count < size) |
|
|
|
|
|
|
|
|
// Check size |
|
|
|
|
|
if (!hasIndices && count < size) |
|
|
throw new PrismException("Too few values in file \"" + file + "\" (" + count + ", not " + size + ")"); |
|
|
throw new PrismException("Too few values in file \"" + file + "\" (" + count + ", not " + size + ")"); |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
throw new PrismException("File I/O error reading from \"" + file + "\""); |
|
|
throw new PrismException("File I/O error reading from \"" + file + "\""); |
|
|
|