Configuration.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package r2rml.engine;
  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.IOException;
  5. import java.util.Properties;
  6. import org.apache.log4j.Logger;
  7. /**
  8. * Configuration Class.
  9. *
  10. * @author Christophe Debruyne
  11. * @version 0.1
  12. *
  13. */
  14. public class Configuration {
  15. private static Logger logger = Logger.getLogger(Configuration.class.getName());
  16. private String connectionURL = null;
  17. private String user = null;
  18. private String password = null;
  19. private String mappingFile = null;
  20. private String outputFile = null;
  21. private String format = null;
  22. private String baseIRI = null;
  23. private boolean filePerGraph = false;
  24. public Configuration(String path) throws R2RMLException {
  25. Properties properties = new Properties();
  26. try {
  27. properties.load(new FileInputStream(new File(path)));
  28. } catch (IOException e) {
  29. throw new R2RMLException(e.getMessage(), e);
  30. }
  31. connectionURL = properties.getProperty("connectionURL");
  32. user = properties.getProperty("user");
  33. password = properties.getProperty("password");
  34. mappingFile = properties.getProperty("mappingFile");
  35. outputFile = properties.getProperty("outputFile");
  36. format = properties.getProperty("format", "TURTLE");
  37. setFilePerGraph("true".equals(properties.getProperty("filePerGraph", "false").toLowerCase()));
  38. baseIRI = properties.getProperty("baseIRI");
  39. }
  40. public Configuration() {
  41. }
  42. public String getConnectionURL() {
  43. return connectionURL;
  44. }
  45. public void setConnectionURL(String connectionURL) {
  46. this.connectionURL = connectionURL;
  47. }
  48. public String getUser() {
  49. return user;
  50. }
  51. public void setUser(String user) {
  52. this.user = user;
  53. }
  54. public String getPassword() {
  55. return password;
  56. }
  57. public void setPassword(String password) {
  58. this.password = password;
  59. }
  60. public String getMappingFile() {
  61. return mappingFile;
  62. }
  63. public void setMappingFile(String mappingFile) {
  64. this.mappingFile = mappingFile;
  65. }
  66. public String getOutputFile() {
  67. return outputFile;
  68. }
  69. public void setOutputFile(String outputFile) {
  70. this.outputFile = outputFile;
  71. }
  72. public String getFormat() {
  73. return format;
  74. }
  75. public void setFormat(String format) {
  76. this.format = format;
  77. }
  78. public String getBaseIRI() {
  79. return baseIRI;
  80. }
  81. public void setBaseIRI(String baseIRI) {
  82. if(baseIRI.contains("#"))
  83. logger.warn("Base IRIs should not contain a \"#\".");
  84. if(baseIRI.contains("?"))
  85. logger.warn("Base IRIs should not contain a \"?\".");
  86. if(!baseIRI.endsWith("/"))
  87. logger.warn("Base IRIs should end with a \"/\".");
  88. this.baseIRI = baseIRI;
  89. }
  90. public boolean isFilePerGraph() {
  91. return filePerGraph;
  92. }
  93. public void setFilePerGraph(boolean filePerGraph) {
  94. this.filePerGraph = filePerGraph;
  95. }
  96. }