当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.getKeys方法代码示例

本文整理汇总了Java中org.apache.commons.configuration2.Configuration.getKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getKeys方法的具体用法?Java Configuration.getKeys怎么用?Java Configuration.getKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.configuration2.Configuration的用法示例。


在下文中一共展示了Configuration.getKeys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetchTableMap

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
private HashMap<String, String> fetchTableMap(String dataSource)
    throws ConfigurationException, BiremeException {
  Configurations configs = new Configurations();
  Configuration tableConfig = null;

  tableConfig = configs.properties(new File(DEFAULT_TABLEMAP_DIR + dataSource + ".properties"));

  String originTable, mappedTable;
  HashMap<String, String> localTableMap = new HashMap<String, String>();
  Iterator<String> tables = tableConfig.getKeys();

  while (tables.hasNext()) {
    originTable = tables.next();
    mappedTable = tableConfig.getString(originTable);

    if (originTable.split("\\.").length != 2 || mappedTable.split("\\.").length != 2) {
      String message = "Wrong format: " + originTable + ", " + mappedTable;
      logger.fatal(message);
      throw new BiremeException(message);
    }

    localTableMap.put(dataSource + "." + originTable, mappedTable);

    if (!tableMap.values().contains(mappedTable)) {
      loadersCount++;
    }
    tableMap.put(dataSource + "." + originTable, mappedTable);
  }

  return localTableMap;
}
 
开发者ID:HashDataInc,项目名称:bireme,代码行数:32,代码来源:Config.java

示例2: clearKeys

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
private static void clearKeys(Configuration conf, String key)
{
	if (conf.containsKey(key))
		conf.clearProperty(key);
	Iterator<String> keys = conf.getKeys(key);
	while (keys.hasNext())
		conf.clearProperty(keys.next());
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:9,代码来源:RuntimeJavaMain.java

示例3: asProperties

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
public static Properties asProperties(Configuration config)
{
	Properties result = new Properties();
	for (Iterator it = config.getKeys(); it.hasNext();)
	{
		String key = (String) it.next();
		result.setProperty(key, config.getProperty(key).toString());
	}
	return result;
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:11,代码来源:ConfigUtils.java

示例4: test

import org.apache.commons.configuration2.Configuration; //导入方法依赖的package包/类
@Test
public void test() {

    for (ConfigurationType type : ConfigurationType.values()) {

        Configuration conf = type.get().orElse(null);

        Map<String, String> map = new HashMap<>();

        if (conf != null) {
            for (Iterator<String> itr = conf.getKeys(); itr.hasNext(); ) {
                String key = itr.next();
                map.put(key, conf.getString(key));
            }
        }

        switch (type) {
            case VERSION:
                assertNotNull(conf.getString(VERSION.getKey()));
                assertEquals(map.size(), 1);
                break;
            case SYSTEM:
                List<?> system = Collections.list(System.getProperties().propertyNames());
                system.forEach(o -> assertTrue(conf.containsKey(o.toString()), "Missing : " + o));
                assertEquals(map.size(), system.size());
                break;
            case HOME:
                // Do nothing. (Dependent on the test machine.)
                break;
            case SITE:
                assertEquals(conf.getString(VERSION.getKey()), "test");
                assertEquals(conf.getString(SITE.getKey()), "test");
                break;
            default:
                fail("Unknown type : " + type);

        }

    }

}
 
开发者ID:after-the-sunrise,项目名称:bitflyer4j,代码行数:42,代码来源:ConfigurationTypeTest.java


注:本文中的org.apache.commons.configuration2.Configuration.getKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。