6 |
|
*/ |
7 |
|
|
8 |
|
package java.util; |
9 |
+ |
import java.util.*; // for javadoc (till 6280605 is fixed) |
10 |
|
import java.util.Map.Entry; |
11 |
|
|
12 |
|
/** |
86 |
|
* finding such an entry, <tt>false</tt> is returned. Note that this |
87 |
|
* implementation requires linear time in the size of the map. |
88 |
|
* |
88 |
– |
* @throws NullPointerException {@inheritDoc} |
89 |
|
* @throws ClassCastException {@inheritDoc} |
90 |
+ |
* @throws NullPointerException {@inheritDoc} |
91 |
|
*/ |
92 |
|
public boolean containsValue(Object value) { |
93 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
117 |
|
* implementation requires linear time in the size of the map; many |
118 |
|
* implementations will override this method. |
119 |
|
* |
119 |
– |
* @throws NullPointerException {@inheritDoc} |
120 |
|
* @throws ClassCastException {@inheritDoc} |
121 |
+ |
* @throws NullPointerException {@inheritDoc} |
122 |
|
*/ |
123 |
|
public boolean containsKey(Object key) { |
124 |
|
Iterator<Map.Entry<K,V>> i = entrySet().iterator(); |
148 |
|
* implementation requires linear time in the size of the map; many |
149 |
|
* implementations will override this method. |
150 |
|
* |
150 |
– |
* @throws NullPointerException {@inheritDoc} |
151 |
|
* @throws ClassCastException {@inheritDoc} |
152 |
+ |
* @throws NullPointerException {@inheritDoc} |
153 |
|
*/ |
154 |
|
public V get(Object key) { |
155 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
179 |
|
* <tt>UnsupportedOperationException</tt>. |
180 |
|
* |
181 |
|
* @throws UnsupportedOperationException {@inheritDoc} |
181 |
– |
* @throws NullPointerException {@inheritDoc} |
182 |
|
* @throws ClassCastException {@inheritDoc} |
183 |
+ |
* @throws NullPointerException {@inheritDoc} |
184 |
|
* @throws IllegalArgumentException {@inheritDoc} |
185 |
|
*/ |
186 |
|
public V put(K key, V value) { |
205 |
|
* contains a mapping for the specified key. |
206 |
|
* |
207 |
|
* @throws UnsupportedOperationException {@inheritDoc} |
207 |
– |
* @throws NullPointerException {@inheritDoc} |
208 |
|
* @throws ClassCastException {@inheritDoc} |
209 |
+ |
* @throws NullPointerException {@inheritDoc} |
210 |
|
*/ |
211 |
|
public V remove(Object key) { |
212 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
248 |
|
* the <tt>put</tt> operation and the specified map is nonempty. |
249 |
|
* |
250 |
|
* @throws UnsupportedOperationException {@inheritDoc} |
250 |
– |
* @throws NullPointerException {@inheritDoc} |
251 |
|
* @throws ClassCastException {@inheritDoc} |
252 |
+ |
* @throws NullPointerException {@inheritDoc} |
253 |
|
* @throws IllegalArgumentException {@inheritDoc} |
254 |
|
*/ |
255 |
|
public void putAll(Map<? extends K, ? extends V> m) { |
405 |
|
|
406 |
|
if (!(o instanceof Map)) |
407 |
|
return false; |
408 |
< |
Map<K,V> t = (Map<K,V>) o; |
409 |
< |
if (t.size() != size()) |
408 |
> |
Map<K,V> m = (Map<K,V>) o; |
409 |
> |
if (m.size() != size()) |
410 |
|
return false; |
411 |
|
|
412 |
|
try { |
416 |
|
K key = e.getKey(); |
417 |
|
V value = e.getValue(); |
418 |
|
if (value == null) { |
419 |
< |
if (!(t.get(key)==null && t.containsKey(key))) |
419 |
> |
if (!(m.get(key)==null && m.containsKey(key))) |
420 |
|
return false; |
421 |
|
} else { |
422 |
< |
if (!value.equals(t.get(key))) |
422 |
> |
if (!value.equals(m.get(key))) |
423 |
|
return false; |
424 |
|
} |
425 |
|
} |
469 |
|
* appended. Finally a right brace is appended. A string is obtained |
470 |
|
* from the stringbuffer, and returned. |
471 |
|
* |
472 |
< |
* @return a String representation of this map. |
472 |
> |
* @return a String representation of this map |
473 |
|
*/ |
474 |
|
public String toString() { |
475 |
< |
StringBuffer buf = new StringBuffer(); |
476 |
< |
buf.append("{"); |
475 |
> |
StringBuilder sb = new StringBuilder(); |
476 |
> |
sb.append("{"); |
477 |
|
|
478 |
|
Iterator<Entry<K,V>> i = entrySet().iterator(); |
479 |
|
boolean hasNext = i.hasNext(); |
482 |
|
K key = e.getKey(); |
483 |
|
V value = e.getValue(); |
484 |
|
if (key == this) |
485 |
< |
buf.append("(this Map)"); |
485 |
> |
sb.append("(this Map)"); |
486 |
|
else |
487 |
< |
buf.append(key); |
488 |
< |
buf.append("="); |
487 |
> |
sb.append(key); |
488 |
> |
sb.append("="); |
489 |
|
if (value == this) |
490 |
< |
buf.append("(this Map)"); |
490 |
> |
sb.append("(this Map)"); |
491 |
|
else |
492 |
< |
buf.append(value); |
492 |
> |
sb.append(value); |
493 |
|
hasNext = i.hasNext(); |
494 |
|
if (hasNext) |
495 |
< |
buf.append(", "); |
495 |
> |
sb.append(", "); |
496 |
|
} |
497 |
|
|
498 |
< |
buf.append("}"); |
499 |
< |
return buf.toString(); |
498 |
> |
sb.append("}"); |
499 |
> |
return sb.toString(); |
500 |
|
} |
501 |
|
|
502 |
|
/** |
556 |
|
* Creates an entry representing the same mapping as the |
557 |
|
* specified entry. |
558 |
|
* |
559 |
< |
* @param entry the entry to copy. |
559 |
> |
* @param entry the entry to copy |
560 |
|
*/ |
561 |
|
public SimpleEntry(Entry<? extends K, ? extends V> entry) { |
562 |
|
this.key = entry.getKey(); |