本文整理汇总了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;
}
示例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());
}
示例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;
}
示例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);
}
}
}