Search in sources :

Example 16 with Ini

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;
}
Also used : Ini(org.ini4j.Ini) IOption(org.apache.hyracks.api.config.IOption) HashMap(java.util.HashMap) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Map(java.util.Map) EnumMap(java.util.EnumMap) TreeMap(java.util.TreeMap) CompositeMap(org.apache.commons.collections4.map.CompositeMap) SortedMap(java.util.SortedMap)

Example 17 with 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;
}
Also used : Ini(org.ini4j.Ini) URL(java.net.URL)

Example 18 with Ini

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, "", "");
    }
}
Also used : Ini(org.ini4j.Ini) ArrayList(java.util.ArrayList) File(java.io.File)

Example 19 with Ini

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);
    }
}
Also used : InvalidFileFormatException(org.ini4j.InvalidFileFormatException) Ini(org.ini4j.Ini) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 20 with Ini

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;
}
Also used : Ini(org.ini4j.Ini) By(org.openqa.selenium.By)

Aggregations

Ini (org.ini4j.Ini)24 File (java.io.File)9 IOException (java.io.IOException)6 StringReader (java.io.StringReader)3 URL (java.net.URL)3 Map (java.util.Map)3 Profile (org.ini4j.Profile)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 EnumMap (java.util.EnumMap)2 HashMap (java.util.HashMap)2 SortedMap (java.util.SortedMap)2 TreeMap (java.util.TreeMap)2 CompositeMap (org.apache.commons.collections4.map.CompositeMap)2 ArrayListValuedHashMap (org.apache.commons.collections4.multimap.ArrayListValuedHashMap)2 IOption (org.apache.hyracks.api.config.IOption)2 Config (org.ini4j.Config)2 Hypervisor (com.cloud.hypervisor.Hypervisor)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1