tester
Class Printer

java.lang.Object
  extended by tester.Printer

public class Printer
extends java.lang.Object


Field Summary
private static int counter
          object counter
private static java.util.HashMap<java.lang.Integer,java.lang.Integer> hashmap
          a hashmap of the hashcodes for the objects that are being printed: if the same pair is compared again, the loop of printing stops and produces true
private static java.lang.String INDENT
          current indentation level for pretty-printing
(package private)  java.lang.Object obj
          the object we wish to pretty-print
private static java.lang.String result
          the resulting string produced
 
Constructor Summary
Printer()
           
 
Method Summary
private static java.lang.String makeIterableStrings(java.util.Iterator it)
          Produce a String that represents the data generated by the given iterator -- comma separated.
private static java.lang.String makeString(java.lang.Object obj)
          Produce a String representation of the given object.
static void print(java.lang.Object obj)
          Print the values of the given object
static java.lang.String produceString(java.lang.Object obj)
          Produce a String representation of the values of the given object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

obj

java.lang.Object obj
the object we wish to pretty-print


INDENT

private static java.lang.String INDENT
current indentation level for pretty-printing


result

private static java.lang.String result
the resulting string produced


counter

private static int counter
object counter


hashmap

private static java.util.HashMap<java.lang.Integer,java.lang.Integer> hashmap
a hashmap of the hashcodes for the objects that are being printed: if the same pair is compared again, the loop of printing stops and produces true

Constructor Detail

Printer

public Printer()
Method Detail

print

public static void print(java.lang.Object obj)
Print the values of the given object

Parameters:
obj - the object to display in the console

produceString

public static java.lang.String produceString(java.lang.Object obj)
Produce a String representation of the values of the given object

Parameters:
obj - the object to represent
Returns:
a String representation of the values of the given object

makeString

private static java.lang.String makeString(java.lang.Object obj)
Produce a String representation of the given object.

Show String 'as is'.

For primitive datatypes and thier wrapper classes show the primitive values.

For all Arrays traverse over all elements.

For datatypes that implement Iterable interface traverse over all elements.

For datatypes that implement Traversal interface traverse over all elements.

For an instance of a declared class show all fields

Parameters:
obj - the given object

makeIterableStrings

private static java.lang.String makeIterableStrings(java.util.Iterator it)
Produce a String that represents the data generated by the given iterator -- comma separated.

Parameters:
it - the iterator for generating data
Returns:
the String that represents all generated data