-
Notifications
You must be signed in to change notification settings - Fork 61
/
ReferenceExtractor.java
43 lines (32 loc) · 1.11 KB
/
ReferenceExtractor.java
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
package be.ugent.rml.extractor;
import be.ugent.idlab.knows.dataio.record.Record;
import be.ugent.rml.functions.SingleRecordFunctionExecutor;
import java.io.IOException;
import java.util.List;
public class ReferenceExtractor implements Extractor, SingleRecordFunctionExecutor {
public String reference;
private boolean ignoreDoubleQuotes;
public ReferenceExtractor(String reference, boolean ignoreDoubleQuotes) {
this.reference = reference;
this.ignoreDoubleQuotes = ignoreDoubleQuotes;
}
public ReferenceExtractor(String reference) {
this(reference, false);
}
@Override
public List<Object> extract(Record record) {
String temp = this.reference;
if (ignoreDoubleQuotes && temp.startsWith("\"") && temp.endsWith("\"")) {
temp = temp.substring(1, temp.length() - 1);
}
return record.get(temp);
}
@Override
public String toString() {
return "ReferenceExecutor that works with " + reference;
}
@Override
public Object execute(Record record) throws IOException {
return extract(record);
}
}