org.apache.commons.lang.builder

Class ToStringStyle

public abstract class ToStringStyle extends Object implements Serializable

Controls String formatting for {@link 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 {@link 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

Version: $Id: ToStringStyle.java 161243 2005-04-14 04:30:28Z ggregory $

Author: Stephen Colebourne Gary Gregory Pete Gieser Masato Tezuka

Field Summary
static ToStringStyleDEFAULT_STYLE
The default toString style.
static ToStringStyleMULTI_LINE_STYLE
The multi line toString style.
static ToStringStyleNO_FIELD_NAMES_STYLE
The no field names toString style.
static ToStringStyleSHORT_PREFIX_STYLE
The short prefix toString style.
static ToStringStyleSIMPLE_STYLE
The simple toString style.
Constructor Summary
protected ToStringStyle()

Constructor.

Method Summary
voidappend(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail)

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

voidappend(StringBuffer buffer, String fieldName, long value)

Append to the toString a long value.

voidappend(StringBuffer buffer, String fieldName, int value)

Append to the toString an int value.

voidappend(StringBuffer buffer, String fieldName, short value)

Append to the toString a short value.

voidappend(StringBuffer buffer, String fieldName, byte value)

Append to the toString a byte value.

voidappend(StringBuffer buffer, String fieldName, char value)

Append to the toString a char value.

voidappend(StringBuffer buffer, String fieldName, double value)

Append to the toString a double value.

voidappend(StringBuffer buffer, String fieldName, float value)

Append to the toString a float value.

voidappend(StringBuffer buffer, String fieldName, boolean value)

Append to the toString a boolean value.

voidappend(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail)

Append to the toString an Object array.

voidappend(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail)

Append to the toString a long array.

voidappend(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail)

Append to the toString an int array.

voidappend(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail)

Append to the toString a short array.

voidappend(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail)

Append to the toString a byte array.

voidappend(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail)

Append to the toString a char array.

voidappend(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail)

Append to the toString a double array.

voidappend(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail)

Append to the toString a float array.

voidappend(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail)

Append to the toString a boolean array.

protected voidappendClassName(StringBuffer buffer, Object object)

Append to the toString the class name.

protected voidappendContentEnd(StringBuffer buffer)

Append to the toString the content end.

protected voidappendContentStart(StringBuffer buffer)

Append to the toString the content start.

protected voidappendDetail(StringBuffer buffer, String fieldName, Object value)

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

protected voidappendDetail(StringBuffer buffer, String fieldName, Collection coll)

Append to the toString a Collection.

protected voidappendDetail(StringBuffer buffer, String fieldName, Map map)

Append to the toString a Map.

protected voidappendDetail(StringBuffer buffer, String fieldName, long value)

Append to the toString a long value.

protected voidappendDetail(StringBuffer buffer, String fieldName, int value)

Append to the toString an int value.

protected voidappendDetail(StringBuffer buffer, String fieldName, short value)

Append to the toString a short value.

protected voidappendDetail(StringBuffer buffer, String fieldName, byte value)

Append to the toString a byte value.

protected voidappendDetail(StringBuffer buffer, String fieldName, char value)

Append to the toString a char value.

protected voidappendDetail(StringBuffer buffer, String fieldName, double value)

Append to the toString a double value.

protected voidappendDetail(StringBuffer buffer, String fieldName, float value)

Append to the toString a float value.

protected voidappendDetail(StringBuffer buffer, String fieldName, boolean value)

Append to the toString a boolean value.

protected voidappendDetail(StringBuffer buffer, String fieldName, Object[] array)

Append to the toString the detail of an Object array.

protected voidappendDetail(StringBuffer buffer, String fieldName, long[] array)

Append to the toString the detail of a long array.

protected voidappendDetail(StringBuffer buffer, String fieldName, int[] array)

Append to the toString the detail of an int array.

protected voidappendDetail(StringBuffer buffer, String fieldName, short[] array)

Append to the toString the detail of a short array.

protected voidappendDetail(StringBuffer buffer, String fieldName, byte[] array)

Append to the toString the detail of a byte array.

protected voidappendDetail(StringBuffer buffer, String fieldName, char[] array)

Append to the toString the detail of a char array.

protected voidappendDetail(StringBuffer buffer, String fieldName, double[] array)

Append to the toString the detail of a double array.

protected voidappendDetail(StringBuffer buffer, String fieldName, float[] array)

Append to the toString the detail of a float array.

protected voidappendDetail(StringBuffer buffer, String fieldName, boolean[] array)

Append to the toString the detail of a boolean array.

voidappendEnd(StringBuffer buffer, Object object)

Append to the toString the end of data indicator.

protected voidappendFieldEnd(StringBuffer buffer, String fieldName)

Append to the toString the field end.

protected voidappendFieldSeparator(StringBuffer buffer)

Append to the toString the field separator.

protected voidappendFieldStart(StringBuffer buffer, String fieldName)

Append to the toString the field start.

protected voidappendIdentityHashCode(StringBuffer buffer, Object object)

Append the {@link System#identityHashCode(java.lang.Object)}.

protected voidappendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail)

Append 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.

protected voidappendNullText(StringBuffer buffer, String fieldName)

Append to the toString an indicator for null.

The default indicator is '<null>'.

voidappendStart(StringBuffer buffer, Object object)

Append to the toString the start of data indicator.

protected voidappendSummary(StringBuffer buffer, String fieldName, Object value)

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

protected voidappendSummary(StringBuffer buffer, String fieldName, Object[] array)

Append to the toString a summary of an Object array.

protected voidappendSummary(StringBuffer buffer, String fieldName, long[] array)

Append to the toString a summary of a long array.

protected voidappendSummary(StringBuffer buffer, String fieldName, int[] array)

Append to the toString a summary of an int array.

protected voidappendSummary(StringBuffer buffer, String fieldName, short[] array)

Append to the toString a summary of a short array.

protected voidappendSummary(StringBuffer buffer, String fieldName, byte[] array)

Append to the toString a summary of a byte array.

protected voidappendSummary(StringBuffer buffer, String fieldName, char[] array)

Append to the toString a summary of a char array.

protected voidappendSummary(StringBuffer buffer, String fieldName, double[] array)

Append to the toString a summary of a double array.

protected voidappendSummary(StringBuffer buffer, String fieldName, float[] array)

Append to the toString a summary of a float array.

protected voidappendSummary(StringBuffer buffer, String fieldName, boolean[] array)

Append to the toString a summary of a boolean array.

protected voidappendSummarySize(StringBuffer buffer, String fieldName, int size)

Append 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>'.

voidappendSuper(StringBuffer buffer, String superToString)

Append to the toString the superclass toString.

A null superToString is ignored.

voidappendToString(StringBuffer buffer, String toString)

Append to the toString another toString.

A null toString is ignored.

protected StringgetArrayEnd()

Gets the array end text.

protected StringgetArraySeparator()

Gets the array separator text.

protected StringgetArrayStart()

Gets the array start text.

protected StringgetContentEnd()

Gets the content end text.

protected StringgetContentStart()

Gets the content start text.

protected StringgetFieldNameValueSeparator()

Gets the field name value separator text.

protected StringgetFieldSeparator()

Gets the field separator text.

protected StringgetNullText()

Gets the text to output when null found.

protected StringgetShortClassName(Class cls)

Gets the short class name for a class.

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

protected StringgetSizeEndText()

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

This is output after the size value.

protected StringgetSizeStartText()

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

This is output before the size value.

protected StringgetSummaryObjectEndText()

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

This is output after the size value.

protected StringgetSummaryObjectStartText()

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

This is output before the size value.

protected booleanisArrayContentDetail()

Gets whether to output array content detail.

protected booleanisDefaultFullDetail()

Gets whether to use full detail when the caller doesn't specify.

protected booleanisFieldSeparatorAtEnd()

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

protected booleanisFieldSeparatorAtStart()

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

protected booleanisFullDetail(Boolean fullDetailRequest)

Is this field to be output in full detail.

This method converts a detail request into a detail level.

protected booleanisShortClassName()

Gets whether to output short or long class names.

protected booleanisUseClassName()

Gets whether to use the class name.

protected booleanisUseFieldNames()

Gets whether to use the field names passed in.

protected booleanisUseIdentityHashCode()

Gets whether to use the identity hash code.

protected booleanisUseShortClassName()

Gets whether to output short or long class names.

protected voidreflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)

Append to the toString the detail of an array type.

protected voidremoveLastFieldSeparator(StringBuffer buffer)

Remove the last field separator from the buffer.

protected voidsetArrayContentDetail(boolean arrayContentDetail)

Sets whether to output array content detail.

protected voidsetArrayEnd(String arrayEnd)

Sets the array end text.

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

protected voidsetArraySeparator(String arraySeparator)

Sets the array separator text.

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

protected voidsetArrayStart(String arrayStart)

Sets the array start text.

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

protected voidsetContentEnd(String contentEnd)

Sets the content end text.

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

protected voidsetContentStart(String contentStart)

Sets the content start text.

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

protected voidsetDefaultFullDetail(boolean defaultFullDetail)

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

protected voidsetFieldNameValueSeparator(String fieldNameValueSeparator)

Sets the field name value separator text.

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

protected voidsetFieldSeparator(String fieldSeparator)

Sets the field separator text.

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

protected voidsetFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd)

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

protected voidsetFieldSeparatorAtStart(boolean fieldSeparatorAtStart)

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

protected voidsetNullText(String nullText)

Sets the text to output when null found.

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

protected voidsetShortClassName(boolean shortClassName)

Sets whether to output short or long class names.

protected voidsetSizeEndText(String sizeEndText)

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.

protected voidsetSizeStartText(String sizeStartText)

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.

protected voidsetSummaryObjectEndText(String summaryObjectEndText)

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.

protected voidsetSummaryObjectStartText(String summaryObjectStartText)

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.

protected voidsetUseClassName(boolean useClassName)

Sets whether to use the class name.

protected voidsetUseFieldNames(boolean useFieldNames)

Sets whether to use the field names passed in.

protected voidsetUseIdentityHashCode(boolean useIdentityHashCode)

Sets whether to use the identity hash code.

protected voidsetUseShortClassName(boolean useShortClassName)

Sets whether to output short or long class names.

Field Detail

DEFAULT_STYLE

public static final ToStringStyle DEFAULT_STYLE
The default toString style.

MULTI_LINE_STYLE

public static final ToStringStyle MULTI_LINE_STYLE
The multi line toString style.

NO_FIELD_NAMES_STYLE

public static final ToStringStyle NO_FIELD_NAMES_STYLE
The no field names toString style.

SHORT_PREFIX_STYLE

public static final ToStringStyle SHORT_PREFIX_STYLE
The short prefix toString style.

Since: 2.1

SIMPLE_STYLE

public static final ToStringStyle SIMPLE_STYLE
The simple toString style.

Constructor Detail

ToStringStyle

protected ToStringStyle()

Constructor.

Method Detail

append

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

Append 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

append

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

Append to the toString a long value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString an int value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString a short value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString a byte value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString a char value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString a double value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString a float value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append to the toString a boolean value.

Parameters: buffer the StringBuffer to populate fieldName the field name value the value to add to the toString

append

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

Append 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

append

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

Append 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

append

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

Append 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

append

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

Append 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

append

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

Append 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

append

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

Append 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

append

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

Append 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

append

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

Append 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

append

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

Append 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

appendClassName

protected void appendClassName(StringBuffer buffer, Object object)

Append to the toString the class name.

Parameters: buffer the StringBuffer to populate object the Object whose name to output

appendContentEnd

protected void appendContentEnd(StringBuffer buffer)

Append to the toString the content end.

Parameters: buffer the StringBuffer to populate

appendContentStart

protected void appendContentStart(StringBuffer buffer)

Append to the toString the content start.

Parameters: buffer the StringBuffer to populate

appendDetail

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

Append 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

appendDetail

protected void appendDetail(StringBuffer buffer, String fieldName, Collection coll)

Append 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

appendDetail

protected void appendDetail(StringBuffer buffer, String fieldName, Map map)

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendDetail

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

Append 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

appendEnd

public void appendEnd(StringBuffer buffer, Object object)

Append to the toString the end of data indicator.

Parameters: buffer the StringBuffer to populate object the Object to build a toString for.

appendFieldEnd

protected void appendFieldEnd(StringBuffer buffer, String fieldName)

Append to the toString the field end.

Parameters: buffer the StringBuffer to populate fieldName the field name, typically not used as already appended

appendFieldSeparator

protected void appendFieldSeparator(StringBuffer buffer)

Append to the toString the field separator.

Parameters: buffer the StringBuffer to populate

appendFieldStart

protected void appendFieldStart(StringBuffer buffer, String fieldName)

Append to the toString the field start.

Parameters: buffer the StringBuffer to populate fieldName the field name

appendIdentityHashCode

protected void appendIdentityHashCode(StringBuffer buffer, Object object)

Append the {@link System#identityHashCode(java.lang.Object)}.

Parameters: buffer the StringBuffer to populate object the Object whose id to output

appendInternal

protected void appendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail)

Append 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

appendNullText

protected void appendNullText(StringBuffer buffer, String fieldName)

Append 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

appendStart

public void appendStart(StringBuffer buffer, Object object)

Append to the toString the start of data indicator.

Parameters: buffer the StringBuffer to populate object the Object to build a toString for

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummary

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

Append 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

appendSummarySize

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

Append 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

appendSuper

public void appendSuper(StringBuffer buffer, String superToString)

Append to the toString the superclass toString.

A null superToString is ignored.

Parameters: buffer the StringBuffer to populate superToString the super.toString()

Since: 2.0

appendToString

public void appendToString(StringBuffer buffer, String toString)

Append to the toString another toString.

A null toString is ignored.

Parameters: buffer the StringBuffer to populate toString the additional toString

Since: 2.0

getArrayEnd

protected String getArrayEnd()

Gets the array end text.

Returns: the current array end text

getArraySeparator

protected String getArraySeparator()

Gets the array separator text.

Returns: the current array separator text

getArrayStart

protected String getArrayStart()

Gets the array start text.

Returns: the current array start text

getContentEnd

protected String getContentEnd()

Gets the content end text.

Returns: the current content end text

getContentStart

protected String getContentStart()

Gets the content start text.

Returns: the current content start text

getFieldNameValueSeparator

protected String getFieldNameValueSeparator()

Gets the field name value separator text.

Returns: the current field name value separator text

getFieldSeparator

protected String getFieldSeparator()

Gets the field separator text.

Returns: the current field separator text

getNullText

protected String getNullText()

Gets the text to output when null found.

Returns: the current text to output when null found

getShortClassName

protected String getShortClassName(Class cls)

Gets the short class name for a class.

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

Parameters: cls the Class to get the short name of

Returns: the short name

getSizeEndText

protected String getSizeEndText()

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

getSizeStartText

protected String getSizeStartText()

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

getSummaryObjectEndText

protected String getSummaryObjectEndText()

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

getSummaryObjectStartText

protected String getSummaryObjectStartText()

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

isArrayContentDetail

protected boolean isArrayContentDetail()

Gets whether to output array content detail.

Returns: the current array content detail setting

isDefaultFullDetail

protected boolean isDefaultFullDetail()

Gets whether to use full detail when the caller doesn't specify.

Returns: the current defaultFullDetail flag

isFieldSeparatorAtEnd

protected boolean isFieldSeparatorAtEnd()

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

Returns: fieldSeparatorAtEnd flag

Since: 2.0

isFieldSeparatorAtStart

protected boolean isFieldSeparatorAtStart()

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

Returns: the fieldSeparatorAtStart flag

Since: 2.0

isFullDetail

protected boolean isFullDetail(Boolean fullDetailRequest)

Is this field to 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

isShortClassName

protected boolean isShortClassName()

Deprecated: Use {@link #isUseShortClassName()} Method will be removed in Commons Lang 3.0.

Gets whether to output short or long class names.

Returns: the current shortClassName flag

isUseClassName

protected boolean isUseClassName()

Gets whether to use the class name.

Returns: the current useClassName flag

isUseFieldNames

protected boolean isUseFieldNames()

Gets whether to use the field names passed in.

Returns: the current useFieldNames flag

isUseIdentityHashCode

protected boolean isUseIdentityHashCode()

Gets whether to use the identity hash code.

Returns: the current useIdentityHashCode flag

isUseShortClassName

protected boolean isUseShortClassName()

Gets whether to output short or long class names.

Returns: the current useShortClassName flag

Since: 2.0

reflectionAppendArrayDetail

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

Append 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

removeLastFieldSeparator

protected void removeLastFieldSeparator(StringBuffer buffer)

Remove the last field separator from the buffer.

Parameters: buffer the StringBuffer to populate

Since: 2.0

setArrayContentDetail

protected void setArrayContentDetail(boolean arrayContentDetail)

Sets whether to output array content detail.

Parameters: arrayContentDetail the new arrayContentDetail flag

setArrayEnd

protected void setArrayEnd(String arrayEnd)

Sets the array end text.

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

Parameters: arrayEnd the new array end text

setArraySeparator

protected void setArraySeparator(String arraySeparator)

Sets the array separator text.

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

Parameters: arraySeparator the new array separator text

setArrayStart

protected void setArrayStart(String arrayStart)

Sets the array start text.

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

Parameters: arrayStart the new array start text

setContentEnd

protected void setContentEnd(String contentEnd)

Sets the content end text.

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

Parameters: contentEnd the new content end text

setContentStart

protected void setContentStart(String contentStart)

Sets the content start text.

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

Parameters: contentStart the new content start text

setDefaultFullDetail

protected void setDefaultFullDetail(boolean defaultFullDetail)

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

Parameters: defaultFullDetail the new defaultFullDetail flag

setFieldNameValueSeparator

protected void setFieldNameValueSeparator(String fieldNameValueSeparator)

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

setFieldSeparator

protected void setFieldSeparator(String fieldSeparator)

Sets the field separator text.

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

Parameters: fieldSeparator the new field separator text

setFieldSeparatorAtEnd

protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd)

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

Parameters: fieldSeparatorAtEnd the fieldSeparatorAtEnd flag

Since: 2.0

setFieldSeparatorAtStart

protected void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart)

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

Parameters: fieldSeparatorAtStart the fieldSeparatorAtStart flag

Since: 2.0

setNullText

protected void setNullText(String nullText)

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

setShortClassName

protected void setShortClassName(boolean shortClassName)

Deprecated: Use {@link #setUseShortClassName(boolean)} Method will be removed in Commons Lang 3.0.

Sets whether to output short or long class names.

Parameters: shortClassName the new shortClassName flag

setSizeEndText

protected void setSizeEndText(String sizeEndText)

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

setSizeStartText

protected void setSizeStartText(String sizeStartText)

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

setSummaryObjectEndText

protected void setSummaryObjectEndText(String summaryObjectEndText)

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

setSummaryObjectStartText

protected void setSummaryObjectStartText(String summaryObjectStartText)

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

setUseClassName

protected void setUseClassName(boolean useClassName)

Sets whether to use the class name.

Parameters: useClassName the new useClassName flag

setUseFieldNames

protected void setUseFieldNames(boolean useFieldNames)

Sets whether to use the field names passed in.

Parameters: useFieldNames the new useFieldNames flag

setUseIdentityHashCode

protected void setUseIdentityHashCode(boolean useIdentityHashCode)

Sets whether to use the identity hash code.

Parameters: useIdentityHashCode the new useIdentityHashCode flag

setUseShortClassName

protected void setUseShortClassName(boolean useShortClassName)

Sets whether to output short or long class names.

Parameters: useShortClassName the new useShortClassName flag

Since: 2.0

Copyright © 2001-2005 - Apache Software Foundation