/** * 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); }
/** * 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))); }
@Override public int size() { return sysprops.size(); }
/** * 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 }
@Override public int size() { return dict.size(); } };
@Override public int size() { return dictionary.size(); } };
@Override public int size() { return dict.size(); } };
/** * Create a properties object for the service. * * @param props The properties for this service. */ ServiceProperties(Dictionary<String, ?> props) { this((props == null) ? 2 : props.size() + 2, props); }
@Override public int size() { return dict.size(); } };
/** * @see java.util.Map#size() */ public int size() { return dictionary.size(); }
/** * Create a properties object for the service. * * @param props The properties for this service. */ ServiceProperties(Dictionary<String, ?> props) { this((props == null) ? 2 : props.size() + 2, props); }
/** * Create a properties object for the service. * * @param props The properties for this service. */ ServiceProperties(Dictionary<String, ?> props) { this((props == null) ? 2 : props.size() + 2, props); }
@Override public int size() { return dictionary.size(); } };
@Override public synchronized int size () { return this.dictionary.size (); }
@Override public int size() { return dict.size(); } };
/** * Create a properties object for the service. * * @param props The properties for this service. */ ServiceProperties(Dictionary<String, ?> props) { this((props == null) ? 2 : props.size() + 2, props); }
private static Map<String, String> dictionaryToMap(Dictionary<String, String> contents) { Map<String, String> map = new HashMap<String, String>(contents.size()); Enumeration<String> keys = contents.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); map.put(key, contents.get(key)); } return map; }
public static String[] unparseMappings(Dictionary mappings) { Enumeration keys = mappings.keys(); String[] result = new String[mappings.size()]; int index = 0; while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); result[index] = key + "=" + formatPrefix((String) mappings.get(key)); index++; } return result; }
private Dictionary filterHidden(Dictionary dict) { final Dictionary filtered = new Hashtable(dict.size()); final Enumeration keys = dict.keys(); while (keys.hasMoreElements()) { final String key = (String)keys.nextElement(); if (!isHidden(key)) { filtered.put(key, dict.get(key)); } } return filtered; }