Search in sources :

Example 11 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 12 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)

Aggregations

Ini (org.ini4j.Ini)12 File (java.io.File)3 IOException (java.io.IOException)3 StringReader (java.io.StringReader)3 Map (java.util.Map)3 Profile (org.ini4j.Profile)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 URL (java.net.URL)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 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 FileNotFoundException (java.io.FileNotFoundException)1 ObjectInputStream (java.io.ObjectInputStream)1 Reader (java.io.Reader)1 StringWriter (java.io.StringWriter)1