Returns the string representation of this map. @return the string representation of this map.
()
| 349 | * @return the string representation of this map. |
| 350 | */ |
| 351 | @Override |
| 352 | public String toString() { |
| 353 | if (isEmpty()) { |
| 354 | return "{}"; //$NON-NLS-1$ |
| 355 | } |
| 356 | |
| 357 | StringBuilder buffer = new StringBuilder(size() * 28); |
| 358 | buffer.append('{'); |
| 359 | Iterator<Map.Entry<K, V>> it = entrySet().iterator(); |
| 360 | while (it.hasNext()) { |
| 361 | Map.Entry<K, V> entry = it.next(); |
| 362 | Object key = entry.getKey(); |
| 363 | if (key != this) { |
| 364 | buffer.append(key); |
| 365 | } else { |
| 366 | buffer.append("(this Map)"); //$NON-NLS-1$ |
| 367 | } |
| 368 | buffer.append('='); |
| 369 | Object value = entry.getValue(); |
| 370 | if (value != this) { |
| 371 | buffer.append(value); |
| 372 | } else { |
| 373 | buffer.append("(this Map)"); //$NON-NLS-1$ |
| 374 | } |
| 375 | if (it.hasNext()) { |
| 376 | buffer.append(", "); //$NON-NLS-1$ |
| 377 | } |
| 378 | } |
| 379 | buffer.append('}'); |
| 380 | return buffer.toString(); |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * Returns a collection of the values contained in this map. The collection |