List of usage examples for org.apache.commons.configuration PropertiesConfiguration getKeys
public Iterator getKeys()
Iterator
with the keys contained in this configuration. From source file:com.carmatech.maven.utils.MergeUtils.java
public static void putAll(final PropertiesConfiguration target, final PropertiesConfiguration source) { for (final Iterator<String> sourceKeys = source.getKeys(); sourceKeys.hasNext();) { final String key = sourceKeys.next(); final Object value = source.getProperty(key); target.setProperty(key, value);/*w w w . j a v a 2 s.c o m*/ } }
From source file:com.obidea.semantika.database.connection.ConnectionProviderFactory.java
public static Properties getConnectionProperties(PropertiesConfiguration properties) { Properties toReturn = new Properties(); Iterator<String> iter = properties.getKeys(); while (iter.hasNext()) { String propKey = iter.next(); if (propKey.contains(Environment.CONNECTION_PREFIX)) { toReturn.setProperty(propKey, properties.getString(propKey)); }/* ww w . j av a 2 s . c o m*/ } return toReturn; }
From source file:com.xemantic.tadedon.configuration.Configurations.java
public static void merge(PropertiesConfiguration defaultConf, PropertiesConfiguration conf) { LOG.debug("Merging: {} <-> {}", defaultConf.getURL(), conf.getURL()); for (@SuppressWarnings("unchecked") Iterator<String> iterator = defaultConf.getKeys(); iterator.hasNext();) { String key = iterator.next(); if (!conf.containsKey(key)) { copyProperty(key, defaultConf, conf); }/*w w w.j av a 2 s . c om*/ } try { conf.save(); } catch (ConfigurationException e) { throw new RuntimeException("Could no save configuration file: " + conf.getFileName(), e); } }
From source file:com.heliosphere.athena.base.resource.bundle.ResourceBundleManager.java
/** * Registers the resource bundles defined in a given properties file. * <p>//from ww w. j ava2 s . c o m * @param properties {@link PropertiesConfiguration} file containing the * resource bundles to register. */ @SuppressWarnings({ "nls", "unchecked" }) private static final void register(final PropertiesConfiguration properties) { String value; String name; if (properties == null) { throw new InvalidArgumentException(BundleAthenaBase.ResourceBundleInvalidConfiguration); } final Iterator<String> iter = properties.getKeys(); while (iter != null && iter.hasNext()) { value = iter.next(); name = properties.getString(value); final ResourceBundle bundle = ResourceBundle.getBundle(name, locale); // Ensure the loaded bundle is for the required language. if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) { try { register((Class<? extends IBundle>) Class.forName(value), bundle); } catch (ClassNotFoundException e) { String message = MessageFormat.format( "Cannot register properties [file={0}, class={1}, reason={2}, resolution={3}]", name, value, "The given class cannot be found", "Ensure the given class exist as an enumeration class and implements the IBundle interface"); log.error(message, e); // Cannot get resource bundle, so message must be in raw format. throw new ResourceBundleException(MessageFormat.format( "Cannot register properties [file={0}, class={1}, reason={2}, resolution={3}]", name, value, "The given class cannot be found", "Ensure the given class exist as an enumeration class and implements the IBundle interface")); } } else { // Cannot get resource bundle, so message must be in raw format. throw new ResourceBundleException( MessageFormat.format("Bundle cannot be found [name={0}, locale={1}]", name, locale)); } } }
From source file:com.heliosphere.demeter.base.resource.bundle.ResourceBundleManager.java
/** * Registers the resource bundles defined in a given properties file. * <p>/*from ww w .j a va2 s . co m*/ * @param properties {@link PropertiesConfiguration} file containing the * resource bundles to register. */ @SuppressWarnings({ "nls", "unchecked" }) private static final void register(final PropertiesConfiguration properties) { String value; String name; if (properties == null) { throw new InvalidArgumentException(BundleDemeterBase.ResourceBundleInvalidConfiguration); } final Iterator<String> iter = properties.getKeys(); while (iter != null && iter.hasNext()) { value = iter.next(); name = properties.getString(value); final ResourceBundle bundle = ResourceBundle.getBundle(name, locale); // Ensure the loaded bundle is for the required language. if (bundle.getLocale().getLanguage().equals(locale.getLanguage())) { try { register((Class<? extends IBundle>) Class.forName(value), bundle); } catch (ClassNotFoundException e) { String message = MessageFormat.format( "Cannot register properties [file={0}, class={1}, reason={2}, resolution={3}]", name, value, "The given class cannot be found", "Ensure the given class exist as an enumeration class and implements the IBundle interface"); log.error(message, e); // Cannot get resource bundle, so message must be in raw format. throw new ResourceBundleException(MessageFormat.format( "Cannot register properties [file={0}, class={1}, reason={2}, resolution={3}]", name, value, "The given class cannot be found", "Ensure the given class exist as an enumeration class and implements the IBundle interface")); } } else { // Cannot get resource bundle, so message must be in raw format. throw new ResourceBundleException( MessageFormat.format("Bundle cannot be found [name={0}, locale={1}]", name, locale)); } } }
From source file:com.aurel.track.admin.customize.category.filter.MenuitemFilterBL.java
/** * Loads the filter names from property file * @return/*from ww w . ja va 2s. c om*/ */ private static List<String> loadFilterNamesToSubscribe() { List<String> filterNames = new LinkedList<String>(); String ON = "on"; String OFF = "off"; PropertiesConfiguration propertiesConfiguration = null; try { propertiesConfiguration = HandleHome.getProperties(HandleHome.FILTER_SUBSCRIPTIONS_FILE, ApplicationBean.getInstance().getServletContext()); } catch (ServletException e) { LOGGER.error( "ServletException by getting the FilterSubscriptions.properties from war " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } if (propertiesConfiguration != null) { Iterator<String> keys = propertiesConfiguration.getKeys(); while (keys.hasNext()) { String key = keys.next(); String[] keyParts = key.split("\\."); if (keyParts != null && keyParts.length > 1) { String repository = keyParts[0]; if (repository != null && !"".equals(repository)) { String filterName = key.substring(repository.length() + 1); String value = propertiesConfiguration.getString(key); if (value != null && !"".equals(value)) { if (ON.equals(value)) { filterNames.add(filterName); } else { if (!OFF.equals(value)) { try { Boolean boolValue = Boolean.valueOf(value); if (boolValue != null && boolValue.booleanValue()) { filterNames.add(filterName); } } catch (Exception e) { LOGGER.info("The value " + value + " for key " + key + " can't be converted to a boolean " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } } } } } } return filterNames; }
From source file:com.ibm.replication.iidr.metadata.Settings.java
/** * Log the properties in the specified configuration file * /*w ww .j a va2 s .c o m*/ * @param config */ private void logSettings(PropertiesConfiguration config) { Iterator<String> configKeys = config.getKeys(); while (configKeys.hasNext()) { String configKey = configKeys.next(); logger.debug("Property: " + configKey + " = " + config.getProperty(configKey)); } }
From source file:fr.inria.atlanmod.neoemf.data.blueprints.option.BlueprintsResourceSaveTest.java
protected int getKeyCount(PropertiesConfiguration configuration) { Iterator<String> keyIterator = configuration.getKeys(); int keyCount = 0; while (keyIterator.hasNext()) { keyCount++;//from ww w . j a v a 2 s . co m keyIterator.next(); } return keyCount; }
From source file:club.jmint.crossing.config.ServerConfig.java
@Override public ServerConfig loadConfig() { super.loadConfig(); PropertiesConfiguration conf = loadPropertiesConfigFile(configFilePath); Iterator<String> it = conf.getKeys(); String key = null;/*from www .j av a 2 s.co m*/ while (it.hasNext()) { key = it.next(); scMap.put(key, conf.getString(key)); } return this; }
From source file:com.bskyb.cg.environments.message.MessageFormatFactory.java
protected void initFromProperties() throws Exception { PropertiesConfiguration propertiesConfiguration = keysToClassNames.getConfigure(); Iterator<String> iterator = propertiesConfiguration.getKeys(); String key;// w ww . ja v a2 s .c om String className; String[] params = null; while (iterator.hasNext()) { key = (String) iterator.next(); params = propertiesConfiguration.getStringArray(key); className = params[0]; Class<MessageFormat> cls = (Class<MessageFormat>) Class.forName(className); classes.put(key, cls); args.put(key, ArrayUtils.subarray(params, 0, params.length)); } }