/** * Compares the specified Object with this Dictionary for equality, * * @return true if the specified Object is equal to this Dictionary. */ public synchronized boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Dictionary)) return false; Dictionary dict = (Dictionary) o; int max = size(); if (dict.size() != max) return false; Enumeration k = keys(); Enumeration e = elements(); for (int i = 0; i < max; i++) { Object key = k.nextElement(); Object value = e.nextElement(); if (!value.equals(dict.get(key))) { return false; } } return true; }
/** * Create a case insensitive dictionary from the specified dictionary. * * @param dictionary * @throws IllegalArgumentException If <code>dictionary</code> contains case variants of the * same key name. */ CaseInsensitiveDictionary(Dictionary dictionary) { if (dictionary == null) { this.dictionary = null; this.keys = new String[0]; return; } this.dictionary = dictionary; List keyList = new ArrayList(dictionary.size()); for (Enumeration e = dictionary.keys(); e.hasMoreElements(); ) { Object k = e.nextElement(); if (k instanceof String) { String key = (String) k; for (Iterator i = keyList.iterator(); i.hasNext(); ) { if (key.equalsIgnoreCase((String) i.next())) { throw new IllegalArgumentException(); } } keyList.add(key); } } this.keys = (String[]) keyList.toArray(new String[keyList.size()]); }
public int size() { return headers.size(); }
public static void countClone(Dictionary l) { ndict_clones++; ndict_elems += l.size(); }