123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package r2rml.engine;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.util.Properties;
- import org.apache.log4j.Logger;
- /**
- * Configuration Class.
- *
- * @author Christophe Debruyne
- * @version 0.1
- *
- */
- public class Configuration {
-
- private static Logger logger = Logger.getLogger(Configuration.class.getName());
-
- private String connectionURL = null;
- private String user = null;
- private String password = null;
- private String mappingFile = null;
- private String outputFile = null;
- private String format = null;
- private String baseIRI = null;
- private boolean filePerGraph = false;
-
- public Configuration(String path) throws R2RMLException {
- Properties properties = new Properties();
- try {
- properties.load(new FileInputStream(new File(path)));
- } catch (IOException e) {
- throw new R2RMLException(e.getMessage(), e);
- }
-
- connectionURL = properties.getProperty("connectionURL");
- user = properties.getProperty("user");
- password = properties.getProperty("password");
- mappingFile = properties.getProperty("mappingFile");
- outputFile = properties.getProperty("outputFile");
- format = properties.getProperty("format", "TURTLE");
- setFilePerGraph("true".equals(properties.getProperty("filePerGraph", "false").toLowerCase()));
- baseIRI = properties.getProperty("baseIRI");
- }
-
- public Configuration() {
-
- }
- public String getConnectionURL() {
- return connectionURL;
- }
-
- public void setConnectionURL(String connectionURL) {
- this.connectionURL = connectionURL;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getMappingFile() {
- return mappingFile;
- }
-
- public void setMappingFile(String mappingFile) {
- this.mappingFile = mappingFile;
- }
-
- public String getOutputFile() {
- return outputFile;
- }
-
- public void setOutputFile(String outputFile) {
- this.outputFile = outputFile;
- }
-
- public String getFormat() {
- return format;
- }
-
- public void setFormat(String format) {
- this.format = format;
- }
- public String getBaseIRI() {
- return baseIRI;
- }
- public void setBaseIRI(String baseIRI) {
- if(baseIRI.contains("#"))
- logger.warn("Base IRIs should not contain a \"#\".");
- if(baseIRI.contains("?"))
- logger.warn("Base IRIs should not contain a \"?\".");
- if(!baseIRI.endsWith("/"))
- logger.warn("Base IRIs should end with a \"/\".");
- this.baseIRI = baseIRI;
- }
- public boolean isFilePerGraph() {
- return filePerGraph;
- }
- public void setFilePerGraph(boolean filePerGraph) {
- this.filePerGraph = filePerGraph;
- }
-
- }
|