diff options
| author | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
|---|---|---|
| committer | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
| commit | 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch) | |
| tree | 47511c0fb89dccff0db4b5990522e04f294d795b /src/uk/ac/ox/cs/pagoda/util/Properties.java | |
| parent | b1ac207612ee8b045244253fb94b866104bc34f2 (diff) | |
| download | ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.tar.gz ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.zip | |
initial version
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/util/Properties.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/util/Properties.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/util/Properties.java b/src/uk/ac/ox/cs/pagoda/util/Properties.java new file mode 100644 index 0000000..551f94f --- /dev/null +++ b/src/uk/ac/ox/cs/pagoda/util/Properties.java | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.util; | ||
| 2 | |||
| 3 | import java.io.BufferedReader; | ||
| 4 | import java.io.FileInputStream; | ||
| 5 | import java.io.IOException; | ||
| 6 | import java.io.InputStreamReader; | ||
| 7 | import java.util.HashMap; | ||
| 8 | |||
| 9 | public class Properties { | ||
| 10 | |||
| 11 | public static final String FILE_SEPARATOR = ";"; | ||
| 12 | |||
| 13 | // switches | ||
| 14 | // public static final String reuseGapFile = "REUSE_GAP"; | ||
| 15 | public static final String toTrackProofs = "TO_TRACK"; | ||
| 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 | |||
| 38 | public static final String correspondence = "CORRESPONDENCE"; | ||
| 39 | |||
| 40 | private HashMap<String, String> param = new HashMap<String, String>(); | ||
| 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 | |||
| 68 | public void load(String file) throws IOException { | ||
| 69 | BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); | ||
| 70 | String line; | ||
| 71 | String tokens[]; | ||
| 72 | while ((line = Utility.readLine(reader)) != null) { | ||
| 73 | if (line.isEmpty() || line.startsWith("#")) | ||
| 74 | continue; | ||
| 75 | |||
| 76 | tokens = line.split("="); | ||
| 77 | if (tokens[1].equals("on")) | ||
| 78 | set(tokens[0], String.valueOf(true)); | ||
| 79 | else if (tokens[1].equals("off")) | ||
| 80 | set(tokens[0], String.valueOf(false)); | ||
| 81 | else | ||
| 82 | set(tokens[0], tokens[1]); | ||
| 83 | } | ||
| 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 | } | ||
| 94 | |||
| 95 | } | ||
