fix bug in CSV reader (read past end of line)

This commit is contained in:
Grahame Grieve 2020-04-06 10:11:00 +10:00
parent a52a1127f8
commit 3e49000188
1 changed files with 7 additions and 3 deletions

View File

@ -93,8 +93,12 @@ public class CSVReader extends InputStreamReader {
}
public boolean has(String name) {
for (int i = 0; i < cols.length; i++) {
if (name.equals(cols[i].trim()))
return cell(name) != null;
}
return false;
}
public String cell(String name) {
int index = -1;
@ -103,7 +107,7 @@ public class CSVReader extends InputStreamReader {
index = i;
}
if (index == -1)
throw new Error("no cell "+name);
throw new FHIRException("no cell "+name);
String s = cells.length >= index ? cells[index] : null;
if (Utilities.noString(s))
return null;
@ -149,7 +153,7 @@ public class CSVReader extends InputStreamReader {
StringBuilder b = new StringBuilder();
boolean inQuote = false;
while (inQuote || (peek() != '\r' && peek() != '\n')) {
while (ready() && (inQuote || (peek() != '\r' && peek() != '\n'))) {
char c = peek();
next();
if (c == '"') {