Class ToStringStyle
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
StandardToStringStyle
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
- Version:
- $Id: ToStringStyle.java 907168 2010-02-06 03:33:50Z mbenson $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ToStringStyleThe default toString style.static final ToStringStyleThe multi line toString style.static final ToStringStyleThe no field names toString style.static final ToStringStyleThe short prefix toString style.static final ToStringStyleThe simple toString style. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(StringBuffer buffer, String fieldName, boolean value) Append to thetoStringabooleanvalue.voidappend(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail) Append to thetoStringabooleanarray.voidappend(StringBuffer buffer, String fieldName, byte value) Append to thetoStringabytevalue.voidappend(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail) Append to thetoStringabytearray.voidappend(StringBuffer buffer, String fieldName, char value) Append to thetoStringacharvalue.voidappend(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail) Append to thetoStringachararray.voidappend(StringBuffer buffer, String fieldName, double value) Append to thetoStringadoublevalue.voidappend(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail) Append to thetoStringadoublearray.voidappend(StringBuffer buffer, String fieldName, float value) Append to thetoStringafloatvalue.voidappend(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail) Append to thetoStringafloatarray.voidappend(StringBuffer buffer, String fieldName, int value) Append to thetoStringanintvalue.voidappend(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail) Append to thetoStringanintarray.voidappend(StringBuffer buffer, String fieldName, long value) Append to thetoStringalongvalue.voidappend(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail) Append to thetoStringalongarray.voidappend(StringBuffer buffer, String fieldName, short value) Append to thetoStringashortvalue.voidappend(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail) Append to thetoStringashortarray.voidappend(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail) Append to thetoStringanObjectarray.voidappend(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) Append to thetoStringanObjectvalue, printing the fulltoStringof theObjectpassed in.protected voidappendClassName(StringBuffer buffer, Object object) Append to thetoStringthe class name.protected voidappendContentEnd(StringBuffer buffer) Append to thetoStringthe content end.protected voidappendContentStart(StringBuffer buffer) Append to thetoStringthe content start.protected voidappendCyclicObject(StringBuffer buffer, String fieldName, Object value) Append to thetoStringanObjectvalue that has been detected to participate in a cycle.protected voidappendDetail(StringBuffer buffer, String fieldName, boolean value) Append to thetoStringabooleanvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, boolean[] array) Append to thetoStringthe detail of abooleanarray.protected voidappendDetail(StringBuffer buffer, String fieldName, byte value) Append to thetoStringabytevalue.protected voidappendDetail(StringBuffer buffer, String fieldName, byte[] array) Append to thetoStringthe detail of abytearray.protected voidappendDetail(StringBuffer buffer, String fieldName, char value) Append to thetoStringacharvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, char[] array) Append to thetoStringthe detail of achararray.protected voidappendDetail(StringBuffer buffer, String fieldName, double value) Append to thetoStringadoublevalue.protected voidappendDetail(StringBuffer buffer, String fieldName, double[] array) Append to thetoStringthe detail of adoublearray.protected voidappendDetail(StringBuffer buffer, String fieldName, float value) Append to thetoStringafloatvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, float[] array) Append to thetoStringthe detail of afloatarray.protected voidappendDetail(StringBuffer buffer, String fieldName, int value) Append to thetoStringanintvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, int[] array) Append to thetoStringthe detail of anintarray.protected voidappendDetail(StringBuffer buffer, String fieldName, long value) Append to thetoStringalongvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, long[] array) Append to thetoStringthe detail of alongarray.protected voidappendDetail(StringBuffer buffer, String fieldName, short value) Append to thetoStringashortvalue.protected voidappendDetail(StringBuffer buffer, String fieldName, short[] array) Append to thetoStringthe detail of ashortarray.protected voidappendDetail(StringBuffer buffer, String fieldName, Object value) Append to thetoStringanObjectvalue, printing the full detail of theObject.protected voidappendDetail(StringBuffer buffer, String fieldName, Object[] array) Append to thetoStringthe detail of anObjectarray.protected voidappendDetail(StringBuffer buffer, String fieldName, Collection coll) Append to thetoStringaCollection.protected voidappendDetail(StringBuffer buffer, String fieldName, Map map) Append to thetoStringaMap.voidappendEnd(StringBuffer buffer, Object object) Append to thetoStringthe end of data indicator.protected voidappendFieldEnd(StringBuffer buffer, String fieldName) Append to thetoStringthe field end.protected voidappendFieldSeparator(StringBuffer buffer) Append to thetoStringthe field separator.protected voidappendFieldStart(StringBuffer buffer, String fieldName) Append to thetoStringthe field start.protected voidappendIdentityHashCode(StringBuffer buffer, Object object) Append theSystem.identityHashCode(java.lang.Object).protected voidappendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail) Append to thetoStringanObject, correctly interpreting its type.protected voidappendNullText(StringBuffer buffer, String fieldName) Append to thetoStringan indicator fornull.voidappendStart(StringBuffer buffer, Object object) Append to thetoStringthe start of data indicator.protected voidappendSummary(StringBuffer buffer, String fieldName, boolean[] array) Append to thetoStringa summary of abooleanarray.protected voidappendSummary(StringBuffer buffer, String fieldName, byte[] array) Append to thetoStringa summary of abytearray.protected voidappendSummary(StringBuffer buffer, String fieldName, char[] array) Append to thetoStringa summary of achararray.protected voidappendSummary(StringBuffer buffer, String fieldName, double[] array) Append to thetoStringa summary of adoublearray.protected voidappendSummary(StringBuffer buffer, String fieldName, float[] array) Append to thetoStringa summary of afloatarray.protected voidappendSummary(StringBuffer buffer, String fieldName, int[] array) Append to thetoStringa summary of anintarray.protected voidappendSummary(StringBuffer buffer, String fieldName, long[] array) Append to thetoStringa summary of alongarray.protected voidappendSummary(StringBuffer buffer, String fieldName, short[] array) Append to thetoStringa summary of ashortarray.protected voidappendSummary(StringBuffer buffer, String fieldName, Object value) Append to thetoStringanObjectvalue, printing a summary of theObject.protected voidappendSummary(StringBuffer buffer, String fieldName, Object[] array) Append to thetoStringa summary of anObjectarray.protected voidappendSummarySize(StringBuffer buffer, String fieldName, int size) Append to thetoStringa size summary.voidappendSuper(StringBuffer buffer, String superToString) Append to thetoStringthe superclass toString.voidappendToString(StringBuffer buffer, String toString) Append to thetoStringanother toString.protected StringGets the array end text.protected StringGets the array separator text.protected StringGets the array start text.protected StringGets the content end text.protected StringGets the content start text.protected StringGets the field name value separator text.protected StringGets the field separator text.protected StringGets the text to output whennullfound.protected StringgetShortClassName(Class cls) Gets the short class name for a class.protected StringGets the end text to output when aCollection,Mapor array size is output.protected StringGets the start text to output when aCollection,Mapor array size is output.protected StringGets the end text to output when anObjectis output in summary mode.protected StringGets the start text to output when anObjectis output in summary mode.protected booleanGets whether to output array content detail.protected booleanGets whether to use full detail when the caller doesn't specify.protected booleanGets whether the field separator should be added at the end of each buffer.protected booleanGets 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.protected booleanDeprecated.protected booleanGets whether to use the class name.protected booleanGets whether to use the field names passed in.protected booleanGets whether to use the identity hash code.protected booleanGets whether to output short or long class names.protected voidreflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array) Append to thetoStringthe 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.protected voidsetArraySeparator(String arraySeparator) Sets the array separator text.protected voidsetArrayStart(String arrayStart) Sets the array start text.protected voidsetContentEnd(String contentEnd) Sets the content end text.protected voidsetContentStart(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(String fieldNameValueSeparator) Sets the field name value separator text.protected voidsetFieldSeparator(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(String nullText) Sets the text to output whennullfound.protected voidsetShortClassName(boolean shortClassName) Deprecated.UsesetUseShortClassName(boolean)Method will be removed in Commons Lang 3.0.protected voidsetSizeEndText(String sizeEndText) Sets the end text to output when aCollection,Mapor array size is output.protected voidsetSizeStartText(String sizeStartText) Sets the start text to output when aCollection,Mapor array size is output.protected voidsetSummaryObjectEndText(String summaryObjectEndText) Sets the end text to output when anObjectis output in summary mode.protected voidsetSummaryObjectStartText(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 Details
-
DEFAULT_STYLE
The default toString style. Using the Using thePersonexample fromToStringBuilder, the output would look like this:Person@182f0db[name=John Doe,age=33,smoker=false]
-
MULTI_LINE_STYLE
The multi line toString style. Using the Using thePersonexample fromToStringBuilder, the output would look like this:Person@182f0db[ name=John Doe age=33 smoker=false ]
-
NO_FIELD_NAMES_STYLE
The no field names toString style. Using the Using thePersonexample fromToStringBuilder, the output would look like this:Person@182f0db[John Doe,33,false]
-
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
The simple toString style. Using the Using thePersonexample fromToStringBuilder, the output would look like this:John Doe,33,false
-
-
Constructor Details
-
ToStringStyle
protected ToStringStyle()Constructor.
-
-
Method Details
-
appendSuper
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
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
Append to the
toStringthe start of data indicator.- Parameters:
buffer- theStringBufferto populateobject- theObjectto build atoStringfor
-
appendEnd
Append to the
toStringthe end of data indicator.- Parameters:
buffer- theStringBufferto populateobject- theObjectto build atoStringfor.
-
removeLastFieldSeparator
Remove the last field separator from the buffer.
- Parameters:
buffer- theStringBufferto populate- Since:
- 2.0
-
append
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
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
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
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
Append to the
toStringaCollection.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedcoll- theCollectionto add to thetoString, notnull
-
appendDetail
Append to the
toStringaMap.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedmap- theMapto add to thetoString, notnull
-
appendSummary
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
Append to the
toStringalongvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringalongvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringanintvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringanintvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringashortvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringashortvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringabytevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringabytevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringacharvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringacharvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringadoublevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringadoublevalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringafloatvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringafloatvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
Append to the
toStringabooleanvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoString
-
appendDetail
Append to the
toStringabooleanvalue.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString
-
append
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
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
-
reflectionAppendArrayDetail
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Append to the
toStringthe class name.- Parameters:
buffer- theStringBufferto populateobject- theObjectwhose name to output
-
appendIdentityHashCode
Append the
System.identityHashCode(java.lang.Object).- Parameters:
buffer- theStringBufferto populateobject- theObjectwhose id to output
-
appendContentStart
Append to the
toStringthe content start.- Parameters:
buffer- theStringBufferto populate
-
appendContentEnd
Append to the
toStringthe content end.- Parameters:
buffer- theStringBufferto populate
-
appendNullText
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
Append to the
toStringthe field separator.- Parameters:
buffer- theStringBufferto populate
-
appendFieldStart
Append to the
toStringthe field start.- Parameters:
buffer- theStringBufferto populatefieldName- the field name
-
appendFieldEnd
Append to the
toStringthe field end.- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appended
-
appendSummarySize
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
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
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
-
isShortClassName
protected boolean isShortClassName()Deprecated.UseisUseShortClassName()Method will be removed in Commons Lang 3.0.Gets whether to output short or long class names.
- Returns:
- the current shortClassName 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
-
setShortClassName
protected void setShortClassName(boolean shortClassName) Deprecated.UsesetUseShortClassName(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
-
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
Gets the array start text.
- Returns:
- the current array start text
-
setArrayStart
Sets the array start text.
nullis accepted, but will be converted to an empty String.- Parameters:
arrayStart- the new array start text
-
getArrayEnd
Gets the array end text.
- Returns:
- the current array end text
-
setArrayEnd
Sets the array end text.
nullis accepted, but will be converted to an empty String.- Parameters:
arrayEnd- the new array end text
-
getArraySeparator
Gets the array separator text.
- Returns:
- the current array separator text
-
setArraySeparator
Sets the array separator text.
nullis accepted, but will be converted to an empty String.- Parameters:
arraySeparator- the new array separator text
-
getContentStart
Gets the content start text.
- Returns:
- the current content start text
-
setContentStart
Sets the content start text.
nullis accepted, but will be converted to an empty String.- Parameters:
contentStart- the new content start text
-
getContentEnd
Gets the content end text.
- Returns:
- the current content end text
-
setContentEnd
Sets the content end text.
nullis accepted, but will be converted to an empty String.- Parameters:
contentEnd- the new content end text
-
getFieldNameValueSeparator
Gets the field name value separator text.
- Returns:
- the current field name value separator text
-
setFieldNameValueSeparator
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
Gets the field separator text.
- Returns:
- the current field separator text
-
setFieldSeparator
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
Gets the text to output when
nullfound.- Returns:
- the current text to output when null found
-
setNullText
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
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
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
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
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
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
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
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
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
-
isUseShortClassName()Method will be removed in Commons Lang 3.0.