|
||||||||||
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 ArrayAndCollectionFormatter |
arrayAndCollectionFormatter
|
protected int |
maxDepth
|
protected int |
maxNrArrayOrCollectionElements
|
static String |
MOCK_NAME_CHAIN_SEPARATOR
|
Constructor Summary | |
---|---|
ObjectFormatter()
Creates a formatter with a maximum recursion depth of 3. |
|
ObjectFormatter(int maxDepth,
int maxNrArrayOrCollectionElements)
Creates a formatter with the given maximum recursion depth. |
Method Summary | |
---|---|
String |
format(Object object)
Gets the string representation of the given object. |
protected boolean |
formatCharacter(Object object,
Class<?> type,
StringBuilder result)
|
protected void |
formatFields(Object object,
Class<?> clazz,
int currentDepth,
StringBuilder result)
Formats the field values of the given object. |
protected boolean |
formatFile(Object object,
StringBuilder result)
|
protected void |
formatImpl(Object object,
int currentDepth,
StringBuilder result)
Actual implementation of the formatting. |
protected boolean |
formatJavaLang(Object object,
StringBuilder result,
Class<?> type)
|
protected boolean |
formatMock(Object object,
StringBuilder result)
|
protected boolean |
formatNumberOrDate(Object object,
StringBuilder result)
|
protected void |
formatObject(Object object,
int currentDepth,
StringBuilder result)
Formats the given object by formatting the inner fields. |
protected boolean |
formatPrimitiveOrEnum(Object object,
Class<?> type,
StringBuilder result)
|
protected boolean |
formatProxy(Object object,
Class<?> type,
StringBuilder result)
|
protected boolean |
formatString(Object object,
StringBuilder result)
|
protected Class<?> |
getDummyObjectClass()
|
protected Class<?> |
getProxyUtilsClass()
|
protected boolean |
isDummy(Object object)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String MOCK_NAME_CHAIN_SEPARATOR
protected int maxDepth
protected int maxNrArrayOrCollectionElements
protected ArrayAndCollectionFormatter arrayAndCollectionFormatter
Constructor Detail |
---|
public ObjectFormatter()
public ObjectFormatter(int maxDepth, int maxNrArrayOrCollectionElements)
maxDepth
- The max depth > 0maxNrArrayOrCollectionElements
- The maximum nr of elements for arrays and collections to display > 0Method Detail |
---|
public String format(Object object)
object
- The instance
protected void formatImpl(Object object, int currentDepth, StringBuilder result)
object
- The instancecurrentDepth
- The current recursion depthresult
- The builder to append the result to, not nullprotected boolean formatJavaLang(Object object, StringBuilder result, Class<?> type)
protected boolean formatPrimitiveOrEnum(Object object, Class<?> type, StringBuilder result)
protected boolean formatCharacter(Object object, Class<?> type, StringBuilder result)
protected boolean formatNumberOrDate(Object object, StringBuilder result)
protected boolean formatString(Object object, StringBuilder result)
protected void formatObject(Object object, int currentDepth, StringBuilder result)
object
- The object, not nullcurrentDepth
- The current recursion depthresult
- The builder to append the result to, not nullprotected void formatFields(Object object, Class<?> clazz, int currentDepth, 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 nullprotected boolean formatMock(Object object, StringBuilder result)
protected boolean isDummy(Object object)
protected boolean formatProxy(Object object, Class<?> type, StringBuilder result)
protected boolean formatFile(Object object, StringBuilder result)
protected Class<?> getDummyObjectClass()
protected Class<?> getProxyUtilsClass()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |