se.datadosen.util
Class PrintSafeHashMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by se.datadosen.util.PrintSafeHashMap
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class PrintSafeHashMap
extends java.util.HashMap

HashMap that can be printed without risking ending in recursive loops if it contains recurive references.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
PrintSafeHashMap()
           
PrintSafeHashMap(java.util.Map t)
           
 
Method Summary
 java.lang.String toString()
          Returns a string representation of this map.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

PrintSafeHashMap

public PrintSafeHashMap()

PrintSafeHashMap

public PrintSafeHashMap(java.util.Map t)
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this map. The string representation consists of a list of key-value mappings in the order returned by the map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String.valueOf(Object).

This implementation creates an empty string buffer, appends a left brace, and iterates over the map's entrySet view, appending the string representation of each map.entry in turn. After appending each entry except the last, the string ", " is appended. Finally a right brace is appended. A string is obtained from the stringbuffer, and returned.

Overrides:
toString in class java.util.AbstractMap
Returns:
a String representation of this map.