use of org.ini4j.Ini in project NoraUi by NoraUi.
the class Utilities method getSelectorValue.
/**
* @param applicationKey
* is key of application
* @param code
* is key of selector (CAUTION: if you use any % char. {@link String#format(String, Object...)})
* @param args
* is list of args ({@link String#format(String, Object...)})
* @return the selector
*/
public static String getSelectorValue(String applicationKey, String code, Object... args) {
String selector = "";
logger.debug("getLocator with this application key : {}", applicationKey);
logger.debug("getLocator with this locator file : {}", Context.iniFiles.get(applicationKey));
final Ini ini = Context.iniFiles.get(applicationKey);
final Map<String, String> section = ini.get(code);
if (section != null) {
final Entry<String, String> entry = section.entrySet().iterator().next();
selector = String.format(entry.getValue(), args);
}
return selector;
}
use of org.ini4j.Ini in project iri by iotaledger.
the class Configuration method init.
public boolean init() throws IOException {
File confFile = new File(string(Configuration.DefaultConfSettings.CONFIG));
if (confFile.exists()) {
ini = new Ini(confFile);
prefs = new IniPreferences(ini);
return true;
}
return false;
}
use of org.ini4j.Ini in project MSEC by Tencent.
the class ServiceFactory method getConfig.
public static String getConfig(String section, String key) {
Ini ini = new Ini();
try {
ini.load(new File(SRPC_CONF_PATH));
Profile.Section sec = ini.get(section);
if (sec != null) {
return sec.get(key);
}
} catch (IOException e) {
log.error("get config " + section + ":" + key + " failed.", e);
}
return null;
}
use of org.ini4j.Ini in project MSEC by Tencent.
the class AddSecondLevelServiceConfigTag method addPortConfig.
public void addPortConfig(String filename, int port) throws Exception {
final String SECTION_NAME = "SRPC";
final String KEY = "listen";
// listen=e123/udp 234/tcp
final String VALUE = String.format("%d/udp %d/tcp", port, port);
Ini ini = new Ini();
ini.load(new File(filename));
Ini.Section section = ini.get(SECTION_NAME);
boolean bChanged = false;
if (section == null) {
section = ini.add(SECTION_NAME);
section.add(KEY, VALUE);
bChanged = true;
} else {
String valueStr = section.get(KEY);
if (valueStr == null) {
section.add(KEY, VALUE);
bChanged = true;
} else {
if (!valueStr.equalsIgnoreCase(VALUE)) {
// logger.error("port config exists,but value mismatch!"+valueStr+"!="+VALUE);
section.put(KEY, VALUE);
bChanged = true;
}
}
}
if (bChanged) {
ini.store(new File(filename));
}
}
Aggregations