be.ugent.rml.records.CSVRecord Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rmlmapper Show documentation
Show all versions of rmlmapper Show documentation
The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources.
package be.ugent.rml.records;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* This class is a specific implementation of a record for CSV.
* Every record corresponds with a row of the CSV data source.
*/
public class CSVRecord extends Record {
// The CSV record that is provided by the Apache CSVParser.
private org.apache.commons.csv.CSVRecord record;
private Map datatypes;
CSVRecord(org.apache.commons.csv.CSVRecord record, Map datatypes) {
this.record = record;
this.datatypes = datatypes;
}
/**
* This method returns the datatype of a reference in the record.
* @param value the reference for which the datatype needs to be returned.
* @return the IRI of the datatype.
*/
public String getDataType(String value) {
String datatype = null;
if (datatypes != null) {
datatype = datatypes.get(value);
/*
* Some RDBs require quotes for capitalization, but after executing the query,
* the quotes are dropped in the results as "ID" != ID, neither is 'ID' != ID.
*
* If the lookup fail, remove these quotes and try again.
*/
if (datatype == null) {
value = value.replaceFirst("^\"", "").replaceFirst("\"$", "");
value = value.replaceFirst("^\'", "").replaceFirst("\'$", "");
datatype = datatypes.get(value);
}
}
return datatype;
}
/**
* This method returns the objects for a column in the CSV record (= CSV row).
* @param value the column for which objects need to be returned.
* @return a list of objects for the column.
*/
@Override
public List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy