org.springframework.core.style
Class ToStringCreator

java.lang.Object
  extended by org.springframework.core.style.ToStringCreator

public class ToStringCreator
extends Object

Utility class that builds pretty-printing toString() methods with pluggable styling conventions. By default, ToStringCreator adheres to Spring's toString() styling conventions.

Since:
1.2.2
Author:
Keith Donald, Juergen Hoeller

Constructor Summary
ToStringCreator(Object obj)
          Create a ToStringCreator for the given object.
ToStringCreator(Object obj, ToStringStyler styler)
          Create a ToStringCreator for the given object, using the provided style.
ToStringCreator(Object obj, ValueStyler styler)
          Create a ToStringCreator for the given object, using the provided style.
 
Method Summary
 ToStringCreator append(Object value)
          Append the provided value.
 ToStringCreator append(String fieldName, boolean value)
          Append a boolean field value.
 ToStringCreator append(String fieldName, byte value)
          Append a byte field value.
 ToStringCreator append(String fieldName, double value)
          Append a double field value.
 ToStringCreator append(String fieldName, float value)
          Append a float field value.
 ToStringCreator append(String fieldName, int value)
          Append a integer field value.
 ToStringCreator append(String fieldName, long value)
          Append a long field value.
 ToStringCreator append(String fieldName, Object value)
          Append a field value.
 ToStringCreator append(String fieldName, short value)
          Append a short field value.
 String toString()
          Return the String representation that this ToStringCreator built.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToStringCreator

public ToStringCreator(Object obj)
Create a ToStringCreator for the given object.

Parameters:
obj - the object to be stringified

ToStringCreator

public ToStringCreator(Object obj,
                       ValueStyler styler)
Create a ToStringCreator for the given object, using the provided style.

Parameters:
obj - the object to be stringified
styler - the ValueStyler encapsulating pretty-print instructions

ToStringCreator

public ToStringCreator(Object obj,
                       ToStringStyler styler)
Create a ToStringCreator for the given object, using the provided style.

Parameters:
obj - the object to be stringified
styler - the ToStringStyler encapsulating pretty-print instructions
Method Detail

append

public ToStringCreator append(String fieldName,
                              byte value)
Append a byte field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              short value)
Append a short field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              int value)
Append a integer field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              long value)
Append a long field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              float value)
Append a float field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              double value)
Append a double field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              boolean value)
Append a boolean field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(String fieldName,
                              Object value)
Append a field value.

Parameters:
fieldName - the name of the field, usually the member variable name
value - the field value
Returns:
this, to support call-chaining

append

public ToStringCreator append(Object value)
Append the provided value.

Parameters:
value - The value to append
Returns:
this, to support call-chaining.

toString

public String toString()
Return the String representation that this ToStringCreator built.

Overrides:
toString in class Object