Example usage for org.apache.commons.configuration Configuration getKeys

List of usage examples for org.apache.commons.configuration Configuration getKeys

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getKeys.

Prototype

Iterator getKeys();

Source Link

Document

Get the list of the keys contained in the configuration.

Usage

From source file:org.eclipse.jubula.documentation.gen.ConfigGroup.java

/**
 * @param group/*from w  ww.ja v  a 2  s . com*/
 *            The name of the group read from the properties file
 * @param conf
 *            The configuration source (the properties file)
 */
public ConfigGroup(String group, Configuration conf) {
    Configuration subset = conf.subset(group);
    m_template = subset.getString(TEMPLATE);
    m_output = subset.getString(OUTPUT);
    m_generatorClass = subset.getString(GENERATOR);
    m_name = group;

    subset = subset.subset(GENERATOR);
    for (Iterator it = subset.getKeys(); it.hasNext();) {
        String key = (String) it.next();
        if (!StringConstants.EMPTY.equals(key)) {
            m_generatorProps.put(key, subset.getString(key));
        }
    }
}

From source file:org.eclipse.kapua.commons.setting.AbstractKapuaSetting.java

public <V> Map<String, V> getMap(Class<V> valueType, K prefixKey, String regex) {
    Map<String, V> map = new HashMap<String, V>();
    Configuration subsetConfig = config.subset(prefixKey.key());
    DataConfiguration subsetDataConfig = new DataConfiguration(subsetConfig);
    for (Iterator<String> it = subsetConfig.getKeys(); it.hasNext();) {
        String key = it.next();// ww  w  . j  ava 2  s .  c  om
        if (Pattern.matches(regex, key)) {
            map.put(key, subsetDataConfig.get(valueType, key));
        }
    }
    return map;
}

From source file:org.eclipse.kapua.commons.setting.AbstractKapuaSetting.java

public <V> Map<String, V> getMap(Class<V> valueType, K prefixKey) {
    Map<String, V> map = new HashMap<String, V>();
    Configuration subsetConfig = config.subset(prefixKey.key());
    DataConfiguration subsetDataConfig = new DataConfiguration(subsetConfig);
    for (Iterator<String> it = subsetConfig.getKeys(); it.hasNext();) {
        String key = it.next();//from  w w  w  . j  a  v  a2 s  . c o m
        map.put(key, subsetDataConfig.get(valueType, key));
    }
    return map;
}

From source file:org.investovator.core.commons.configuration.ConfigLoader.java

/**
 *
 * @param filePath specify path to the properties file
 * @throws ConfigurationException//from   w  w w.  j  a  va  2  s.co m
 */
public static void loadProperties(String filePath) throws ConfigurationException {

    Configuration configuration = new PropertiesConfiguration(new File(filePath).getAbsolutePath());

    Iterator<String> iterator = configuration.getKeys();
    while (iterator.hasNext()) {
        String key = iterator.next();
        String[] properties = configuration.getStringArray(key);
        StringBuilder value = new StringBuilder(properties[0]);
        for (int i = 1; i < properties.length; i++) {
            value.append(",").append(properties[i]);
        }
        System.setProperty(key, value.toString());
    }
}

From source file:org.janusgraph.hadoop.MapReduceIndexManagement.java

private static void copyInputKeys(org.apache.hadoop.conf.Configuration hadoopConf,
        org.apache.commons.configuration.Configuration source) {
    // Copy IndexUpdateJob settings into the hadoop-backed cfg
    Iterator<String> keyIter = source.getKeys();
    while (keyIter.hasNext()) {
        String key = keyIter.next();
        ConfigElement.PathIdentifier pid;
        try {//from w ww.j  a v a  2  s.  co m
            pid = ConfigElement.parse(ROOT_NS, key);
        } catch (RuntimeException e) {
            log.debug("[inputkeys] Skipping {}", key, e);
            continue;
        }

        if (!pid.element.isOption())
            continue;

        String k = ConfigElement.getPath(JanusGraphHadoopConfiguration.GRAPH_CONFIG_KEYS, true) + "." + key;
        String v = source.getProperty(key).toString();

        hadoopConf.set(k, v);
        log.debug("[inputkeys] Set {}={}", k, v);
    }
}

From source file:org.janusgraph.util.system.ConfigurationUtil.java

public static List<String> getUnqiuePrefixes(Configuration config) {
    Set<String> nameSet = new HashSet<String>();
    List<String> names = new ArrayList<String>();
    Iterator<String> keyiter = config.getKeys();
    while (keyiter.hasNext()) {
        String key = keyiter.next();
        int pos = key.indexOf(CONFIGURATION_SEPARATOR);
        if (pos > 0) {
            String name = key.substring(0, pos);
            if (nameSet.add(name)) {
                names.add(name);/*from  w  w w . j a  v a  2s . co m*/
            }
        }
    }
    return names;
}

From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtil.java

/**
 * Get a map of configuration nodes mapped to the names of the children of the parent parameter.
 *
 * @param config Configuration object, may be a subset of the configuration tree.
 * @param parent Path to the parent node.
 * @return A map of all the children for the parent configuration node passed.
 *//*from   w ww .  java 2 s.  c  o  m*/
public static Map<String, Configuration> childMap(Configuration config, String parent) {
    if (config == null)
        throw new IllegalArgumentException("Parameter config may not be null.");

    if (parent != null && !parent.isEmpty()) {
        config = config.subset(parent);
    }

    Iterator<String> keys = config.getKeys();
    Map<String, Configuration> map = new LinkedHashMap<>();
    while (keys.hasNext()) {
        String key = keys.next();
        key = key.split("\\.", 2)[0];
        if (!map.containsKey(key)) {
            map.put(key, config.subset(key));
        }
    }
    return map;
}

From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtil.java

/**
 * Get the list of child keys for a configuration node.
 *
 * @param config Configuration object, may be a subset of the configuration tree.
 * @param parent Path to the parent node.
 * @return A string array containing the names of the children.
 */// w w  w  . j av  a  2 s  .co  m
public static Set<String> childKeys(Configuration config, String parent) {
    if (config == null)
        throw new IllegalArgumentException("Parameter config may not be null.");

    if (parent != null && !parent.isEmpty()) {
        config = config.subset(parent);
    }

    Iterator keys = config.getKeys();
    Set<String> list = new HashSet<>();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        key = key.split("\\.", 2)[0];
        list.add(key);
    }
    return list;
}

From source file:org.loggo.server.KafkaConsumer.java

private static Properties asProperties(Configuration conf) {
    Properties result = new Properties();
    @SuppressWarnings("rawtypes")
    Iterator keys = conf.getKeys();
    while (keys.hasNext()) {
        String key = keys.next().toString();
        result.setProperty(key, conf.getProperty(key).toString());
    }/*from  w  ww  . ja va2  s  .c  om*/
    return result;
}

From source file:org.neo4j.server.NeoServerWithEmbeddedWebServer.java

@Override
public void start() {
    // Start at the bottom of the stack and work upwards to the Web
    // container//from   ww  w  .  j av  a2s . c o  m
    startupHealthCheck();

    initWebServer();

    StringLogger logger = startDatabase();

    if (logger != null) {
        logger.logMessage("--- SERVER STARTUP START ---");

        Configuration configuration = configurator.configuration();
        logger.logMessage("Server configuration:");
        for (Object key : IteratorUtil.asIterable(configuration.getKeys())) {
            if (key instanceof String)
                logger.logMessage("  " + key + " = " + configuration.getProperty((String) key));
        }
    }

    startExtensionInitialization();

    startModules(logger);

    startWebServer(logger);

    if (logger != null)
        logger.logMessage("--- SERVER STARTUP END ---", true);
}