aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/util/Properties.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util/Properties.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/util/Properties.java133
1 files changed, 52 insertions, 81 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/Properties.java b/src/uk/ac/ox/cs/pagoda/util/Properties.java
index 551f94f..b687b53 100644
--- a/src/uk/ac/ox/cs/pagoda/util/Properties.java
+++ b/src/uk/ac/ox/cs/pagoda/util/Properties.java
@@ -1,95 +1,66 @@
1package uk.ac.ox.cs.pagoda.util; 1package uk.ac.ox.cs.pagoda.util;
2 2
3import java.io.BufferedReader;
4import java.io.FileInputStream; 3import java.io.FileInputStream;
5import java.io.IOException; 4import java.io.IOException;
6import java.io.InputStreamReader; 5import java.io.InputStream;
7import java.util.HashMap;
8 6
9public class Properties { 7public class Properties {
10
11 public static final String FILE_SEPARATOR = ";";
12 8
13// switches 9 String dataPath = null;
14// public static final String reuseGapFile = "REUSE_GAP"; 10 public String getDataPath() { return dataPath; }
15 public static final String toTrackProofs = "TO_TRACK"; 11 public void setDataPath(String path) { dataPath = path; }
16 public static final String checkAnswers = "TO_CHECK_ANSWERS";
17 public static final String redirectSysOut = "TO_REDIRECT_SYS_OUT";
18 public static final String considerEqualities = "TO_CONSIDER_EQUALITIES";
19
20// parameters
21 public static final String testcase = "TEST_CASE";
22 public static final String typeOfLowerBounds = "TYPE_LOWER_BOUNDS";
23 public static final String FULL_REASONER = "OWLREASONER";
24
25// file locations
26 public static final String ontologyFile = "LOWER_T_FILE";
27 public static final String importedData = "IMPORT";
28 public static final String queryFile = "QUERY_FILE";
29
30// auxiliary files
31// public static final String auxiliaryDirectory = "AUXILIARY_DIRECTORY";
32// public static final String queryAnswerGapFile = "GAP_FILE";
33// public static final String lowerAnswerFile = "LOWER_ANSWER_FILE";
34// public static final String upperAnswerFile = "UPPER_ANSWER_FILE";
35// public static final String boundsGapFile = "BOUNDS_GAP_FILE";
36// public static final String fragmentFile = "FRAGMENT_FILE";
37 12
38 public static final String correspondence = "CORRESPONDENCE"; 13 String ontologyPath;
39 14 public String getOntologyPath() { return ontologyPath; }
40 private HashMap<String, String> param = new HashMap<String, String>(); 15 public void setOntologyPath(String path) { ontologyPath = path; }
41
42 public static final String on = String.valueOf(true);
43 public static final String off = String.valueOf(false);
44
45 public void reset() {
46 param.clear();
47// param.put(reuseGapFile, on);
48 param.put(toTrackProofs, on);
49 param.put(checkAnswers, on);
50 param.put(redirectSysOut, off);
51 param.put(considerEqualities, off);
52 }
53
54 public Properties() {
55 reset();
56 }
57
58 public void addImportedFile(String additionalDataFile) {
59 if (additionalDataFile == null) return ;
60 String files = param.get(importedData);
61 StringBuilder sb = new StringBuilder();
62 if (files != null)
63 sb.append(files).append(FILE_SEPARATOR);
64 sb.append(additionalDataFile);
65 param.put(importedData, sb.toString());
66 }
67 16
68 public void load(String file) throws IOException { 17 String queryPath = null;
69 BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); 18 public String getQueryPath() { return queryPath; }
70 String line; 19 public void setQueryPath(String path) { queryPath = path; }
71 String tokens[]; 20
72 while ((line = Utility.readLine(reader)) != null) { 21 String answerPath = null;
73 if (line.isEmpty() || line.startsWith("#")) 22 public String getAnswerPath() { return answerPath; }
74 continue; 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);
75 45
76 tokens = line.split("="); 46 setOntologyPath(m_properties.getProperty("ONTOLOGY"));
77 if (tokens[1].equals("on")) 47 setDataPath(m_properties.getProperty("DATA"));
78 set(tokens[0], String.valueOf(true)); 48 setQueryPath(m_properties.getProperty("QUERY"));
79 else if (tokens[1].equals("off")) 49 setAnswerPath(m_properties.getProperty("ANSWER"));
80 set(tokens[0], String.valueOf(false)); 50 setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY")));
81 else 51 setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT")));
82 set(tokens[0], tokens[1]); 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 }
83 } 62 }
84 reader.close();
85 }
86
87 public String get(String key) {
88 return param.get(key);
89 }
90
91 public void set(String key, String value) {
92 param.put(key, value);
93 } 63 }
64 public Properties() { }
94 65
95} 66}