aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util')
-rw-r--r--src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java126
-rw-r--r--src/uk/ac/ox/cs/pagoda/util/Properties.java66
2 files changed, 126 insertions, 66 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
new file mode 100644
index 0000000..be6627a
--- /dev/null
+++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
@@ -0,0 +1,126 @@
1package uk.ac.ox.cs.pagoda.util;
2
3import java.io.FileInputStream;
4import java.io.IOException;
5import java.io.InputStream;
6import java.util.Properties;
7
8public class PagodaProperties {
9
10 public static final String CONFIG_FILE = "pagoda.properties";
11
12 public static final boolean DEFAULT_DEBUG = false;
13 public static boolean shellModeDefault = false;
14 private static boolean debug = DEFAULT_DEBUG;
15
16 static {
17 try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) {
18 Properties config = new Properties();
19 config.load(in);
20 in.close();
21 if(config.containsKey("debug")) {
22 debug = Boolean.parseBoolean(config.getProperty("debug"));
23 }
24 } catch(IOException e) {
25 e.printStackTrace();
26 }
27 }
28
29 String dataPath = null;
30 String ontologyPath;
31 String queryPath = null;
32 String answerPath = null;
33 boolean toClassify = true;
34 boolean toCallHermiT = true;
35 boolean shellMode = shellModeDefault;
36
37 public PagodaProperties(String path) {
38 java.util.Properties m_properties = new java.util.Properties();
39 InputStream inputStream = null;
40 try {
41 inputStream = new FileInputStream(path);
42 m_properties.load(inputStream);
43
44 setOntologyPath(m_properties.getProperty("ONTOLOGY"));
45 setDataPath(m_properties.getProperty("DATA"));
46 setQueryPath(m_properties.getProperty("QUERY"));
47 setAnswerPath(m_properties.getProperty("ANSWER"));
48 setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY")));
49 setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT")));
50
51 } catch (IOException e) {
52 e.printStackTrace();
53 } finally {
54 if (inputStream != null)
55 try {
56 inputStream.close();
57 } catch (IOException e) {
58 e.printStackTrace();
59 }
60 }
61 }
62
63 public PagodaProperties() {
64 }
65
66 public static boolean isDebuggingMode() {
67 return debug;
68 }
69
70 public String getDataPath() {
71 return dataPath;
72 }
73
74 public void setDataPath(String path) {
75 dataPath = path;
76 }
77
78 public String getOntologyPath() {
79 return ontologyPath;
80 }
81
82 public void setOntologyPath(String path) {
83 ontologyPath = path;
84 }
85
86 public String getQueryPath() {
87 return queryPath;
88 }
89
90 public void setQueryPath(String path) {
91 queryPath = path;
92 }
93
94 public String getAnswerPath() {
95 return answerPath;
96 }
97
98 public void setAnswerPath(String path) {
99 answerPath = path;
100 }
101
102 public boolean getToClassify() {
103 return toClassify;
104 }
105
106 public void setToClassify(boolean flag) {
107 toClassify = flag;
108 }
109
110 public boolean getToCallHermiT() {
111 return toCallHermiT;
112 }
113
114 public void setToCallHermiT(boolean flag) {
115 toCallHermiT = flag;
116 }
117
118 public boolean getShellMode() {
119 return shellMode;
120 }
121
122 public void setShellMode(boolean flag) {
123 shellMode = flag;
124 }
125
126}
diff --git a/src/uk/ac/ox/cs/pagoda/util/Properties.java b/src/uk/ac/ox/cs/pagoda/util/Properties.java
deleted file mode 100644
index 9ebebb6..0000000
--- a/src/uk/ac/ox/cs/pagoda/util/Properties.java
+++ /dev/null
@@ -1,66 +0,0 @@
1package uk.ac.ox.cs.pagoda.util;
2
3import java.io.FileInputStream;
4import java.io.IOException;
5import java.io.InputStream;
6
7public class Properties {
8
9 String dataPath = null;
10 public String getDataPath() { return dataPath; }
11 public void setDataPath(String path) { dataPath = path; }
12
13 String ontologyPath;
14 public String getOntologyPath() { return ontologyPath; }
15 public void setOntologyPath(String path) { ontologyPath = path; }
16
17 String queryPath = null;
18 public String getQueryPath() { return queryPath; }
19 public void setQueryPath(String path) { queryPath = path; }
20
21 String answerPath = null;
22 public String getAnswerPath() { return answerPath; }
23 public void setAnswerPath(String path) { answerPath = path; }
24
25 boolean toClassify = true;
26 public boolean getToClassify() { return toClassify; }
27 public void setToClassify(boolean flag) { toClassify = flag; }
28
29 boolean toCallHermiT = true;
30 public boolean getToCallHermiT() { return toCallHermiT; }
31 public void setToCallHermiT(boolean flag) { toCallHermiT = flag; }
32
33 public static boolean shellModeDefault = false;
34
35 boolean shellMode = shellModeDefault;
36 public boolean getShellMode() { return shellMode; }
37 public void setShellMode(boolean flag) { shellMode = flag; }
38
39 public Properties(String path) {
40 java.util.Properties m_properties = new java.util.Properties();
41 InputStream inputStream = null;
42 try {
43 inputStream = new FileInputStream(path);
44 m_properties.load(inputStream);
45
46 setOntologyPath(m_properties.getProperty("ONTOLOGY"));
47 setDataPath(m_properties.getProperty("DATA"));
48 setQueryPath(m_properties.getProperty("QUERY"));
49 setAnswerPath(m_properties.getProperty("ANSWER"));
50 setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY")));
51 setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT")));
52
53 } catch (IOException e) {
54 e.printStackTrace();
55 } finally {
56 if (inputStream != null)
57 try {
58 inputStream.close();
59 } catch (IOException e) {
60 e.printStackTrace();
61 }
62 }
63 }
64 public Properties() { }
65
66}