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;
}
use of org.ini4j.Ini in project CyberpunkZombieSurvival_JVM by zunath.
the class AreaInstanceSystem method LoadAreasFromDisk.
private static void LoadAreasFromDisk() {
String folderPath;
try {
Ini ini = new Ini(new File("./nwnx.ini"));
folderPath = ini.get("RESOURCEMANAGER", "sourcepath");
} catch (Exception ex) {
folderPath = "resman";
}
File folder = new File("./" + folderPath + "/are");
File[] files = folder.listFiles();
ArrayList<String> resrefs = new ArrayList<>();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
String resref = file.getName();
int pos = resref.lastIndexOf(".");
if (pos > 0) {
resref = resref.substring(0, pos);
}
resrefs.add(resref);
}
}
}
for (String resref : resrefs) {
NWScript.createArea(resref, "", "");
}
}
use of org.ini4j.Ini in project NoraUi by NoraUi.
the class Context method initApplicationDom.
protected static void initApplicationDom(ClassLoader loader, String version, String applicationKey) {
try {
final InputStream data = loader.getResourceAsStream("selectors/" + version + "/" + applicationKey + ".ini");
if (data != null) {
final Ini ini = new Ini(data);
iniFiles.put(applicationKey, ini);
}
} catch (final InvalidFileFormatException e) {
logger.error("error Context.initApplicationDom()", e);
} catch (final IOException e) {
logger.error(Messages.getMessage(CONTEXT_APP_INI_FILE_NOT_FOUND), applicationKey, e);
}
}
use of org.ini4j.Ini in project NoraUi by NoraUi.
the class Utilities method getLocator.
/**
* This method read a application descriptor file and return a {@link org.openqa.selenium.By} object (xpath, id, link ...).
*
* @param applicationKey
* Name of application. Each application has its fair description file.
* @param code
* Name of element on the web Page.
* @param args
* list of description (xpath, id, link ...) for code.
* @return a {@link org.openqa.selenium.By} object (xpath, id, link ...)
*/
public static By getLocator(String applicationKey, String code, Object... args) {
By locator = null;
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();
final String selector = String.format(entry.getValue(), args);
if ("css".equals(entry.getKey())) {
locator = By.cssSelector(selector);
} else if ("link".equals(entry.getKey())) {
locator = By.linkText(selector);
} else if ("id".equals(entry.getKey())) {
locator = By.id(selector);
} else if ("name".equals(entry.getKey())) {
locator = By.name(selector);
} else if ("xpath".equals(entry.getKey())) {
locator = By.xpath(selector);
} else if ("class".equals(entry.getKey())) {
locator = By.className(selector);
} else {
Assert.fail(entry.getKey() + " NOT implemented!");
}
} else {
Assert.fail(code + " NOT implemented in ini file " + Context.iniFiles.get(applicationKey) + "!");
}
return locator;
}
Aggregations