Class ToStringStyle
- java.lang.Object
-
- org.apache.commons.lang3.builder.ToStringStyle
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
RecursiveToStringStyle,StandardToStringStyle
public abstract class ToStringStyle extends java.lang.Object implements java.io.SerializableControls
Stringformatting forToStringBuilder. The main public interface is always viaToStringBuilder.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, theStandardToStringStyleclass 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
booleantolongtoObjecttoint[]) 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
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ToStringStyleDEFAULT_STYLEThe default toString style.static ToStringStyleJSON_STYLEThe JSON toString style.static ToStringStyleMULTI_LINE_STYLEThe multi line toString style.static ToStringStyleNO_CLASS_NAME_STYLEThe no class name toString style.static ToStringStyleNO_FIELD_NAMES_STYLEThe no field names toString style.static ToStringStyleSHORT_PREFIX_STYLEThe short prefix toString style.static ToStringStyleSIMPLE_STYLEThe simple toString style.
-
Constructor Summary
Constructors Modifier Constructor Description protectedToStringStyle()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean value)Append to thetoStringabooleanvalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array, java.lang.Boolean fullDetail)Append to thetoStringabooleanarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, byte value)Append to thetoStringabytevalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)Append to thetoStringabytearray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Append to thetoStringacharvalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)Append to thetoStringachararray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, double value)Append to thetoStringadoublevalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)Append to thetoStringadoublearray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, float value)Append to thetoStringafloatvalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)Append to thetoStringafloatarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, int value)Append to thetoStringanintvalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)Append to thetoStringanintarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, long value)Append to thetoStringalongvalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)Append to thetoStringalongarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, short value)Append to thetoStringashortvalue.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)Append to thetoStringashortarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)Append to thetoStringanObjectarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, java.lang.Boolean fullDetail)Append to thetoStringanObjectvalue, printing the fulltoStringof theObjectpassed in.protected voidappendClassName(java.lang.StringBuffer buffer, java.lang.Object object)Append to thetoStringthe class name.protected voidappendContentEnd(java.lang.StringBuffer buffer)Append to thetoStringthe content end.protected voidappendContentStart(java.lang.StringBuffer buffer)Append to thetoStringthe content start.protected voidappendCyclicObject(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to thetoStringanObjectvalue that has been detected to participate in a cycle.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean value)Append to thetoStringabooleanvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array)Append to thetoStringthe detail of abooleanarray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, byte value)Append to thetoStringabytevalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array)Append to thetoStringthe detail of abytearray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Append to thetoStringacharvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array)Append to thetoStringthe detail of achararray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, double value)Append to thetoStringadoublevalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array)Append to thetoStringthe detail of adoublearray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, float value)Append to thetoStringafloatvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array)Append to thetoStringthe detail of afloatarray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int value)Append to thetoStringanintvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array)Append to thetoStringthe detail of anintarray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int i, java.lang.Object item)Append to thetoStringthe detail of anObjectarray item.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, long value)Append to thetoStringalongvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array)Append to thetoStringthe detail of alongarray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, short value)Append to thetoStringashortvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array)Append to thetoStringthe detail of ashortarray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to thetoStringanObjectvalue, printing the full detail of theObject.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array)Append to thetoStringthe detail of anObjectarray.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Collection<?> coll)Append to thetoStringaCollection.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)Append to thetoStringaMap.voidappendEnd(java.lang.StringBuffer buffer, java.lang.Object object)Append to thetoStringthe end of data indicator.protected voidappendFieldEnd(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to thetoStringthe field end.protected voidappendFieldSeparator(java.lang.StringBuffer buffer)Append to thetoStringthe field separator.protected voidappendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to thetoStringthe field start.protected voidappendIdentityHashCode(java.lang.StringBuffer buffer, java.lang.Object object)Append theSystem.identityHashCode(java.lang.Object).protected voidappendInternal(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, boolean detail)Append to thetoStringanObject, correctly interpreting its type.protected voidappendNullText(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to thetoStringan indicator fornull.voidappendStart(java.lang.StringBuffer buffer, java.lang.Object object)Append to thetoStringthe start of data indicator.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array)Append to thetoStringa summary of abooleanarray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array)Append to thetoStringa summary of abytearray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array)Append to thetoStringa summary of achararray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array)Append to thetoStringa summary of adoublearray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array)Append to thetoStringa summary of afloatarray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array)Append to thetoStringa summary of anintarray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array)Append to thetoStringa summary of alongarray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array)Append to thetoStringa summary of ashortarray.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to thetoStringanObjectvalue, printing a summary of theObject.protected voidappendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array)Append to thetoStringa summary of anObjectarray.protected voidappendSummarySize(java.lang.StringBuffer buffer, java.lang.String fieldName, int size)Append to thetoStringa size summary.voidappendSuper(java.lang.StringBuffer buffer, java.lang.String superToString)Append to thetoStringthe superclass toString.voidappendToString(java.lang.StringBuffer buffer, java.lang.String toString)Append to thetoStringanother toString.protected java.lang.StringgetArrayEnd()Gets the array end text.protected java.lang.StringgetArraySeparator()Gets the array separator text.protected java.lang.StringgetArrayStart()Gets the array start text.protected java.lang.StringgetContentEnd()Gets the content end text.protected java.lang.StringgetContentStart()Gets the content start text.protected java.lang.StringgetFieldNameValueSeparator()Gets the field name value separator text.protected java.lang.StringgetFieldSeparator()Gets the field separator text.protected java.lang.StringgetNullText()Gets the text to output whennullfound.protected java.lang.StringgetShortClassName(java.lang.Class<?> cls)Gets the short class name for a class.protected java.lang.StringgetSizeEndText()Gets the end text to output when aCollection,Mapor array size is output.protected java.lang.StringgetSizeStartText()Gets the start text to output when aCollection,Mapor array size is output.protected java.lang.StringgetSummaryObjectEndText()Gets the end text to output when anObjectis output in summary mode.protected java.lang.StringgetSummaryObjectStartText()Gets the start text to output when anObjectis output in summary mode.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(java.lang.Boolean fullDetailRequest)Is this field to be output in full detail.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(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object array)Append to thetoStringthe detail of an array type.protected voidremoveLastFieldSeparator(java.lang.StringBuffer buffer)Remove the last field separator from the buffer.protected voidsetArrayContentDetail(boolean arrayContentDetail)Sets whether to output array content detail.protected voidsetArrayEnd(java.lang.String arrayEnd)Sets the array end text.protected voidsetArraySeparator(java.lang.String arraySeparator)Sets the array separator text.protected voidsetArrayStart(java.lang.String arrayStart)Sets the array start text.protected voidsetContentEnd(java.lang.String contentEnd)Sets the content end text.protected voidsetContentStart(java.lang.String contentStart)Sets the content start text.protected voidsetDefaultFullDetail(boolean defaultFullDetail)Sets whether to use full detail when the caller doesn't specify.protected voidsetFieldNameValueSeparator(java.lang.String fieldNameValueSeparator)Sets the field name value separator text.protected voidsetFieldSeparator(java.lang.String fieldSeparator)Sets the field separator text.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(java.lang.String nullText)Sets the text to output whennullfound.protected voidsetSizeEndText(java.lang.String sizeEndText)Sets the end text to output when aCollection,Mapor array size is output.protected voidsetSizeStartText(java.lang.String sizeStartText)Sets the start text to output when aCollection,Mapor array size is output.protected voidsetSummaryObjectEndText(java.lang.String summaryObjectEndText)Sets the end text to output when anObjectis output in summary mode.protected voidsetSummaryObjectStartText(java.lang.String summaryObjectStartText)Sets the start text to output when anObjectis output in summary mode.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. Using thePersonexample fromToStringBuilder, the output would look like this:Person@182f0db[name=John Doe,age=33,smoker=false]
-
MULTI_LINE_STYLE
public static final ToStringStyle MULTI_LINE_STYLE
The multi line toString style. Using thePersonexample fromToStringBuilder, the output would look like this:Person@182f0db[ name=John Doe age=33 smoker=false ]
-
NO_FIELD_NAMES_STYLE
public static final ToStringStyle NO_FIELD_NAMES_STYLE
The no field names toString style. Using thePersonexample fromToStringBuilder, the output would look like this:Person@182f0db[John Doe,33,false]
-
SHORT_PREFIX_STYLE
public static final ToStringStyle SHORT_PREFIX_STYLE
The short prefix toString style. Using thePersonexample fromToStringBuilder, the output would look like this:Person[name=John Doe,age=33,smoker=false]
- Since:
- 2.1
-
SIMPLE_STYLE
public static final ToStringStyle SIMPLE_STYLE
The simple toString style. Using thePersonexample fromToStringBuilder, the output would look like this:John Doe,33,false
-
NO_CLASS_NAME_STYLE
public static final ToStringStyle NO_CLASS_NAME_STYLE
The no class name toString style. Using thePersonexample fromToStringBuilder, the output would look like this:[name=John Doe,age=33,smoker=false]
- Since:
- 3.4
-
JSON_STYLE
public static final ToStringStyle JSON_STYLE
The JSON toString style. Using thePersonexample fromToStringBuilder, 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 anUnsupportedOperationExceptionif no field name is passed in while appending. Furthermore This ToStringStyle will only generate valid JSON if referenced objects also produce JSON when callingtoString()on them.- Since:
- 3.4
- See Also:
- json.org
-
-
Method Detail
-
appendSuper
public void appendSuper(java.lang.StringBuffer buffer, java.lang.String superToString)Append to the
toStringthe superclass toString.NOTE: It assumes that the toString has been created from the same ToStringStyle.
A
nullsuperToStringis ignored.- Parameters:
buffer- theStringBufferto populatesuperToString- thesuper.toString()- Since:
- 2.0
-
appendToString
public void appendToString(java.lang.StringBuffer buffer, java.lang.String toString)Append to the
toStringanother toString.NOTE: It assumes that the toString has been created from the same ToStringStyle.
A
nulltoStringis ignored.- Parameters:
buffer- theStringBufferto populatetoString- the additionaltoString- Since:
- 2.0
-
appendStart
public void appendStart(java.lang.StringBuffer buffer, java.lang.Object object)Append to the
toStringthe start of data indicator.- Parameters:
buffer- theStringBufferto populateobject- theObjectto build atoStringfor
-
appendEnd
public void appendEnd(java.lang.StringBuffer buffer, java.lang.Object object)Append to the
toStringthe end of data indicator.- Parameters:
buffer- theStringBufferto populateobject- theObjectto build atoStringfor.
-
removeLastFieldSeparator
protected void removeLastFieldSeparator(java.lang.StringBuffer buffer)
Remove the last field separator from the buffer.
- Parameters:
buffer- theStringBufferto populate- Since:
- 2.0
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, java.lang.Boolean fullDetail)Append to the
toStringanObjectvalue, printing the fulltoStringof theObjectpassed in.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendInternal
protected void appendInternal(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, boolean detail)Append to the
toStringanObject, correctly interpreting its type.This method performs the main lookup by Class type to correctly route arrays,
Collections,MapsandObjectsto 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- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString, notnulldetail- output detail or not
-
appendCyclicObject
protected void appendCyclicObject(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to the
toStringanObjectvalue that has been detected to participate in a cycle. This implementation will print the standard string value of the value.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString, notnull- Since:
- 2.2
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to the
toStringanObjectvalue, printing the full detail of theObject.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Collection<?> coll)Append to the
toStringaCollection.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedcoll- theCollectionto add to thetoString, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)Append to the
toStringaMap.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedmap- theMapto add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to the
toStringanObjectvalue, printing a summary of theObject.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, long value)Append to the
toStringalongvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, long value)Append to the
toStringalongvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, int value)Append to the
toStringanintvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int value)Append to the
toStringanintvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, short value)Append to the
toStringashortvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, short value)Append to the
toStringashortvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, byte value)Append to the
toStringabytevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, byte value)Append to the
toStringabytevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Append to the
toStringacharvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Append to the
toStringacharvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, double value)Append to the
toStringadoublevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, double value)Append to the
toStringadoublevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, float value)Append to the
toStringafloatvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, float value)Append to the
toStringafloatvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean value)Append to the
toStringabooleanvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean value)Append to the
toStringabooleanvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)Append to the
toStringanObjectarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array)Append to the
toStringthe detail of anObjectarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int i, java.lang.Object item)Append to the
toStringthe detail of anObjectarray item.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedi- the array item index to additem- the array item to add- Since:
- 3.11
-
reflectionAppendArrayDetail
protected void reflectionAppendArrayDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object array)Append to the
toStringthe detail of an array type.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull- Since:
- 2.0
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array)Append to the
toStringa summary of anObjectarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)Append to the
toStringalongarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array)Append to the
toStringthe detail of alongarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array)Append to the
toStringa summary of alongarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)Append to the
toStringanintarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array)Append to the
toStringthe detail of anintarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array)Append to the
toStringa summary of anintarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)Append to the
toStringashortarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array)Append to the
toStringthe detail of ashortarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array)Append to the
toStringa summary of ashortarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)Append to the
toStringabytearray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array)Append to the
toStringthe detail of abytearray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array)Append to the
toStringa summary of abytearray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)Append to the
toStringachararray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array)Append to the
toStringthe detail of achararray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array)Append to the
toStringa summary of achararray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)Append to the
toStringadoublearray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array)Append to the
toStringthe detail of adoublearray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array)Append to the
toStringa summary of adoublearray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)Append to the
toStringafloatarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array)Append to the
toStringthe detail of afloatarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array)Append to the
toStringa summary of afloatarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array, java.lang.Boolean fullDetail)Append to the
toStringabooleanarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array)Append to the
toStringthe detail of abooleanarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendSummary
protected void appendSummary(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array)Append to the
toStringa summary of abooleanarray.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedarray- the array to add to thetoString, notnull
-
appendClassName
protected void appendClassName(java.lang.StringBuffer buffer, java.lang.Object object)Append to the
toStringthe class name.- Parameters:
buffer- theStringBufferto populateobject- theObjectwhose name to output
-
appendIdentityHashCode
protected void appendIdentityHashCode(java.lang.StringBuffer buffer, java.lang.Object object)Append the
System.identityHashCode(java.lang.Object).- Parameters:
buffer- theStringBufferto populateobject- theObjectwhose id to output
-
appendContentStart
protected void appendContentStart(java.lang.StringBuffer buffer)
Append to the
toStringthe content start.- Parameters:
buffer- theStringBufferto populate
-
appendContentEnd
protected void appendContentEnd(java.lang.StringBuffer buffer)
Append to the
toStringthe content end.- Parameters:
buffer- theStringBufferto populate
-
appendNullText
protected void appendNullText(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to the
toStringan indicator fornull.The default indicator is
'<null>'.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appended
-
appendFieldSeparator
protected void appendFieldSeparator(java.lang.StringBuffer buffer)
Append to the
toStringthe field separator.- Parameters:
buffer- theStringBufferto populate
-
appendFieldStart
protected void appendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to the
toStringthe field start.- Parameters:
buffer- theStringBufferto populatefieldName- the field name
-
appendFieldEnd
protected void appendFieldEnd(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to the
toStringthe field end.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appended
-
appendSummarySize
protected void appendSummarySize(java.lang.StringBuffer buffer, java.lang.String fieldName, int size)Append to the
toStringa size summary.The size summary is used to summarize the contents of
Collections,Mapsand arrays.The output consists of a prefix, the passed in size and a suffix.
The default format is
'<size=n>'.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedsize- the size to append
-
isFullDetail
protected boolean isFullDetail(java.lang.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 returnfalse. The calling code may pass innullindicating 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
-
getShortClassName
protected java.lang.String getShortClassName(java.lang.Class<?> cls)
Gets the short class name for a class.
The short class name is the classname excluding the package name.
- Parameters:
cls- theClassto get the short name of- Returns:
- the short name
-
isUseClassName
protected boolean isUseClassName()
Gets whether to use the class name.
- Returns:
- the current useClassName flag
-
setUseClassName
protected void setUseClassName(boolean useClassName)
Sets whether to use the class name.
- Parameters:
useClassName- the new useClassName flag
-
isUseShortClassName
protected boolean isUseShortClassName()
Gets whether to output short or long class names.
- Returns:
- the current useShortClassName flag
- Since:
- 2.0
-
setUseShortClassName
protected void setUseShortClassName(boolean useShortClassName)
Sets whether to output short or long class names.
- Parameters:
useShortClassName- the new useShortClassName flag- Since:
- 2.0
-
isUseIdentityHashCode
protected boolean isUseIdentityHashCode()
Gets whether to use the identity hash code.
- Returns:
- the current useIdentityHashCode flag
-
setUseIdentityHashCode
protected void setUseIdentityHashCode(boolean useIdentityHashCode)
Sets whether to use the identity hash code.
- Parameters:
useIdentityHashCode- the new useIdentityHashCode flag
-
isUseFieldNames
protected boolean isUseFieldNames()
Gets whether to use the field names passed in.
- Returns:
- the current useFieldNames flag
-
setUseFieldNames
protected void setUseFieldNames(boolean useFieldNames)
Sets whether to use the field names passed in.
- Parameters:
useFieldNames- the new useFieldNames flag
-
isDefaultFullDetail
protected boolean isDefaultFullDetail()
Gets whether to use full detail when the caller doesn't specify.
- Returns:
- the current defaultFullDetail flag
-
setDefaultFullDetail
protected void setDefaultFullDetail(boolean defaultFullDetail)
Sets whether to use full detail when the caller doesn't specify.
- Parameters:
defaultFullDetail- the new defaultFullDetail flag
-
isArrayContentDetail
protected boolean isArrayContentDetail()
Gets whether to output array content detail.
- Returns:
- the current array content detail setting
-
setArrayContentDetail
protected void setArrayContentDetail(boolean arrayContentDetail)
Sets whether to output array content detail.
- Parameters:
arrayContentDetail- the new arrayContentDetail flag
-
getArrayStart
protected java.lang.String getArrayStart()
Gets the array start text.
- Returns:
- the current array start text
-
setArrayStart
protected void setArrayStart(java.lang.String arrayStart)
Sets the array start text.
nullis accepted, but will be converted to an empty String.- Parameters:
arrayStart- the new array start text
-
getArrayEnd
protected java.lang.String getArrayEnd()
Gets the array end text.
- Returns:
- the current array end text
-
setArrayEnd
protected void setArrayEnd(java.lang.String arrayEnd)
Sets the array end text.
nullis accepted, but will be converted to an empty String.- Parameters:
arrayEnd- the new array end text
-
getArraySeparator
protected java.lang.String getArraySeparator()
Gets the array separator text.
- Returns:
- the current array separator text
-
setArraySeparator
protected void setArraySeparator(java.lang.String arraySeparator)
Sets the array separator text.
nullis accepted, but will be converted to an empty String.- Parameters:
arraySeparator- the new array separator text
-
getContentStart
protected java.lang.String getContentStart()
Gets the content start text.
- Returns:
- the current content start text
-
setContentStart
protected void setContentStart(java.lang.String contentStart)
Sets the content start text.
nullis accepted, but will be converted to an empty String.- Parameters:
contentStart- the new content start text
-
getContentEnd
protected java.lang.String getContentEnd()
Gets the content end text.
- Returns:
- the current content end text
-
setContentEnd
protected void setContentEnd(java.lang.String contentEnd)
Sets the content end text.
nullis accepted, but will be converted to an empty String.- Parameters:
contentEnd- the new content end text
-
getFieldNameValueSeparator
protected java.lang.String getFieldNameValueSeparator()
Gets the field name value separator text.
- Returns:
- the current field name value separator text
-
setFieldNameValueSeparator
protected void setFieldNameValueSeparator(java.lang.String fieldNameValueSeparator)
Sets the field name value separator text.
nullis accepted, but will be converted to an empty String.- Parameters:
fieldNameValueSeparator- the new field name value separator text
-
getFieldSeparator
protected java.lang.String getFieldSeparator()
Gets the field separator text.
- Returns:
- the current field separator text
-
setFieldSeparator
protected void setFieldSeparator(java.lang.String fieldSeparator)
Sets the field separator text.
nullis accepted, but will be converted to an empty String.- Parameters:
fieldSeparator- the new field separator text
-
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
-
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
-
isFieldSeparatorAtEnd
protected boolean isFieldSeparatorAtEnd()
Gets whether the field separator should be added at the end of each buffer.
- Returns:
- fieldSeparatorAtEnd flag
- Since:
- 2.0
-
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
-
getNullText
protected java.lang.String getNullText()
Gets the text to output when
nullfound.- Returns:
- the current text to output when null found
-
setNullText
protected void setNullText(java.lang.String nullText)
Sets the text to output when
nullfound.nullis accepted, but will be converted to an empty String.- Parameters:
nullText- the new text to output when null found
-
getSizeStartText
protected java.lang.String getSizeStartText()
Gets the start text to output when a
Collection,Mapor array size is output.This is output before the size value.
- Returns:
- the current start of size text
-
setSizeStartText
protected void setSizeStartText(java.lang.String sizeStartText)
Sets the start text to output when a
Collection,Mapor array size is output.This is output before the size value.
nullis accepted, but will be converted to an empty String.- Parameters:
sizeStartText- the new start of size text
-
getSizeEndText
protected java.lang.String getSizeEndText()
Gets the end text to output when a
Collection,Mapor array size is output.This is output after the size value.
- Returns:
- the current end of size text
-
setSizeEndText
protected void setSizeEndText(java.lang.String sizeEndText)
Sets the end text to output when a
Collection,Mapor array size is output.This is output after the size value.
nullis accepted, but will be converted to an empty String.- Parameters:
sizeEndText- the new end of size text
-
getSummaryObjectStartText
protected java.lang.String getSummaryObjectStartText()
Gets the start text to output when an
Objectis output in summary mode.This is output before the size value.
- Returns:
- the current start of summary text
-
setSummaryObjectStartText
protected void setSummaryObjectStartText(java.lang.String summaryObjectStartText)
Sets the start text to output when an
Objectis output in summary mode.This is output before the size value.
nullis accepted, but will be converted to an empty String.- Parameters:
summaryObjectStartText- the new start of summary text
-
getSummaryObjectEndText
protected java.lang.String getSummaryObjectEndText()
Gets the end text to output when an
Objectis output in summary mode.This is output after the size value.
- Returns:
- the current end of summary text
-
setSummaryObjectEndText
protected void setSummaryObjectEndText(java.lang.String summaryObjectEndText)
Sets the end text to output when an
Objectis output in summary mode.This is output after the size value.
nullis accepted, but will be converted to an empty String.- Parameters:
summaryObjectEndText- the new end of summary text
-
-