From c0f5bdcdb29608532656c71c219680eccd4aad09 Mon Sep 17 00:00:00 2001 From: yzhou Date: Tue, 21 Apr 2015 22:45:35 +0100 Subject: fixed some bugs in windows server --- src/uk/ac/ox/cs/pagoda/util/Properties.java | 133 +++++++++++----------------- 1 file changed, 52 insertions(+), 81 deletions(-) (limited to 'src/uk/ac/ox/cs/pagoda/util/Properties.java') 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 @@ package uk.ac.ox.cs.pagoda.util; -import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.HashMap; +import java.io.InputStream; public class Properties { - - public static final String FILE_SEPARATOR = ";"; -// switches -// public static final String reuseGapFile = "REUSE_GAP"; - public static final String toTrackProofs = "TO_TRACK"; - public static final String checkAnswers = "TO_CHECK_ANSWERS"; - public static final String redirectSysOut = "TO_REDIRECT_SYS_OUT"; - public static final String considerEqualities = "TO_CONSIDER_EQUALITIES"; - -// parameters - public static final String testcase = "TEST_CASE"; - public static final String typeOfLowerBounds = "TYPE_LOWER_BOUNDS"; - public static final String FULL_REASONER = "OWLREASONER"; - -// file locations - public static final String ontologyFile = "LOWER_T_FILE"; - public static final String importedData = "IMPORT"; - public static final String queryFile = "QUERY_FILE"; - -// auxiliary files -// public static final String auxiliaryDirectory = "AUXILIARY_DIRECTORY"; -// public static final String queryAnswerGapFile = "GAP_FILE"; -// public static final String lowerAnswerFile = "LOWER_ANSWER_FILE"; -// public static final String upperAnswerFile = "UPPER_ANSWER_FILE"; -// public static final String boundsGapFile = "BOUNDS_GAP_FILE"; -// public static final String fragmentFile = "FRAGMENT_FILE"; + String dataPath = null; + public String getDataPath() { return dataPath; } + public void setDataPath(String path) { dataPath = path; } - public static final String correspondence = "CORRESPONDENCE"; - - private HashMap param = new HashMap(); - - public static final String on = String.valueOf(true); - public static final String off = String.valueOf(false); - - public void reset() { - param.clear(); -// param.put(reuseGapFile, on); - param.put(toTrackProofs, on); - param.put(checkAnswers, on); - param.put(redirectSysOut, off); - param.put(considerEqualities, off); - } - - public Properties() { - reset(); - } - - public void addImportedFile(String additionalDataFile) { - if (additionalDataFile == null) return ; - String files = param.get(importedData); - StringBuilder sb = new StringBuilder(); - if (files != null) - sb.append(files).append(FILE_SEPARATOR); - sb.append(additionalDataFile); - param.put(importedData, sb.toString()); - } + String ontologyPath; + public String getOntologyPath() { return ontologyPath; } + public void setOntologyPath(String path) { ontologyPath = path; } - public void load(String file) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String line; - String tokens[]; - while ((line = Utility.readLine(reader)) != null) { - if (line.isEmpty() || line.startsWith("#")) - continue; + String queryPath = null; + public String getQueryPath() { return queryPath; } + public void setQueryPath(String path) { queryPath = path; } + + String answerPath = null; + public String getAnswerPath() { return answerPath; } + public void setAnswerPath(String path) { answerPath = path; } + + boolean toClassify = true; + public boolean getToClassify() { return toClassify; } + public void setToClassify(boolean flag) { toClassify = flag; } + + boolean toCallHermiT = true; + public boolean getToCallHermiT() { return toCallHermiT; } + public void setToCallHermiT(boolean flag) { toCallHermiT = flag; } + + public static boolean ShellModeDefault = false; + + boolean shellMode = ShellModeDefault; + public boolean getShellMode() { return shellMode; } + public void setShellMode(boolean flag) { shellMode = flag; } + + public Properties(String path) { + java.util.Properties m_properties = new java.util.Properties(); + InputStream inputStream = null; + try { + inputStream = new FileInputStream(path); + m_properties.load(inputStream); - tokens = line.split("="); - if (tokens[1].equals("on")) - set(tokens[0], String.valueOf(true)); - else if (tokens[1].equals("off")) - set(tokens[0], String.valueOf(false)); - else - set(tokens[0], tokens[1]); + setOntologyPath(m_properties.getProperty("ONTOLOGY")); + setDataPath(m_properties.getProperty("DATA")); + setQueryPath(m_properties.getProperty("QUERY")); + setAnswerPath(m_properties.getProperty("ANSWER")); + setToClassify(Boolean.parseBoolean(m_properties.getProperty("TO_CLASSIFY"))); + setToCallHermiT(Boolean.parseBoolean(m_properties.getProperty("CALL_HERMIT"))); + + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (inputStream != null) + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } } - reader.close(); - } - - public String get(String key) { - return param.get(key); - } - - public void set(String key, String value) { - param.put(key, value); } + public Properties() { } } -- cgit v1.2.3