org.test4j.hamcrest.matcher.property.report
类 ObjectFormatter

java.lang.Object
  继承者 org.test4j.hamcrest.matcher.property.report.ObjectFormatter

public class ObjectFormatter
extends Object

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.


字段摘要
protected  int maxDepth
          The maximum recursion depth
 
构造方法摘要
ObjectFormatter()
          Creates a formatter with a maximum recursion depth of 5.
ObjectFormatter(int maxDepth)
          Creates a formatter with the given maximum recursion depth.
 
方法摘要
 String format(Object object)
          Gets the string representation of the given object.
protected  void formatArray(Object array, int currentDepth, StringBuilder result)
          Formats the given array.
protected  void formatCollection(Collection<?> collection, int currentDepth, StringBuilder result)
          Formats the given collection.
protected  void formatFields(Object object, Class clazz, int currentDepth, StringBuilder result)
          Formats the field values of the given object.
protected  void formatImpl(Object object, int currentDepth, StringBuilder result)
          Actual implementation of the formatting.
protected  void formatMap(Map<?,?> map, int currentDepth, StringBuilder result)
          Formats the given map.
protected  void formatObject(Object object, int currentDepth, StringBuilder result)
          Formats the given object by formatting the inner fields.
protected  boolean formatProxy(Object object, StringBuilder result)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

maxDepth

protected int maxDepth
The maximum recursion depth

构造方法详细信息

ObjectFormatter

public ObjectFormatter()
Creates a formatter with a maximum recursion depth of 5.


ObjectFormatter

public ObjectFormatter(int maxDepth)
Creates a formatter with the given maximum recursion depth.

NOTE: there is no cycle detection. A large max depth value can cause lots of output in case of a cycle.

参数:
maxDepth - The max depth > 0
方法详细信息

format

public String format(Object object)
Gets the string representation of the given object.

参数:
object - The instance
返回:
The string representation, not null

formatImpl

protected void formatImpl(Object object,
                          int currentDepth,
                          StringBuilder result)
Actual implementation of the formatting.

参数:
object - The instance
currentDepth - The current recursion depth
result - The builder to append the result to, not null

formatArray

protected void formatArray(Object array,
                           int currentDepth,
                           StringBuilder result)
Formats the given array.

参数:
array - The array, not null
currentDepth - The current recursion depth
result - The builder to append the result to, not null

formatCollection

protected void formatCollection(Collection<?> collection,
                                int currentDepth,
                                StringBuilder result)
Formats the given collection.

参数:
collection - The collection, not null
currentDepth - The current recursion depth
result - The builder to append the result to, not null

formatMap

protected void formatMap(Map<?,?> map,
                         int currentDepth,
                         StringBuilder result)
Formats the given map.

参数:
map - The map, not null
currentDepth - The current recursion depth
result - The builder to append the result to, not null

formatObject

protected void formatObject(Object object,
                            int currentDepth,
                            StringBuilder result)
Formats the given object by formatting the inner fields.

参数:
object - The object, not null
currentDepth - The current recursion depth
result - The builder to append the result to, not null

formatFields

protected void formatFields(Object object,
                            Class clazz,
                            int currentDepth,
                            StringBuilder result)
Formats the field values of the given object.

参数:
object - The object, not null
clazz - The class for which to format the fields, not null
currentDepth - The current recursion depth
result - The builder to append the result to, not null

formatProxy

protected boolean formatProxy(Object object,
                              StringBuilder result)


Copyright © 2013. All rights reserved.