List of usage examples for java.util Dictionary keys
public abstract Enumeration<K> keys();
From source file:com.github.lburgazzoli.quickfixj.osgi.ConfigAdminSessionSettingsBuilder.java
@Override public SessionSettings build() { SessionSettings settings = new SessionSettings(); try {/*from w w w . j av a2 s .co m*/ Configuration cfg = m_cfgAdm.getConfiguration(m_pid); Dictionary<String, Object> prop = cfg.getProperties(); if (validate(prop)) { Enumeration<String> keys = prop.keys(); String key = null; while (keys.hasMoreElements()) { key = keys.nextElement(); settings.setString(key, (String) prop.get(key)); } } } catch (IOException e) { LOGGER.warn("IOException", e); } return settings; }
From source file:org.jahia.services.usermanager.ldap.action.GetLdapConfigurationAction.java
@Override public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource, JCRSessionWrapper session, Map<String, List<String>> parameters, URLResolver urlResolver) throws Exception { String providerKey = req.getParameter("providerKey"); Map<String, String> res = new HashMap<>(); if (StringUtils.isNotBlank(providerKey)) { String pid = jahiaLDAPConfigFactory.getConfigPID(providerKey); if (pid == null) { return new ActionResult(HttpServletResponse.SC_NOT_FOUND); }//w w w . j a va 2 s .co m Configuration configuration = configurationAdmin.getConfiguration(pid); Dictionary<String, Object> properties = configuration.getProperties(); Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); if (!key.startsWith("service.") && !key.startsWith("felix.") && !JahiaLDAPConfig.LDAP_PROVIDER_KEY_PROP.equals(key)) { res.put(key, (String) properties.get(key)); } } } else { for (String f : defaultProperties) { res.put(f, ""); } } return new ActionResult(HttpServletResponse.SC_OK, null, new JSONObject(res)); }
From source file:io.fabric8.karaf.core.properties.PlaceholderResolverImpl.java
@Override public boolean replaceAll(Dictionary<String, Object> dictionary) { int replacedCount = 0; Enumeration<String> keys = dictionary.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); final Object val = dictionary.get(key); if (val instanceof String) { StringBuilder sb = Support.acquireStringBuilder((String) val); if (substitutor.replaceIn(sb)) { replacedCount++;/* www . j a v a2s .com*/ dictionary.put(key, sb.toString()); } } } return replacedCount > 0; }
From source file:org.opencastproject.capture.impl.XProperties.java
/** * Merges the properties from p into this properties object * //from w ww . j av a 2s. com * @param p * The {@code Dictionary} you wish to add to this object */ public void merge(Dictionary<String, String> p) { Enumeration<String> keys = p.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); this.put(key, p.get(key)); } }
From source file:org.openhab.action.openwebif.internal.OpenWebIfActionService.java
/** * {@inheritDoc}//from w w w .ja v a 2 s .c om */ @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties != null) { Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = StringUtils.trimToNull((String) properties.get(key)); if (StringUtils.startsWithIgnoreCase(key, "receiver")) { parseConfig(key, value); } } for (OpenWebIfConfig config : OpenWebIf.getConfigs().values()) { if (!config.isValid()) { throw new ConfigurationException("openwebif", "Invalid OpenWebIf receiver configuration: " + config.toString()); } logger.info("{}", config.toString()); } } }
From source file:edu.northwestern.bioinformatics.studycalendar.osgi.felixcm.internal.PscFelixPersistenceManagerTest.java
private void assertDictionaryKeys(Dictionary<String, ?> actual, String... expectedKeys) { Collection<String> actualKeys = EnumerationUtils.toList(actual.keys()); for (String expectedKey : expectedKeys) { assertTrue("Missing key " + expectedKey, actualKeys.contains(expectedKey)); }/* w w w . j av a 2 s. com*/ assertEquals("Wrong number of keys", expectedKeys.length, actualKeys.size()); }
From source file:org.fcrepo.apix.registry.HttpClientFactory.java
/** * Set props as a dictionary, eww.//from w w w . j ava 2 s.c om * * @param dict Dictionaty */ public void setDictionary(final Dictionary<String, Object> dict) { props = new HashMap<>(); final Enumeration<String> keys = dict.keys(); while (keys.hasMoreElements()) { final String key = keys.nextElement(); props.put(key, dict.get(key).toString()); } }
From source file:org.eclipse.swordfish.core.util.MapBasedDictionary.java
public void putAll(Dictionary dictionary) { if (dictionary != null) // copy the dictionary for (Enumeration enm = dictionary.keys(); enm.hasMoreElements();) { Object key = enm.nextElement(); map.put(key, dictionary.get(key)); }/*from ww w . j a va 2s . c o m*/ }
From source file:datasource.BasicDataSourceProvider.java
/** * Perform a registration for a specific PID. The properties specified are converted to settings * on a basic datasource and that one is registered in the service registry for later handling. * Note that no checking is done on validation of properties, they are parsed as is. * //ww w .j a va 2 s . com * @param pid The managed service pid * @param properties The properties of the pid */ synchronized void registration(String pid, Dictionary<String, ?> properties) { deleted(pid); Hashtable<String, Object> dict = new Hashtable<>(); Enumeration<String> enumeration = properties.keys(); T source = getDataSource(); source.setMaxWait(10000L); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); Object value = properties.get(key); // Check the values. if (key.equals("jdbc.driver")) { source.setDriverClassName(value.toString()); } else if (key.equals("jdbc.user")) { source.setUsername(value.toString()); } else if (key.equals("jdbc.password")) { source.setPassword(value.toString()); } else if (key.equals("jdbc.url")) { source.setUrl(value.toString()); } else if (key.equals("validation.query")) { source.setValidationQuery(value.toString()); } else if (key.equals("validation.timeout")) { source.setValidationQueryTimeout(Integer.parseInt(value.toString())); } else if (key.equals("pool.idle.min")) { source.setMinIdle(Integer.parseInt(value.toString())); } else if (key.equals("pool.idle.max")) { source.setMaxIdle(Integer.parseInt(value.toString())); } else if (key.equals("pool.wait")) { source.setMaxWait(Long.parseLong(value.toString())); } else if (key.equals("pool.active.max")) { source.setMaxActive(Integer.parseInt(value.toString())); } else { dict.put(key, value); } } // Got it. Create the registration for it. ServiceRegistration<DataSource> sr = FrameworkUtil.getBundle(getClass()).getBundleContext() .registerService(DataSource.class, source, dict); registrations.put(pid, new Registration<>(source, sr)); }
From source file:uk.ac.gda.util.dictionary.MapBasedDictionary.java
@SuppressWarnings("unchecked") public void putAll(Dictionary dictionary) { if (dictionary != null) // copy the dictionary for (Enumeration enm = dictionary.keys(); enm.hasMoreElements();) { Object key = enm.nextElement(); map.put(key, dictionary.get(key)); }/*w ww.j av a 2 s. co m*/ }