List of usage examples for org.apache.commons.configuration Configuration getKeys
Iterator getKeys();
From source file:com.germinus.easyconf.ConfUtil.java
public static String toString(Configuration configuration) { Iterator it = configuration.getKeys(); StringBuffer result = new StringBuffer(); result.append("{"); while (it.hasNext()) { String key = (String) it.next(); result.append(key + "=" + configuration.getProperty(key)); result.append(", "); }//from w ww .j av a 2s . c o m result.append("}"); return result.toString(); }
From source file:com.twitter.distributedlog.util.ConfUtils.java
/** * Load configurations with prefixed <i>section</i> from source configuration <i>srcConf</i> into * target configuration <i>targetConf</i>. * * @param targetConf/*from ww w .j ava2 s .c o m*/ * Target Configuration * @param srcConf * Source Configuration * @param section * Section Key */ public static void loadConfiguration(Configuration targetConf, Configuration srcConf, String section) { Iterator confKeys = srcConf.getKeys(); while (confKeys.hasNext()) { Object keyObject = confKeys.next(); if (!(keyObject instanceof String)) { continue; } String key = (String) keyObject; if (key.startsWith(section)) { targetConf.setProperty(key.substring(section.length()), srcConf.getProperty(key)); } } }
From source file:com.kixeye.chassis.bootstrap.configuration.Configurations.java
public static Map<String, ?> asMap(Configuration configuration) { Map<String, Object> config = new TreeMap<>(); Iterator<String> keys = configuration.getKeys(); while (keys.hasNext()) { String key = keys.next(); config.put(key, configuration.getProperty(key)); }//w ww . j a va 2 s . c om return config; }
From source file:net.sf.zekr.common.util.ConfigUtils.java
@SuppressWarnings("unchecked") public static void write(Configuration configuration, Writer w) throws IOException { Iterator keys = configuration.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); Object value = configuration.getProperty(key); w.write(key);/*from w w w .j ava2 s . co m*/ w.write(" = "); if (value instanceof Collection) { w.write(CollectionUtils.toString((List) value, ", ")); } else { w.write(ObjectUtils.toString(value)); } if (keys.hasNext()) { w.write(GlobalConfig.LINE_SEPARATOR); } } }
From source file:com.cisco.oss.foundation.http.server.TraceWrapper.java
public static List<String> getContentTypes(String serviceName) { List<String> types = new ArrayList<String>(5); String baseKey = serviceName + ".http.traceFilter.textContentTypes"; Configuration subset = ConfigurationFactory.getConfiguration().subset(baseKey); Iterator<String> keys = subset.getKeys(); while (keys.hasNext()) { String key = keys.next(); types.add(subset.getString(key)); }/*from w ww .ja v a 2 s . c o m*/ return types; }
From source file:com.xemantic.tadedon.guice.configuration.GuiceConfigurations.java
public static void bindProperties(Binder binder, Configuration configuration) { for (@SuppressWarnings("unchecked") Iterator<String> iterator = configuration.getKeys(); iterator.hasNext();) { String key = iterator.next(); Object property = configuration.getProperty(key); if (property instanceof String) { String value = (String) property; binder.bindConstant().annotatedWith(Names.named(key)).to(value); } else if (property instanceof Collection) { List<String> list = new ArrayList<String>((Collection) property); binder.bind(new TypeLiteral<List<String>>() { }).annotatedWith(Names.named(key)).toInstance(list); } else {//w w w. j a va 2 s . c om throw new UnsupportedPropertyTypeExeception(property.getClass()); } } }
From source file:com.opensoc.json.serialization.JSONEncoderHelper.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static JSONObject getJSON(Configuration config) { JSONObject output = new JSONObject(); if (!config.isEmpty()) { Iterator it = config.getKeys(); while (it.hasNext()) { String k = (String) it.next(); // noinspection unchecked String v = (String) config.getProperty(k); output.put(k, v);//from w w w . ja va 2 s.c o m } } return output; }
From source file:com.linkedin.pinot.broker.broker.helix.DefaultHelixBrokerConfig.java
public static Configuration getDefaultBrokerConf(Configuration externalConfigs) { final Configuration defaultConfigs = getDefaultBrokerConf(); @SuppressWarnings("unchecked") Iterator<String> iterable = externalConfigs.getKeys(); while (iterable.hasNext()) { String key = iterable.next(); defaultConfigs.setProperty(key, externalConfigs.getProperty(key)); }/*from w ww.j a va 2 s . co m*/ return defaultConfigs; }
From source file:com.zavakid.mushroom.impl.ConfigUtil.java
static void assertEq(Configuration expected, Configuration actual) { // Check that the actual config contains all the properties of the expected for (Iterator<?> it = expected.getKeys(); it.hasNext();) { String key = (String) it.next(); assertTrue("actual should contain " + key, actual.containsKey(key)); assertEquals("value of " + key, expected.getProperty(key), actual.getProperty(key)); }// w w w . j a v a 2 s . c o m // Check that the actual config has no extra properties for (Iterator<?> it = actual.getKeys(); it.hasNext();) { String key = (String) it.next(); assertTrue("expected should contain " + key, expected.containsKey(key)); } }
From source file:com.linkedin.pinot.server.starter.helix.DefaultHelixStarterServerConfig.java
public static ServerConf getDefaultHelixServerConfig(Configuration externalConfigs) { Configuration defaultConfigs = loadDefaultServerConf(); @SuppressWarnings("unchecked") Iterator<String> iterable = externalConfigs.getKeys(); while (iterable.hasNext()) { String key = iterable.next(); defaultConfigs.setProperty(key, externalConfigs.getProperty(key)); LOGGER.info("External config key: {}, value: {}", key, externalConfigs.getProperty(key)); }//from ww w . jav a 2s . c o m return new ServerConf(defaultConfigs); }