ToStringStyle

@SuppressWarnings({"deprecation"}) public abstract class org.apache.commons.lang3.builder.ToStringStyle implements Serializable[source]

Controls String formatting for ToStringBuilder. The main public interface is always via ToStringBuilder.

These classes are intended to be used as singletons. There is no need to instantiate a new style each time. A program will generally use one of the predefined constants on this class. Alternatively, the StandardToStringStyle class can be used to set the individual settings. Thus most styles can be achieved without subclassing.

If required, a subclass can override as many or as few of the methods as it requires. Each object type (from boolean to long to Object to int[]) has its own methods to output it. Most have two versions, detail and summary.

For example, the detail version of the array based methods will output the whole array, whereas the summary method will just output the array length.

If you want to format the output of certain objects, such as dates, you must create a subclass and override a method.

public class MyStyle extends ToStringStyle {

    protected void appendDetail(StringBuffer buffer, String fieldName, Object value) {
        if (value instanceof Date) {
            value = new SimpleDateFormat("yyyy-MM-dd").format(value);
        }
        buffer.append(value);
    }
}
Since:

1.0

Constructors

ToStringStyle()

Constructs a new instance.

protected ToStringStyle()[source]

Constructs a new instance.

Fields and constants

DEFAULT_STYLE

The default toString style.

JSON_STYLE

The JSON toString style.

MULTI_LINE_STYLE

The multi line toString style.

NO_CLASS_NAME_STYLE

The no class name toString style.

NO_FIELD_NAMES_STYLE

The no field names toString style.

SHORT_PREFIX_STYLE

The short prefix toString style.

SIMPLE_STYLE

The simple toString style.

public static final ToStringStyle DEFAULT_STYLE[source]

The default toString style. Using the Person example from ToStringBuilder, the output would look like this:

Person@182f0db[name=John Doe,age=33,smoker=false]
public static final ToStringStyle JSON_STYLE[source]

The JSON toString style. Using the Person example from ToStringBuilder, the output would look like this:

{"name": "John Doe", "age": 33, "smoker": true}

Note: Since field names are mandatory in JSON, this ToStringStyle will throw an UnsupportedOperationException if no field name is passed in while appending. Furthermore This ToStringStyle will only generate valid JSON if referenced objects also produce JSON when calling toString() on them.

Since:

3.4

See also:

json.org

public static final ToStringStyle MULTI_LINE_STYLE[source]

The multi line toString style. Using the Person example from ToStringBuilder, the output would look like this:

Person@182f0db[
  name=John Doe
  age=33
  smoker=false
]
public static final ToStringStyle NO_CLASS_NAME_STYLE[source]

The no class name toString style. Using the Person example from ToStringBuilder, the output would look like this:

[name=John Doe,age=33,smoker=false]
Since:

3.4

public static final ToStringStyle NO_FIELD_NAMES_STYLE[source]

The no field names toString style. Using the Person example from ToStringBuilder, the output would look like this:

Person@182f0db[John Doe,33,false]
public static final ToStringStyle SHORT_PREFIX_STYLE[source]

The short prefix toString style. Using the Person example from ToStringBuilder, the output would look like this:

Person[name=John Doe,age=33,smoker=false]
Since:

2.1

public static final ToStringStyle SIMPLE_STYLE[source]

The simple toString style. Using the Person example from ToStringBuilder, the output would look like this:

John Doe,33,false

Methods

append(StringBuffer, String, boolean)

Appends to the toString a boolean value.

append(StringBuffer, String, boolean[], Boolean)

Appends to the toString a boolean array.

append(StringBuffer, String, byte)

Appends to the toString a byte value.

append(StringBuffer, String, byte[], Boolean)

Appends to the toString a byte array.

append(StringBuffer, String, char)

Appends to the toString a char value.

append(StringBuffer, String, char[], Boolean)

Appends to the toString a char array.

append(StringBuffer, String, double)

Appends to the toString a double value.

append(StringBuffer, String, double[], Boolean)

Appends to the toString a double array.

append(StringBuffer, String, float)

Appends to the toString a float value.

append(StringBuffer, String, float[], Boolean)

Appends to the toString a float array.

append(StringBuffer, String, int)

Appends to the toString an int value.

append(StringBuffer, String, int[], Boolean)

Appends to the toString an int array.

append(StringBuffer, String, Object, Boolean)

Appends to the toString an Object value, printing the full toString of the Object passed in.

append(StringBuffer, String, Object[], Boolean)

Appends to the toString an Object array.

append(StringBuffer, String, long)

Appends to the toString a long value.

append(StringBuffer, String, long[], Boolean)

Appends to the toString a long array.

append(StringBuffer, String, short)

Appends to the toString a short value.

append(StringBuffer, String, short[], Boolean)

Appends to the toString a short array.

appendClassName(StringBuffer, Object)

Appends to the toString the class name.

appendContentEnd(StringBuffer)

Appends to the toString the content end.

appendContentStart(StringBuffer)

Appends to the toString the content start.

appendCyclicObject(StringBuffer, String, Object)

Appends to the toString an Object value that has been detected to participate in a cycle.

appendDetail(StringBuffer, String, boolean)

Appends to the toString a boolean value.

appendDetail(StringBuffer, String, boolean[])

Appends to the toString the detail of a boolean array.

appendDetail(StringBuffer, String, byte)

Appends to the toString a byte value.

appendDetail(StringBuffer, String, byte[])

Appends to the toString the detail of a byte array.

appendDetail(StringBuffer, String, char)

Appends to the toString a char value.

appendDetail(StringBuffer, String, char[])

Appends to the toString the detail of a char array.

appendDetail(StringBuffer, String, double)

Appends to the toString a double value.

appendDetail(StringBuffer, String, double[])

Appends to the toString the detail of a double array.

appendDetail(StringBuffer, String, float)

Appends to the toString a float value.

appendDetail(StringBuffer, String, float[])

Appends to the toString the detail of a float array.

appendDetail(StringBuffer, String, int)

Appends to the toString an int value.

appendDetail(StringBuffer, String, int, Object)

Appends to the toString the detail of an Object array item.

appendDetail(StringBuffer, String, int[])

Appends to the toString the detail of an int array.

appendDetail(StringBuffer, String, Object)

Appends to the toString an Object value, printing the full detail of the Object.

appendDetail(StringBuffer, String, Object[])

Appends to the toString the detail of an Object array.

appendDetail(StringBuffer, String, Collection)

Appends to the toString a Collection.

appendDetail(StringBuffer, String, Map)

Appends to the toString a Map.

appendDetail(StringBuffer, String, long)

Appends to the toString a long value.

appendDetail(StringBuffer, String, long[])

Appends to the toString the detail of a long array.

appendDetail(StringBuffer, String, short)

Appends to the toString a short value.

appendDetail(StringBuffer, String, short[])

Appends to the toString the detail of a short array.

appendEnd(StringBuffer, Object)

Appends to the toString the end of data indicator.

appendFieldEnd(StringBuffer, String)

Appends to the toString the field end.

appendFieldSeparator(StringBuffer)

Appends to the toString the field separator.

appendFieldStart(StringBuffer, String)

Appends to the toString the field start.

appendIdentityHashCode(StringBuffer, Object)

Appends the System#identityHashCode(java.lang.Object).

appendInternal(StringBuffer, String, Object, boolean)

Appends to the toString an Object, correctly interpreting its type.

appendNullText(StringBuffer, String)

Appends to the toString an indicator for null.

appendStart(StringBuffer, Object)

Appends to the toString the start of data indicator.

appendSummary(StringBuffer, String, boolean[])

Appends to the toString a summary of a boolean array.

appendSummary(StringBuffer, String, byte[])

Appends to the toString a summary of a byte array.

appendSummary(StringBuffer, String, char[])

Appends to the toString a summary of a char array.

appendSummary(StringBuffer, String, double[])

Appends to the toString a summary of a double array.

appendSummary(StringBuffer, String, float[])

Appends to the toString a summary of a float array.

appendSummary(StringBuffer, String, int[])

Appends to the toString a summary of an int array.

appendSummary(StringBuffer, String, Object)

Appends to the toString an Object value, printing a summary of the Object.

appendSummary(StringBuffer, String, Object[])

Appends to the toString a summary of an Object array.

appendSummary(StringBuffer, String, long[])

Appends to the toString a summary of a long array.

appendSummary(StringBuffer, String, short[])

Appends to the toString a summary of a short array.

appendSummarySize(StringBuffer, String, int)

Appends to the toString a size summary.

appendSuper(StringBuffer, String)

Appends to the toString the superclass toString.

appendToString(StringBuffer, String)

Appends to the toString another toString.

getArrayEnd()

Gets the array end text.

getArraySeparator()

Gets the array separator text.

getArrayStart()

Gets the array start text.

getContentEnd()

Gets the content end text.

getContentStart()

Gets the content start text.

getFieldNameValueSeparator()

Gets the field name value separator text.

getFieldSeparator()

Gets the field separator text.

getNullText()

Gets the text to output when null found.

getRegistry()

Gets the registry of objects being traversed by the reflectionToString methods in the current thread.

getShortClassName(Class)

Gets the short class name for a class.

getSizeEndText()

Gets the end text to output when a Collection, Map or array size is output.

getSizeStartText()

Gets the start text to output when a Collection, Map or array size is output.

getSummaryObjectEndText()

Gets the end text to output when an Object is output in summary mode.

getSummaryObjectStartText()

Gets the start text to output when an Object is output in summary mode.

isArrayContentDetail()

Tests whether to output array content detail.

isDefaultFullDetail()

Tests whether full detail is used when the caller does not specify a detail level.

isFieldSeparatorAtEnd()

Tests whether the field separator should be added at the end of each buffer.

isFieldSeparatorAtStart()

Tests whether the field separator should be added at the start of each buffer.

isFullDetail(Boolean)

Tests whether this field should be output in full detail.

isUseClassName()

Tests whether to use the class name.

isUseFieldNames()

Tests whether to use the field names passed in.

isUseIdentityHashCode()

Tests whether to use the identity hash code.

isUseShortClassName()

Tests whether short class names should be output.

reflectionAppendArrayDetail(StringBuffer, String, Object)

Appends to the toString the detail of an array type.

removeLastFieldSeparator(StringBuffer)

Remove the last field separator from the buffer.

setArrayContentDetail(boolean)

Sets whether to output array content detail.

setArrayEnd(String)

Sets the array end text.

setArraySeparator(String)

Sets the array separator text.

setArrayStart(String)

Sets the array start text.

setContentEnd(String)

Sets the content end text.

setContentStart(String)

Sets the content start text.

setDefaultFullDetail(boolean)

Sets whether to use full detail when the caller doesn’t specify.

setFieldNameValueSeparator(String)

Sets the field name value separator text.

setFieldSeparator(String)

Sets the field separator text.

setFieldSeparatorAtEnd(boolean)

Sets whether the field separator should be added at the end of each buffer.

setFieldSeparatorAtStart(boolean)

Sets whether the field separator should be added at the start of each buffer.

setNullText(String)

Sets the text to output when null found.

setSizeEndText(String)

Sets the end text to output when a Collection, Map or array size is output.

setSizeStartText(String)

Sets the start text to output when a Collection, Map or array size is output.

setSummaryObjectEndText(String)

Sets the end text to output when an Object is output in summary mode.

setSummaryObjectStartText(String)

Sets the start text to output when an Object is output in summary mode.

setUseClassName(boolean)

Sets whether to use the class name.

setUseFieldNames(boolean)

Sets whether to use the field names passed in.

setUseIdentityHashCode(boolean)

Sets whether to use the identity hash code.

setUseShortClassName(boolean)

Sets whether to output short or long class names.

public void append(StringBuffer buffer, String fieldName, boolean value)[source]

Appends to the toString a boolean value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail)[source]

Appends to the toString a boolean array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, byte value)[source]

Appends to the toString a byte value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail)[source]

Appends to the toString a byte array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, char value)[source]

Appends to the toString a char value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail)[source]

Appends to the toString a char array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, double value)[source]

Appends to the toString a double value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail)[source]

Appends to the toString a double array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, float value)[source]

Appends to the toString a float value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail)[source]

Appends to the toString a float array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, int value)[source]

Appends to the toString an int value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail)[source]

Appends to the toString an int array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail)[source]

Appends to the toString an Object value, printing the full toString of the Object passed in.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail)[source]

Appends to the toString an Object array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, long value)[source]

Appends to the toString a long value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail)[source]

Appends to the toString a long array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

public void append(StringBuffer buffer, String fieldName, short value)[source]

Appends to the toString a short value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • value – The value to add to the toString.

public void append(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail)[source]

Appends to the toString a short array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

  • array – The array to add to the toString.

  • fullDetail – true for detail, false for summary info, null for style decides.

protected void appendClassName(StringBuffer buffer, Object object)[source]

Appends to the toString the class name.

Parameters:
protected void appendContentEnd(StringBuffer buffer)[source]

Appends to the toString the content end.

Parameters:

buffer – The StringBuffer to populate.

protected void appendContentStart(StringBuffer buffer)[source]

Appends to the toString the content start.

Parameters:

buffer – The StringBuffer to populate.

protected void appendCyclicObject(StringBuffer buffer, String fieldName, Object value)[source]

Appends to the toString an Object value that has been detected to participate in a cycle. This implementation will print the standard string value of the value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended

  • value – The value to add to the toString, not null.

Since:

2.2

protected void appendDetail(StringBuffer buffer, String fieldName, boolean value)[source]

Appends to the toString a boolean value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, boolean[] array)[source]

Appends to the toString the detail of a boolean array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, byte value)[source]

Appends to the toString a byte value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, byte[] array)[source]

Appends to the toString the detail of a byte array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, char value)[source]

Appends to the toString a char value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, char[] array)[source]

Appends to the toString the detail of a char array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, double value)[source]

Appends to the toString a double value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, double[] array)[source]

Appends to the toString the detail of a double array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, float value)[source]

Appends to the toString a float value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, float[] array)[source]

Appends to the toString the detail of a float array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, int value)[source]

Appends to the toString an int value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, int i, Object item)[source]

Appends to the toString the detail of an Object array item.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • i – The array item index to add.

  • item – The array item to add.

Since:

3.11

protected void appendDetail(StringBuffer buffer, String fieldName, int[] array)[source]

Appends to the toString the detail of an int array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, Object value)[source]

Appends to the toString an Object value, printing the full detail of the Object.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, Object[] array)[source]

Appends to the toString the detail of an Object array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll)[source]

Appends to the toString a Collection.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • coll – The Collection to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, Map<?, ?> map)[source]

Appends to the toString a Map.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • map – The Map to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, long value)[source]

Appends to the toString a long value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, long[] array)[source]

Appends to the toString the detail of a long array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendDetail(StringBuffer buffer, String fieldName, short value)[source]

Appends to the toString a short value.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString.

protected void appendDetail(StringBuffer buffer, String fieldName, short[] array)[source]

Appends to the toString the detail of a short array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

public void appendEnd(StringBuffer buffer, Object object)[source]

Appends to the toString the end of data indicator.

Parameters:
protected void appendFieldEnd(StringBuffer buffer, String fieldName)[source]

Appends to the toString the field end.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

protected void appendFieldSeparator(StringBuffer buffer)[source]

Appends to the toString the field separator.

Parameters:

buffer – The StringBuffer to populate.

protected void appendFieldStart(StringBuffer buffer, String fieldName)[source]

Appends to the toString the field start.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name.

protected void appendIdentityHashCode(StringBuffer buffer, Object object)[source]

Appends the System#identityHashCode(java.lang.Object).

Parameters:
protected void appendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail)[source]

Appends to the toString an Object, correctly interpreting its type.

This method performs the main lookup by Class type to correctly route arrays, Collections, Maps and Objects to the appropriate method.

Either detail or summary views can be specified.

If a cycle is detected, an object will be appended with the Object.toString() format.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString, not null.

  • detail – output detail or not.

protected void appendNullText(StringBuffer buffer, String fieldName)[source]

Appends to the toString an indicator for null.

The default indicator is "<null>".

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

public void appendStart(StringBuffer buffer, Object object)[source]

Appends to the toString the start of data indicator.

Parameters:
protected void appendSummary(StringBuffer buffer, String fieldName, boolean[] array)[source]

Appends to the toString a summary of a boolean array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, byte[] array)[source]

Appends to the toString a summary of a byte array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, char[] array)[source]

Appends to the toString a summary of a char array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, double[] array)[source]

Appends to the toString a summary of a double array.

Parameters:
  • buffer – The StringBuffer to populate

  • fieldName – The field name, typically not used as already appended

  • array – The array to add to the toString, not null

protected void appendSummary(StringBuffer buffer, String fieldName, float[] array)[source]

Appends to the toString a summary of a float array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, int[] array)[source]

Appends to the toString a summary of an int array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, Object value)[source]

Appends to the toString an Object value, printing a summary of the Object.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • value – The value to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, Object[] array)[source]

Appends to the toString a summary of an Object array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, long[] array)[source]

Appends to the toString a summary of a long array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummary(StringBuffer buffer, String fieldName, short[] array)[source]

Appends to the toString a summary of a short array.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

protected void appendSummarySize(StringBuffer buffer, String fieldName, int size)[source]

Appends to the toString a size summary.

The size summary is used to summarize the contents of Collections, Maps and arrays.

The output consists of a prefix, the passed in size and a suffix.

The default format is "<size=n>".

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • size – The size to append.

public void appendSuper(StringBuffer buffer, String superToString)[source]

Appends to the toString the superclass toString.

NOTE: It assumes that the toString has been created from the same ToStringStyle.

A null superToString is ignored.

Parameters:
  • buffer – The StringBuffer to populate.

  • superToString – The super.toString().

Since:

2.0

public void appendToString(StringBuffer buffer, String toString)[source]

Appends to the toString another toString.

NOTE: It assumes that the toString has been created from the same ToStringStyle.

A null toString is ignored.

Parameters:
  • buffer – The StringBuffer to populate.

  • toString – The additional toString.

Since:

2.0

protected String getArrayEnd()[source]

Gets the array end text.

Returns:

The current array end text.

protected String getArraySeparator()[source]

Gets the array separator text.

Returns:

The current array separator text.

protected String getArrayStart()[source]

Gets the array start text.

Returns:

The current array start text.

protected String getContentEnd()[source]

Gets the content end text.

Returns:

The current content end text.

protected String getContentStart()[source]

Gets the content start text.

Returns:

The current content start text.

protected String getFieldNameValueSeparator()[source]

Gets the field name value separator text.

Returns:

The current field name value separator text.

protected String getFieldSeparator()[source]

Gets the field separator text.

Returns:

The current field separator text.

protected String getNullText()[source]

Gets the text to output when null found.

Returns:

The current text to output when null found.

public static Map<Object, Object> getRegistry()[source]

Gets the registry of objects being traversed by the reflectionToString methods in the current thread.

Returns:

Set the registry of objects being traversed.

protected String getShortClassName(Class<?> cls)[source]

Gets the short class name for a class.

The short class name is the class name excluding the package name.

Parameters:

cls – The Class to get the short name of.

Returns:

The short name.

protected String getSizeEndText()[source]

Gets the end text to output when a Collection, Map or array size is output.

This is output after the size value.

Returns:

The current end of size text.

protected String getSizeStartText()[source]

Gets the start text to output when a Collection, Map or array size is output.

This is output before the size value.

Returns:

The current start of size text.

protected String getSummaryObjectEndText()[source]

Gets the end text to output when an Object is output in summary mode.

This is output after the size value.

Returns:

The current end of summary text.

protected String getSummaryObjectStartText()[source]

Gets the start text to output when an Object is output in summary mode.

This is output before the size value.

Returns:

The current start of summary text.

protected boolean isArrayContentDetail()[source]

Tests whether to output array content detail.

Returns:

The current array content detail setting.

protected boolean isDefaultFullDetail()[source]

Tests whether full detail is used when the caller does not specify a detail level.

Returns:

The current defaultFullDetail flag.

protected boolean isFieldSeparatorAtEnd()[source]

Tests whether the field separator should be added at the end of each buffer.

Returns:

fieldSeparatorAtEnd flag.

Since:

2.0

protected boolean isFieldSeparatorAtStart()[source]

Tests whether the field separator should be added at the start of each buffer.

Returns:

The fieldSeparatorAtStart flag.

Since:

2.0

protected boolean isFullDetail(Boolean fullDetailRequest)[source]

Tests whether this field should be output in full detail.

This method converts a detail request into a detail level. The calling code may request full detail (true), but a subclass might ignore that and always return false. The calling code may pass in null indicating that it doesn’t care about the detail level. In this case the default detail level is used.

Parameters:

fullDetailRequest – The detail level requested.

Returns:

whether full detail is to be shown.

protected boolean isUseClassName()[source]

Tests whether to use the class name.

Returns:

The current useClassName flag.

protected boolean isUseFieldNames()[source]

Tests whether to use the field names passed in.

Returns:

The current useFieldNames flag.

protected boolean isUseIdentityHashCode()[source]

Tests whether to use the identity hash code.

Returns:

The current useIdentityHashCode flag.

protected boolean isUseShortClassName()[source]

Tests whether short class names should be output.

Returns:

The current useShortClassName flag.

Since:

2.0

protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)[source]

Appends to the toString the detail of an array type.

Parameters:
  • buffer – The StringBuffer to populate.

  • fieldName – The field name, typically not used as already appended.

  • array – The array to add to the toString, not null.

Since:

2.0

protected void removeLastFieldSeparator(StringBuffer buffer)[source]

Remove the last field separator from the buffer.

Parameters:

buffer – The StringBuffer to populate.

Since:

2.0

protected void setArrayContentDetail(boolean arrayContentDetail)[source]

Sets whether to output array content detail.

Parameters:

arrayContentDetail – The new arrayContentDetail flag.

protected void setArrayEnd(String arrayEnd)[source]

Sets the array end text.

null is accepted, but will be converted to an empty String.

Parameters:

arrayEnd – The new array end text.

protected void setArraySeparator(String arraySeparator)[source]

Sets the array separator text.

null is accepted, but will be converted to an empty String.

Parameters:

arraySeparator – The new array separator text.

protected void setArrayStart(String arrayStart)[source]

Sets the array start text.

null is accepted, but will be converted to an empty String.

Parameters:

arrayStart – The new array start text.

protected void setContentEnd(String contentEnd)[source]

Sets the content end text.

null is accepted, but will be converted to an empty String.

Parameters:

contentEnd – The new content end text.

protected void setContentStart(String contentStart)[source]

Sets the content start text.

null is accepted, but will be converted to an empty String.

Parameters:

contentStart – The new content start text.

protected void setDefaultFullDetail(boolean defaultFullDetail)[source]

Sets whether to use full detail when the caller doesn’t specify.

Parameters:

defaultFullDetail – The new defaultFullDetail flag.

protected void setFieldNameValueSeparator(String fieldNameValueSeparator)[source]

Sets the field name value separator text.

null is accepted, but will be converted to an empty String.

Parameters:

fieldNameValueSeparator – The new field name value separator text.

protected void setFieldSeparator(String fieldSeparator)[source]

Sets the field separator text.

null is accepted, but will be converted to an empty String.

Parameters:

fieldSeparator – The new field separator text.

protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd)[source]

Sets whether the field separator should be added at the end of each buffer.

Parameters:

fieldSeparatorAtEnd – The fieldSeparatorAtEnd flag.

Since:

2.0

protected void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart)[source]

Sets whether the field separator should be added at the start of each buffer.

Parameters:

fieldSeparatorAtStart – The fieldSeparatorAtStart flag.

Since:

2.0

protected void setNullText(String nullText)[source]

Sets the text to output when null found.

null is accepted, but will be converted to an empty String.

Parameters:

nullText – The new text to output when null found.

protected void setSizeEndText(String sizeEndText)[source]

Sets the end text to output when a Collection, Map or array size is output.

This is output after the size value.

null is accepted, but will be converted to an empty String.

Parameters:

sizeEndText – The new end of size text.

protected void setSizeStartText(String sizeStartText)[source]

Sets the start text to output when a Collection, Map or array size is output.

This is output before the size value.

null is accepted, but will be converted to an empty String.

Parameters:

sizeStartText – The new start of size text.

protected void setSummaryObjectEndText(String summaryObjectEndText)[source]

Sets the end text to output when an Object is output in summary mode.

This is output after the size value.

null is accepted, but will be converted to an empty String.

Parameters:

summaryObjectEndText – The new end of summary text.

protected void setSummaryObjectStartText(String summaryObjectStartText)[source]

Sets the start text to output when an Object is output in summary mode.

This is output before the size value.

null is accepted, but will be converted to an empty String.

Parameters:

summaryObjectStartText – The new start of summary text.

protected void setUseClassName(boolean useClassName)[source]

Sets whether to use the class name.

Parameters:

useClassName – The new useClassName flag.

protected void setUseFieldNames(boolean useFieldNames)[source]

Sets whether to use the field names passed in.

Parameters:

useFieldNames – The new useFieldNames flag.

protected void setUseIdentityHashCode(boolean useIdentityHashCode)[source]

Sets whether to use the identity hash code.

Parameters:

useIdentityHashCode – The new useIdentityHashCode flag.

protected void setUseShortClassName(boolean useShortClassName)[source]

Sets whether to output short or long class names.

Parameters:

useShortClassName – The new useShortClassName flag.

Since:

2.0