|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.core.util.ObjectFormatter
public class ObjectFormatter
A class for generating a string representation of any object, array or primitive value.
Non-primitive objects are processed recursively so that a string representation of inner objects is also generated. Too avoid too much output, this recursion is limited with a given maximum depth.
| Field Summary | |
|---|---|
protected int |
maxDepth
The maximum recursion depth |
| Constructor Summary | |
|---|---|
ObjectFormatter()
Creates a formatter with a maximum recursion depth of 5. |
|
ObjectFormatter(int maxDepth)
Creates a formatter with the given maximum recursion depth. |
|
| Method Summary | |
|---|---|
java.lang.String |
format(java.lang.Object object)
Gets the string representation of the given object. |
protected void |
formatArray(java.lang.Object array,
int currentDepth,
java.lang.StringBuilder result)
Formats the given array. |
protected void |
formatCollection(java.util.Collection<?> collection,
int currentDepth,
java.lang.StringBuilder result)
Formats the given collection. |
protected void |
formatFields(java.lang.Object object,
java.lang.Class<?> clazz,
int currentDepth,
java.lang.StringBuilder result)
Formats the field values of the given object. |
protected void |
formatImpl(java.lang.Object object,
int currentDepth,
java.lang.StringBuilder result)
Actual implementation of the formatting. |
protected void |
formatMap(java.util.Map<?,?> map,
int currentDepth,
java.lang.StringBuilder result)
Formats the given map. |
protected boolean |
formatMock(java.lang.Object object,
java.lang.StringBuilder result)
|
protected void |
formatObject(java.lang.Object object,
int currentDepth,
java.lang.StringBuilder result)
Formats the given object by formatting the inner fields. |
protected boolean |
formatProxy(java.lang.Object object,
java.lang.StringBuilder result)
|
protected java.lang.Class<?> |
getDummyObjectClass()
|
protected java.lang.Class<?> |
getProxyUtilsClass()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int maxDepth
| Constructor Detail |
|---|
public ObjectFormatter()
public ObjectFormatter(int maxDepth)
maxDepth - The max depth > 0| Method Detail |
|---|
public java.lang.String format(java.lang.Object object)
object - The instance
protected void formatImpl(java.lang.Object object,
int currentDepth,
java.lang.StringBuilder result)
object - The instancecurrentDepth - The current recursion depthresult - The builder to append the result to, not null
protected void formatArray(java.lang.Object array,
int currentDepth,
java.lang.StringBuilder result)
array - The array, not nullcurrentDepth - The current recursion depthresult - The builder to append the result to, not null
protected void formatCollection(java.util.Collection<?> collection,
int currentDepth,
java.lang.StringBuilder result)
collection - The collection, not nullcurrentDepth - The current recursion depthresult - The builder to append the result to, not null
protected void formatMap(java.util.Map<?,?> map,
int currentDepth,
java.lang.StringBuilder result)
map - The map, not nullcurrentDepth - The current recursion depthresult - The builder to append the result to, not null
protected void formatObject(java.lang.Object object,
int currentDepth,
java.lang.StringBuilder result)
object - The object, not nullcurrentDepth - The current recursion depthresult - The builder to append the result to, not null
protected void formatFields(java.lang.Object object,
java.lang.Class<?> clazz,
int currentDepth,
java.lang.StringBuilder result)
object - The object, not nullclazz - The class for which to format the fields, not nullcurrentDepth - The current recursion depthresult - The builder to append the result to, not null
protected boolean formatMock(java.lang.Object object,
java.lang.StringBuilder result)
protected boolean formatProxy(java.lang.Object object,
java.lang.StringBuilder result)
protected java.lang.Class<?> getDummyObjectClass()
protected java.lang.Class<?> getProxyUtilsClass()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||