aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/util/PagodaProperties.java
blob: be6627aa5682741fbf9a41897c813337e096dacb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package uk.ac.ox.cs.pagoda.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PagodaProperties {

	public static final String CONFIG_FILE = "pagoda.properties";

	public static final boolean DEFAULT_DEBUG = false;
	public static boolean shellModeDefault = false;
	private static boolean debug = DEFAULT_DEBUG;

	static {
		try(InputStream in = PagodaProperties.class.getClassLoader().getResourceAsStream(CONFIG_FILE)) {
			Properties config = new Properties();
			config.load(in);
			in.close();
			if(config.containsKey("debug")) {
				debug = Boolean.parseBoolean(config.getProperty("debug"));
			}
		} catch(IOException e) {
			e.printStackTrace();
		}
	}

	String dataPath = null;
	String ontologyPath;
	String queryPath = null;
	String answerPath = null;
	boolean toClassify = true;
	boolean toCallHermiT = true;
	boolean shellMode = shellModeDefault;

	public PagodaProperties(String path) {
		java.util.Properties m_properties = new java.util.Properties();
		InputStream inputStream = null;
		try {
			inputStream = new FileInputStream(path);
			m_properties.load(inputStream);

			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();
				}
		}
	}

	public PagodaProperties() {
	}

	public static boolean isDebuggingMode() {
		return debug;
	}

	public String getDataPath() {
		return dataPath;
	}

	public void setDataPath(String path) {
		dataPath = path;
	}

	public String getOntologyPath() {
		return ontologyPath;
	}

	public void setOntologyPath(String path) {
		ontologyPath = path;
	}

	public String getQueryPath() {
		return queryPath;
	}

	public void setQueryPath(String path) {
		queryPath = path;
	}

	public String getAnswerPath() {
		return answerPath;
	}

	public void setAnswerPath(String path) {
		answerPath = path;
	}

	public boolean getToClassify() {
		return toClassify;
	}

	public void setToClassify(boolean flag) {
		toClassify = flag;
	}

	public boolean getToCallHermiT() {
		return toCallHermiT;
	}

	public void setToCallHermiT(boolean flag) {
		toCallHermiT = flag;
	}

	public boolean getShellMode() {
		return shellMode;
	}

	public void setShellMode(boolean flag) {
		shellMode = flag;
	}

}