Java Code Examples for org.apache.commons.configuration.Configuration.getKeys()

The following are Jave code examples for showing how to use getKeys() of the org.apache.commons.configuration.Configuration class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jbake-rtl-jalaali   File: AsciidoctorEngine.java   Source Code and License Vote up 6 votes
private Options getAsciiDocOptionsAndAttributes(ParserContext context) {
    Configuration config = context.getConfig();
    final AttributesBuilder attributes = attributes(config.getStringArray(Keys.ASCIIDOCTOR_ATTRIBUTES));
    if (config.getBoolean(Keys.ASCIIDOCTOR_ATTRIBUTES_EXPORT, false)) {
        final String prefix = config.getString(  Keys.ASCIIDOCTOR_ATTRIBUTES_EXPORT_PREFIX, "");
        for (final Iterator<String> it = config.getKeys(); it.hasNext();) {
            final String key = it.next();
            if (!key.startsWith("asciidoctor")) {
                attributes.attribute(prefix + key.replace(".", "_"), config.getProperty(key));
            }
        }
    }
    final Configuration optionsSubset = config.subset(Keys.ASCIIDOCTOR_OPTION);
    final Options options = options().attributes(attributes.get()).get();
    for (final Iterator<String> iterator = optionsSubset.getKeys(); iterator.hasNext();) {
        final String name = iterator.next();
        if (name.equals(Options.TEMPLATE_DIRS)) {
        	options.setTemplateDirs(optionsSubset.getString(name));
        } else {
        	options.setOption(name,  guessTypeByContent(optionsSubset.getString(name)));
        }
    }
    options.setBaseDir(context.getFile().getParentFile().getAbsolutePath());
    options.setSafe(UNSAFE);
    return options;
}
 
Example 2
Project: incubator-servicecomb-java-chassis   File: ConfigurePropertyUtils.java   Source Code and License Vote up 5 votes
public static Map<String, String> getPropertiesWithPrefix(Configuration configuration, String prefix) {
  Map<String, String> propertiesMap = new HashMap<>();

  Iterator<String> keysIterator = configuration.getKeys(prefix);
  while (keysIterator.hasNext()) {
    String key = keysIterator.next();
    propertiesMap.put(key.substring(prefix.length() + 1), String.valueOf(configuration.getProperty(key)));
  }
  return propertiesMap;
}
 
Example 3
Project: spring-configuration-support   File: DatabaseConfigurationPropertiesFactoryBean.java   Source Code and License Vote up 5 votes
/**
 * Creates a properties instance with the key/value pairs specified within the passed configuration object.
 *
 * @param configuration the configuration
 * @return the populated properties instance
 */
protected Properties createPropertiesForConfiguration(Configuration configuration){

	Properties properties = new Properties();

	final Iterator keys = configuration.getKeys();
	while (keys.hasNext()) {
		String key = (String) keys.next();
		List list = configuration.getList(key);
		properties.setProperty(key, (String) list.get(0));
	}

	return properties;
}
 
Example 4
Project: momo-2   File: Bot.java   Source Code and License Vote up 5 votes
public boolean loadProperties() {
	try (FileInputStream finput = new FileInputStream("resources/Bot.properties")) {
		PropertiesConfiguration config = new PropertiesConfiguration();
		config.load(finput, "UTF-8");
		config.setEncoding("UTF-8");
		botConfig.setToken(config.getString("BotToken"));
		botConfig.setAvatar(config.getString("Avatar"));
		botConfig.setBotOwnerId(config.getLong("BotOwnerId", 0));
		botConfig.setBotInviteLink(config.getString("InviteLink"));
		botConfig.setMaxSongLength(config.getInt("MaxSongLength", 15));
		botConfig.setCompanionBot(config.getBoolean("MusicCompanion", false));
		botConfig.setDefaultSSLPort(config.getInt("DefaultSSLPort", 8443));
		botConfig.setDefaultInsecurePort(config.getInt("DefaultInsecurePort", 8080));

		Configuration subset = config.subset("apikey");
		Iterator<String> iter = subset.getKeys();
		while(iter.hasNext()) {
			String key = iter.next();
			String val = subset.getString(key);
			if(val.length() > 0) {
				this.apiKeys.put(key, val);
				logger.info("Added API key for: {}", key);
			}
		}
		StatusChangeJob.setStatuses(config.getStringArray("StatusRotation"));
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
Example 5
Project: KantaCDA-API   File: MaarittelyKonfiguraatio.java   Source Code and License Vote up 3 votes
@SuppressWarnings("unchecked")
private MaarittelyKonfiguraatio() throws ConfigurationException {
    maarittelyt = new HashMap<String, MaarittelyLuokka>();

    try {
        Configuration config = new PropertiesConfiguration("cda_template.properties");

        Iterator<String> templateIds = (Iterator<String>) config.getKeys();
        while (templateIds.hasNext()) {
            kasitteleTyyppi(config, templateIds.next());
        }
    }
    catch (ConfigurationException e) {
        throw e;
    }
}