aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java416
1 files changed, 222 insertions, 194 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
index 7b68400..18469ff 100644
--- a/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
+++ b/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
@@ -11,198 +11,226 @@ import java.util.Properties;
11 11
12public class PagodaProperties { 12public class PagodaProperties {
13 13
14 public static final String CONFIG_FILE = "pagoda.properties"; 14 public enum SkolemUpperBoundOptions {DISABLED, BEFORE_SUMMARISATION, AFTER_SUMMARISATION}
15 public static final boolean DEFAULT_DEBUG = false; 15
16 private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; 16 public static final String CONFIG_FILE = "pagoda.properties";
17 private static final boolean DEFAULT_USE_SKOLEM_UPPER_BOUND; 17 public static final boolean DEFAULT_DEBUG = false;
18 private static final boolean DEFAULT_TO_CALL_HERMIT; 18 private static final boolean DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND;
19 private static final Path DEFAULT_STATISTICS_DIR; 19 private static final SkolemUpperBoundOptions DEFAULT_SKOLEM_UPPER_BOUND;
20 20 private static final int DEFAULT_SKOLEM_DEPTH;
21 public static boolean shellModeDefault = false; 21 private static final boolean DEFAULT_TO_CALL_HERMIT;
22 private static boolean debug = DEFAULT_DEBUG; 22 private static final Path DEFAULT_STATISTICS_DIR;
23 23
24 static { 24 public static boolean shellModeDefault = false;
25 boolean defaultUseAlwaysSimpleUpperBound = false; 25 private static boolean debug = DEFAULT_DEBUG;
26 boolean defaultUseSkolemUpperBound = true; 26
27 boolean toCallHermit = true; 27 static {
28 Path defaultStatisticsDir = null; 28 boolean defaultUseAlwaysSimpleUpperBound = false;
29 29 SkolemUpperBoundOptions defaultSkolemUpperBound = SkolemUpperBoundOptions.DISABLED;
30 try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) { 30 int defaultSkolemDepth = 1;
31 Properties config = new Properties(); 31 boolean toCallHermit = true;
32 config.load(in); 32 Path defaultStatisticsDir = null;
33 in.close(); 33
34 Logger logger = Logger.getLogger("PagodaProperties"); 34 try (InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) {
35 if(config.containsKey("debug")) { 35 Properties config = new Properties();
36 debug = Boolean.parseBoolean(config.getProperty("debug")); 36 config.load(in);
37 logger.info("Debugging mode is enabled"); 37 in.close();
38 38 Logger logger = Logger.getLogger("PagodaProperties");
39 if(config.containsKey("statisticsDir")) { 39 if (config.containsKey("debug")) {
40 defaultStatisticsDir = Paths.get(config.getProperty("statisticsDir")); 40 debug = Boolean.parseBoolean(config.getProperty("debug"));
41 logger.info("The directory where statistics are saved is: \"" + defaultStatisticsDir + "\""); 41 logger.info("Debugging mode is enabled");
42 } 42
43 } 43 if (config.containsKey("statisticsDir")) {
44 if(config.containsKey("useAlwaysSimpleUpperBound")) { 44 defaultStatisticsDir = Paths.get(config.getProperty("statisticsDir"));
45 defaultUseAlwaysSimpleUpperBound = 45 logger.info("The directory where statistics are saved is: \"" + defaultStatisticsDir + "\"");
46 Boolean.parseBoolean(config.getProperty("useAlwaysSimpleUpperBound")); 46 }
47 if(defaultUseAlwaysSimpleUpperBound) 47 }
48 logger.debug("By default the simple upper bound is always used"); 48 if (config.containsKey("useAlwaysSimpleUpperBound")) {
49 } 49 defaultUseAlwaysSimpleUpperBound =
50 if(config.containsKey("useSkolemUpperBound")) { 50 Boolean.parseBoolean(config.getProperty("useAlwaysSimpleUpperBound"));
51 defaultUseSkolemUpperBound = Boolean.parseBoolean(config.getProperty("useSkolemUpperBound")); 51 if (defaultUseAlwaysSimpleUpperBound)
52 if(defaultUseSkolemUpperBound) 52 logger.debug("By default the simple upper bound is always used");
53 logger.debug("By default the Skolem upper bound is enabled"); 53 }
54 else 54 if (config.containsKey("skolemUpperBound")) {
55 logger.debug("By default the Skolem upper bound is disabled"); 55 defaultSkolemUpperBound = SkolemUpperBoundOptions.valueOf(config.getProperty("skolemUpperBound"));
56 } 56 switch (defaultSkolemUpperBound) {
57 if(config.containsKey("toCallHermit")) { 57 case AFTER_SUMMARISATION:
58 toCallHermit = Boolean.parseBoolean(config.getProperty("toCallHermit")); 58 logger.debug("By default the Skolem upper bound is applied AFTER Summarisation");
59 if(toCallHermit) 59 break;
60 logger.debug("By default Hermit is enabled"); 60 case BEFORE_SUMMARISATION:
61 else 61 logger.debug("By default the Skolem upper bound is applied BEFORE Summarisation");
62 logger.debug("By default Hermit is disabled"); 62 break;
63 } 63 default:
64 64 defaultSkolemUpperBound = SkolemUpperBoundOptions.DISABLED;
65 } catch(IOException e) { 65 case DISABLED:
66 e.printStackTrace(); 66 logger.debug("By default the Skolem upper bound is disabled");
67 } 67 }
68 DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound; 68 }
69 DEFAULT_USE_SKOLEM_UPPER_BOUND = defaultUseSkolemUpperBound; 69 if (config.containsKey("toCallHermit")) {
70 DEFAULT_TO_CALL_HERMIT = toCallHermit; 70 toCallHermit = Boolean.parseBoolean(config.getProperty("toCallHermit"));
71 DEFAULT_STATISTICS_DIR = defaultStatisticsDir; 71 if (toCallHermit)
72 } 72 logger.debug("By default Hermit is enabled");
73 73 else
74 String dataPath = null; 74 logger.debug("By default Hermit is disabled");
75 String ontologyPath; 75 }
76 String queryPath = null; 76 if (config.containsKey("skolemDepth")) {
77 String answerPath = null; 77 defaultSkolemDepth = Integer.parseInt(config.getProperty("skolemDepth"));
78 boolean toClassify = true; 78 logger.debug("By default the max skolemisation depth is " + defaultSkolemDepth);
79 boolean toCallHermiT = DEFAULT_TO_CALL_HERMIT; 79 }
80 boolean shellMode = shellModeDefault; 80
81 private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; 81 } catch (IOException e) {
82 private boolean useSkolemUpperBound = DEFAULT_USE_SKOLEM_UPPER_BOUND; 82 e.printStackTrace();
83 private Path statisticsDir = DEFAULT_STATISTICS_DIR; 83 }
84 84 DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND = defaultUseAlwaysSimpleUpperBound;
85 public PagodaProperties(String path) { 85 DEFAULT_SKOLEM_UPPER_BOUND = defaultSkolemUpperBound;
86 java.util.Properties m_properties = new java.util.Properties(); 86 DEFAULT_TO_CALL_HERMIT = toCallHermit;
87 InputStream inputStream = null; 87 DEFAULT_STATISTICS_DIR = defaultStatisticsDir;
88 try { 88 DEFAULT_SKOLEM_DEPTH = defaultSkolemDepth;
89 inputStream = new FileInputStream(path); 89 }
90 m_properties.load(inputStream); 90
91 91 String dataPath = null;
92 setOntologyPath(m_properties.getProperty("ONTOLOGY")); 92 String ontologyPath;
93 setDataPath(m_properties.getProperty("DATA")); 93 String queryPath = null;
94 setQueryPath(m_properties.getProperty("QUERY")); 94 String answerPath = null;
95 setAnswerPath(m_properties.getProperty("ANSWER")); 95 boolean toClassify = true;
96 setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY"))); 96 boolean toCallHermiT = DEFAULT_TO_CALL_HERMIT;
97 setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT"))); 97
98 98 public int getSkolemDepth() {
99 } catch (IOException e) { 99 return skolemDepth;
100 e.printStackTrace(); 100 }
101 } finally { 101
102 if (inputStream != null) 102 public void setSkolemDepth(int skolemDepth) {
103 try { 103 this.skolemDepth = skolemDepth;
104 inputStream.close(); 104 }
105 } catch (IOException e) { 105
106 e.printStackTrace(); 106 int skolemDepth = DEFAULT_SKOLEM_DEPTH;
107 } 107 boolean shellMode = shellModeDefault;
108 } 108 private boolean useAlwaysSimpleUpperBound = DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND;
109 } 109 private SkolemUpperBoundOptions skolemUpperBound = DEFAULT_SKOLEM_UPPER_BOUND;
110 public PagodaProperties() { 110 private Path statisticsDir = DEFAULT_STATISTICS_DIR;
111 } 111
112 112 public PagodaProperties(String path) {
113 public static boolean isDebuggingMode() { 113 java.util.Properties m_properties = new java.util.Properties();
114 return debug; 114 InputStream inputStream = null;
115 } 115 try {
116 116 inputStream = new FileInputStream(path);
117 public static boolean getDefaultUseAlwaysSimpleUpperBound() { 117 m_properties.load(inputStream);
118 return DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND; 118
119 } 119 setOntologyPath(m_properties.getProperty("ONTOLOGY"));
120 120 setDataPath(m_properties.getProperty("DATA"));
121 public static Path getDefaultStatisticsDir() { 121 setQueryPath(m_properties.getProperty("QUERY"));
122 return DEFAULT_STATISTICS_DIR; 122 setAnswerPath(m_properties.getProperty("ANSWER"));
123 } 123 setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY")));
124 124 setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT")));
125 public static boolean getDefaultUseSkolemUpperBound() { 125
126 return DEFAULT_USE_SKOLEM_UPPER_BOUND; 126 } catch (IOException e) {
127 } 127 e.printStackTrace();
128 128 } finally {
129 public String getDataPath() { 129 if (inputStream != null)
130 return dataPath; 130 try {
131 } 131 inputStream.close();
132 132 } catch (IOException e) {
133 public void setDataPath(String path) { 133 e.printStackTrace();
134 dataPath = path; 134 }
135 } 135 }
136 136 }
137 public String getOntologyPath() { 137
138 return ontologyPath; 138 public PagodaProperties() {
139 } 139 }
140 140
141 public void setOntologyPath(String path) { 141 public static boolean isDebuggingMode() {
142 ontologyPath = path; 142 return debug;
143 } 143 }
144 144
145 public String getQueryPath() { 145 public static boolean getDefaultUseAlwaysSimpleUpperBound() {
146 return queryPath; 146 return DEFAULT_USE_ALWAYS_SIMPLE_UPPER_BOUND;
147 } 147 }
148 148
149 public void setQueryPath(String path) { 149 public static Path getDefaultStatisticsDir() {
150 queryPath = path; 150 return DEFAULT_STATISTICS_DIR;
151 } 151 }
152 152
153 public String getAnswerPath() { 153 public static SkolemUpperBoundOptions getDefaultSkolemUpperBound() {
154 return answerPath; 154 return DEFAULT_SKOLEM_UPPER_BOUND;
155 } 155 }
156 156
157 public void setAnswerPath(String path) { 157 public String getDataPath() {
158 answerPath = path; 158 return dataPath;
159 } 159 }
160 160
161 public boolean getToClassify() { 161 public void setDataPath(String path) {
162 return toClassify; 162 dataPath = path;
163 } 163 }
164 164
165 public void setToClassify(boolean flag) { 165 public String getOntologyPath() {
166 toClassify = flag; 166 return ontologyPath;
167 } 167 }
168 168
169 public boolean getToCallHermiT() { 169 public void setOntologyPath(String path) {
170 return toCallHermiT; 170 ontologyPath = path;
171 } 171 }
172 172
173 public void setToCallHermiT(boolean flag) { 173 public String getQueryPath() {
174 toCallHermiT = flag; 174 return queryPath;
175 } 175 }
176 176
177 public boolean getShellMode() { 177 public void setQueryPath(String path) {
178 return shellMode; 178 queryPath = path;
179 } 179 }
180 180
181 public void setShellMode(boolean flag) { 181 public String getAnswerPath() {
182 shellMode = flag; 182 return answerPath;
183 } 183 }
184 184
185 public boolean getUseAlwaysSimpleUpperBound() { 185 public void setAnswerPath(String path) {
186 return useAlwaysSimpleUpperBound; 186 answerPath = path;
187 } 187 }
188 188
189 public void setUseAlwaysSimpleUpperBound(boolean flag) { 189 public boolean getToClassify() {
190 useAlwaysSimpleUpperBound = flag; 190 return toClassify;
191 } 191 }
192 192
193 public boolean getUseSkolemUpperBound() { 193 public void setToClassify(boolean flag) {
194 return useSkolemUpperBound; 194 toClassify = flag;
195 } 195 }
196 196
197 public void setUseSkolemUpperBound(boolean flag) { 197 public boolean getToCallHermiT() {
198 useSkolemUpperBound = flag; 198 return toCallHermiT;
199 } 199 }
200 200
201 public Path getStatisticsDir() { 201 public void setToCallHermiT(boolean flag) {
202 return statisticsDir; 202 toCallHermiT = flag;
203 } 203 }
204 204
205 public void setStatisticsDir(Path statisticsDir) { 205 public boolean getShellMode() {
206 this.statisticsDir = statisticsDir; 206 return shellMode;
207 } 207 }
208
209 public void setShellMode(boolean flag) {
210 shellMode = flag;
211 }
212
213 public boolean getUseAlwaysSimpleUpperBound() {
214 return useAlwaysSimpleUpperBound;
215 }
216
217 public void setUseAlwaysSimpleUpperBound(boolean flag) {
218 useAlwaysSimpleUpperBound = flag;
219 }
220
221 public SkolemUpperBoundOptions getSkolemUpperBound() {
222 return skolemUpperBound;
223 }
224
225 public void setSkolemUpperBound(SkolemUpperBoundOptions flag) {
226 skolemUpperBound = flag;
227 }
228
229 public Path getStatisticsDir() {
230 return statisticsDir;
231 }
232
233 public void setStatisticsDir(Path statisticsDir) {
234 this.statisticsDir = statisticsDir;
235 }
208} 236}