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