forked from sqlancer/sqlancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCnosDBResultSet.java
More file actions
52 lines (40 loc) · 1.29 KB
/
CnosDBResultSet.java
File metadata and controls
52 lines (40 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package sqlancer.cnosdb.client;
import java.io.Reader;
import java.sql.SQLException;
import java.util.Iterator;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import sqlancer.IgnoreMeException;
public class CnosDBResultSet {
private final Iterator<CSVRecord> records;
private CSVRecord next;
public CnosDBResultSet(Reader in) throws Exception {
Iterable<CSVRecord> records = CSVFormat.DEFAULT.builder().setHeader().setSkipHeaderRecord(true).build()
.parse(in);
this.records = records.iterator();
}
public void close() {
}
public boolean next() throws SQLException {
if (records.hasNext()) {
next = records.next();
return true;
}
return false;
}
public int getInt(int i) throws SQLException {
return Integer.parseInt(next.get(i - 1));
}
public String getString(int i) throws SQLException {
return next.get(i - 1);
}
public long getLong(int i) throws SQLException {
if (next.get(i - 1).isEmpty()) {
throw new IgnoreMeException();
}
return Long.parseLong(next.get(i - 1));
}
// public boolean getBool(int i) throws Exception {
// return Boolean.parseBoolean(getString(i));
// }
}