use of org.ini4j.Ini in project asterixdb by apache.
the class ConfigManager method toIni.
public Ini toIni(boolean includeDefaults) {
Ini ini = new Ini();
for (Map.Entry<IOption, Object> entry : (includeDefaults ? configurationMap : definedMap).entrySet()) {
if (entry.getValue() != null) {
final IOption option = entry.getKey();
ini.add(option.section().sectionName(), option.ini(), option.type().serializeToIni(entry.getValue()));
}
}
for (Map.Entry<String, Map<IOption, Object>> nodeMapEntry : nodeSpecificMap.entrySet()) {
String section = Section.NC.sectionName() + "/" + nodeMapEntry.getKey();
for (Map.Entry<IOption, Object> entry : nodeMapEntry.getValue().entrySet()) {
if (entry.getValue() != null) {
final IOption option = entry.getKey();
ini.add(section, option.ini(), option.type().serializeToIni(entry.getValue()));
}
}
}
return ini;
}
use of org.ini4j.Ini in project asterixdb by apache.
the class ConfigUtils method getOptionValue.
public static String getOptionValue(String[] args, IOption option) throws IOException {
String value = getOptionValue(args, option.cmdline());
if (value == null) {
Ini iniFile = null;
String configFile = getOptionValue(args, ControllerConfig.Option.CONFIG_FILE.cmdline());
String configFileUrl = getOptionValue(args, ControllerConfig.Option.CONFIG_FILE_URL.cmdline());
if (configFile != null) {
iniFile = loadINIFile(configFile);
} else if (configFileUrl != null) {
iniFile = loadINIFile(new URL(configFileUrl));
}
if (iniFile != null) {
value = iniFile.get(option.section().sectionName(), option.ini());
}
}
return value;
}
Aggregations