private static <K,V> void log(RedwoodChannels channels, String description, Dictionary<K,V> dict) { //(a real data structure) Map<K, V> map = Generics.newHashMap(); //(copy to map) Enumeration<K> keys = dict.keys(); while(keys.hasMoreElements()){ K key = keys.nextElement(); V value = dict.get(key); map.put(key,value); } //(log like normal) log(channels, description, map); }
/** * Dictionary does not know the putAll method. Please use Map.putAll(). * @param m1 the to directory. * @param m2 the from directory. * @param <K> type of the key * @param <V> type of the value * @since Ant 1.6 * @deprecated since 1.6.x. */ @Deprecated public static <K, V> void putAll(Dictionary<? super K, ? super V> m1, Dictionary<? extends K, ? extends V> m2) { StreamUtils.enumerationAsStream(m2.keys()).forEach(key -> m1.put(key, m2.get(key))); }
/** * Create a case insensitive map from the specified dictionary. * * @param dictionary * @throws IllegalArgumentException If {@code dictionary} contains case * variants of the same key name. */ CaseInsensitiveMap(Dictionary<String, ?> dictionary) { if (dictionary == null) { this.dictionary = null; this.keys = new String[0]; return; } this.dictionary = dictionary; List<String> keyList = new ArrayList<String>(dictionary.size()); for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements();) { Object k = e.nextElement(); if (k instanceof String) { String key = (String) k; for (String i : keyList) { if (key.equalsIgnoreCase(i)) { throw new IllegalArgumentException(); } } keyList.add(key); } } this.keys = keyList.toArray(new String[keyList.size()]); }
/** * Create an EventProperties from the specified dictionary. * * <p> * The specified properties will be copied into this EventProperties. * Properties whose key is not of type {@code String} will be ignored. A * property with the key "event.topics" will be ignored. * * @param properties The properties to use for this EventProperties object * (may be {@code null}). */ EventProperties(Dictionary<String, ?> properties) { int size = (properties == null) ? 0 : properties.size(); Map<String, Object> p = new HashMap<String, Object>(size); if (size > 0) { for (Enumeration<?> e = properties.keys(); e.hasMoreElements();) { Object key = e.nextElement(); if ((key instanceof String) && !EVENT_TOPIC.equals(key)) { Object value = properties.get(key); p.put((String) key, value); } } } // safely publish the map this.properties = Collections.unmodifiableMap(p); }
/** * Method to populate current Repositories using OSGi Service * @throws Exception */ private void populateRepositories() throws Exception { // Cleaning Repositories repositories.clear(); // Validating that RepositoryAdmin exists Validate.notNull(getRepositoryAdmin(), "RepositoryAdmin not found"); // Checking if exists installed Repos and adding to repositories Enumeration persistedRepos = installedRepos.keys(); while (persistedRepos.hasMoreElements()) { String repositoryURL = (String) persistedRepos.nextElement(); // Checking if is a valid URL if (repositoryURL.startsWith("http") || repositoryURL.startsWith("file")) { // Installing persisted repositories getRepositoryAdmin().addRepository(repositoryURL); } } for (Repository repo : getRepositoryAdmin().listRepositories()) { repositories.add(repo); } }
/** * Dictionary does not have an equals. * Please use Map.equals(). * * <p>Follows the equals contract of Java 2's Map.</p> * @param d1 the first directory. * @param d2 the second directory. * @return true if the directories are equal. * @since Ant 1.5 * @deprecated since 1.6.x. */ @Deprecated public static boolean equals(Dictionary<?, ?> d1, Dictionary<?, ?> d2) { if (d1 == d2) { return true; } if (d1 == null || d2 == null) { return false; } if (d1.size() != d2.size()) { return false; } // don't need the opposite check as the Dictionaries have the // same size, so we've also covered all keys of d2 already. return StreamUtils.enumerationAsStream(d1.keys()) .allMatch(key -> d1.get(key).equals(d2.get(key))); }
private void applyAuthSupplier(Dictionary<String, String> d, HTTPConduit c) { Enumeration<String> keys = d.keys(); while (keys.hasMoreElements()) { String k = keys.nextElement(); if (k.startsWith("authSupplier")) { String v = d.get(k); Object obj; try { obj = Class.forName(v).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new RuntimeException(e); } if (obj instanceof HttpAuthSupplier) { c.setAuthSupplier((HttpAuthSupplier)obj); } } } } }
/** * Constructs an event. * * @param topic The topic of the event. * @param properties The event's properties (may be <code>null</code>). A * property whose key is not of type <code>String</code> will be * ignored. * @throws IllegalArgumentException If topic is not a valid topic name. */ public Event(String topic, Dictionary/* <String,Object> */properties) { validateTopicName(topic); this.topic = topic; int size = (properties == null) ? 1 : (properties.size() + 1); Map p = new HashMap(size); if (properties != null) { for (Enumeration e = properties.keys(); e.hasMoreElements();) { Object key = e.nextElement(); if (key instanceof String) { Object value = properties.get(key); p.put(key, value); } } } p.put(EventConstants.EVENT_TOPIC, topic); this.properties = p; // safely publish the map }
private void applyProxyAuthorization(Dictionary<String, String> d, HTTPConduit c) { Enumeration<String> keys = d.keys(); ProxyAuthorizationPolicy p = c.getProxyAuthorization(); while (keys.hasMoreElements()) { String k = keys.nextElement(); if (k.startsWith("proxyAuthorization.")) { if (p == null) { p = new ProxyAuthorizationPolicy(); c.setProxyAuthorization(p); } String v = d.get(k); k = k.substring("proxyAuthorization.".length()); if ("UserName".equals(k)) { p.setUserName(v); } else if ("Password".equals(k)) { p.setPassword(v); } else if ("Authorization".equals(k)) { p.setAuthorization(v); } else if ("AuthorizationType".equals(k)) { p.setAuthorizationType(v); } } } }
private void applyAuthorization(Dictionary<String, String> d, HTTPConduit c) { Enumeration<String> keys = d.keys(); AuthorizationPolicy p = c.getAuthorization(); while (keys.hasMoreElements()) { String k = keys.nextElement(); if (k.startsWith("authorization.")) { if (p == null) { p = new AuthorizationPolicy(); c.setAuthorization(p); } String v = d.get(k); k = k.substring("authorization.".length()); if ("UserName".equals(k)) { p.setUserName(v); } else if ("Password".equals(k)) { p.setPassword(v); } else if ("Authorization".equals(k)) { p.setAuthorization(v); } else if ("AuthorizationType".equals(k)) { p.setAuthorizationType(v); } } } }
private void applyClientPolicies(Dictionary<String, String> d, HTTPConduit c) { Enumeration<String> keys = d.keys(); HTTPClientPolicy p = c.getClient(); while (keys.hasMoreElements()) { String k = keys.nextElement(); if (k.startsWith("client.")) { if (p == null) { c.setClient(p); String v = d.get(k); k = k.substring("client.".length()); if ("ConnectionTimeout".equals(k)) {
Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { String nextKey = keys.nextElement().toString(); if (!nextKey.startsWith(CXF_SERVLET_PREFIX)) { sprops.put(nextKey, properties.get(nextKey));
private void applyTlsClientParameters(Dictionary<String, String> d, HTTPConduit c) { Enumeration<String> keys = d.keys(); TLSClientParameters p = c.getTlsClientParameters(); SecureRandomParameters srp = null; TrustManagersType tmt = null; boolean enableRevocation = false; while (keys.hasMoreElements()) { String k = keys.nextElement(); if (k.startsWith("tlsClientParameters.")) { if (p == null) { c.setTlsClientParameters(p); String v = d.get(k); k = k.substring("tlsClientParameters.".length());
@Override public void setProperties(Dictionary<String, ?> dctnr) { while(dctnr.keys().hasMoreElements()){ String key = dctnr.keys().nextElement(); props.put(key, dctnr.get(key)); } }
public long getSumValidationErrors() { long sumValidationErrors = 0; synchronized (validationErrors) { Enumeration<String> keys = validationErrors.keys(); while (keys.hasMoreElements()) { sumValidationErrors += validationErrors.get(keys.nextElement()); } } return sumValidationErrors; }
private Dictionary copyValues(Dictionary to, Dictionary from, boolean stringsOnly) { if (from == null) return to; for (Enumeration keys = from.keys(); keys.hasMoreElements(); ) { String key = (String) keys.nextElement(); Object value = from.get(key); if ((value instanceof String) || !stringsOnly) to.put(key, value); } return to; }
public void updateDic(Dictionary dic){ Enumeration e=dic.keys(); while(e.hasMoreElements()){ String varName=(String)e.nextElement(); Object varValue=dic.get(varName); stateVars.put(varName,varValue); } } }
private Dictionary copyValues(Dictionary to, Dictionary from, boolean stringsOnly) { if (from == null) return to; for (Enumeration keys = from.keys(); keys.hasMoreElements(); ) { String key = (String) keys.nextElement(); Object value = from.get(key); if ((value instanceof String) || !stringsOnly) to.put(key, value); } return to; }
protected static void copyTo( Map<String, Object> target, Dictionary<String, ?> source ) { for ( Enumeration<String> keys = source.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); Object value = source.get(key); target.put(key, value); } }
public static void copy(Dictionary destination, Dictionary source) { Enumeration e = source.keys(); while (e.hasMoreElements()) { Object key = e.nextElement(); Object value = source.get(key); destination.put(key, value); } }