public class StringDump
extends java.lang.Object
Object
s to string using reflection and
recursion.Constructor and Description |
---|
StringDump() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
dump(java.lang.Object object)
Uses reflection and recursion to dump the contents of the given object
using a custom, JSON-like notation (but not JSON).
|
static java.lang.String |
dump(java.lang.Object object,
boolean isIncludingStatics)
Uses reflection and recursion to dump the contents of the given object
using a custom, JSON-like notation (but not JSON).
|
public static java.lang.String dump(java.lang.Object object)
See also: dump(Object, boolean, IdentityHashMap, int)
object
- the Object
to dump using reflection and recursionpublic static java.lang.String dump(java.lang.Object object, boolean isIncludingStatics)
Parses all fields of the runtime class including super class fields,
which are successively prefixed with "super.
" at each level.
Number
s, enum
s, and null
references are formatted
using the standard String.valueOf()
method.
CharSequences
s are wrapped with quotes.
The recursive call invokes only one method on each recursive call, so limit of the object-graph depth is one-to-one with the stack overflow limit.
Backwards references are tracked using a "visitor map" which is an
instance of IdentityHashMap
. When an existing object reference is
encountered the "sysId"
is printed and the recursion ends.
object
- the Object
to dump using reflection and recursionisIncludingStatics
- true
if static
fields should be dumped,
false
to skip them