MCPcopy Create free account
hub / github.com/ddf-project/DDF / loadConfig

Method loadConfig

core/src/main/java/io/ddf/util/ConfigHandler.java:151–188  ·  view source on GitHub ↗

Load configuration from ddf.ini, or the file name specified by the environment variable DDF_INI. @return the Configuration object loaded @throws Exception @throws ConfigurationException , IOException

()

Source from the content-addressed store, hash-verified

149 * @throws ConfigurationException , {@link IOException}
150 */
151 @Override
152 public Configuration loadConfig() throws ConfigurationException, IOException {
153
154 Configuration resultConfig = new Configuration();
155
156 if (!Utils.localFileExists(this.getConfigFileName())) {
157 // String configFileName = System.getenv(ConfigConstant.DDF_INI_ENV_VAR.getValue());
158 File file = new File(this.locateConfigFileName(this.getConfigDir(), this.getConfigFileName()));
159 mConfigDir = file.getParentFile().getName();
160 mConfigFileName = file.getCanonicalPath();
161 }
162
163 if (!Utils.localFileExists(this.getConfigFileName())) return null;
164
165 HierarchicalINIConfiguration config = new HierarchicalINIConfiguration(this.getConfigFileName());
166
167 @SuppressWarnings("unchecked")
168 Set<String> sectionNames = config.getSections();
169 for (String sectionName : sectionNames) {
170 SubnodeConfiguration section = config.getSection(sectionName);
171 if (section != null) {
172 Configuration.Section resultSection = resultConfig.getSection(sectionName);
173
174 @SuppressWarnings("unchecked")
175 Iterator<String> keys = section.getKeys();
176 while (keys.hasNext()) {
177 String key = keys.next();
178 String value = section.getString(key);
179 if (value != null) {
180 resultSection.set(key, value);
181 }
182 }
183 }
184 }
185
186 mConfig = resultConfig;
187 return mConfig;
188 }
189
190 @Override
191 public void setConfig(Configuration theConfig) {

Callers 1

getConfigMethod · 0.95

Calls 10

localFileExistsMethod · 0.95
getConfigFileNameMethod · 0.95
locateConfigFileNameMethod · 0.95
getConfigDirMethod · 0.95
getSectionMethod · 0.95
getNameMethod · 0.65
getSectionsMethod · 0.65
getSectionMethod · 0.65
getKeysMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected