public abstract class ToStringStyle extends Object implements Serializable
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); } }
Modifier and Type | Field and Description |
---|---|
static ToStringStyle |
DEFAULT_STYLE
The default toString style.
|
static ToStringStyle |
JSON_STYLE
The JSON toString style.
|
static ToStringStyle |
MULTI_LINE_STYLE
The multi line toString style.
|
static ToStringStyle |
NO_CLASS_NAME_STYLE
The no class name toString style.
|
static ToStringStyle |
NO_FIELD_NAMES_STYLE
The no field names toString style.
|
static ToStringStyle |
SHORT_PREFIX_STYLE
The short prefix toString style.
|
static ToStringStyle |
SIMPLE_STYLE
The simple toString style.
|
Modifier | Constructor and Description |
---|---|
protected |
ToStringStyle()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
append(StringBuffer buffer,
String fieldName,
boolean value)
Append to the
toString a boolean
value. |
void |
append(StringBuffer buffer,
String fieldName,
boolean[] array,
Boolean fullDetail)
Append to the
toString a boolean
array. |
void |
append(StringBuffer buffer,
String fieldName,
byte value)
Append to the
toString a byte
value. |
void |
append(StringBuffer buffer,
String fieldName,
byte[] array,
Boolean fullDetail)
Append to the
toString a byte
array. |
void |
append(StringBuffer buffer,
String fieldName,
char value)
Append to the
toString a char
value. |
void |
append(StringBuffer buffer,
String fieldName,
char[] array,
Boolean fullDetail)
Append to the
toString a char
array. |
void |
append(StringBuffer buffer,
String fieldName,
double value)
Append to the
toString a double
value. |
void |
append(StringBuffer buffer,
String fieldName,
double[] array,
Boolean fullDetail)
Append to the
toString a double
array. |
void |
append(StringBuffer buffer,
String fieldName,
float value)
Append to the
toString a float
value. |
void |
append(StringBuffer buffer,
String fieldName,
float[] array,
Boolean fullDetail)
Append to the
toString a float
array. |
void |
append(StringBuffer buffer,
String fieldName,
int value)
Append to the
toString an int
value. |
void |
append(StringBuffer buffer,
String fieldName,
int[] array,
Boolean fullDetail)
Append to the
toString an int
array. |
void |
append(StringBuffer buffer,
String fieldName,
long value)
Append to the
toString a long
value. |
void |
append(StringBuffer buffer,
String fieldName,
long[] array,
Boolean fullDetail)
Append to the
toString a long
array. |
void |
append(StringBuffer buffer,
String fieldName,
Object[] array,
Boolean fullDetail)
Append to the
toString an Object
array. |
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. |
void |
append(StringBuffer buffer,
String fieldName,
short value)
Append to the
toString a short
value. |
void |
append(StringBuffer buffer,
String fieldName,
short[] array,
Boolean fullDetail)
Append to the
toString a short
array. |
protected void |
appendClassName(StringBuffer buffer,
Object object)
Append to the
toString the class name. |
protected void |
appendContentEnd(StringBuffer buffer)
Append to the
toString the content end. |
protected void |
appendContentStart(StringBuffer buffer)
Append to the
toString the content start. |
protected void |
appendCyclicObject(StringBuffer buffer,
String fieldName,
Object value)
Append to the
toString an Object
value that has been detected to participate in a cycle. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
boolean value)
Append to the
toString a boolean
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
boolean[] array)
Append to the
toString the detail of a
boolean array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
byte value)
Append to the
toString a byte
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
byte[] array)
Append to the
toString the detail of a
byte array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
char value)
Append to the
toString a char
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
char[] array)
Append to the
toString the detail of a
char array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Collection<?> coll)
Append to the
toString a Collection . |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
double value)
Append to the
toString a double
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
double[] array)
Append to the
toString the detail of a
double array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
float value)
Append to the
toString a float
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
float[] array)
Append to the
toString the detail of a
float array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
int value)
Append to the
toString an int
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
int[] array)
Append to the
toString the detail of an
int array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
long value)
Append to the
toString a long
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
long[] array)
Append to the
toString the detail of a
long array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Map<?,?> map)
Append to the
toString a Map . |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Object value)
Append to the
toString an Object
value, printing the full detail of the Object . |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
Object[] array)
Append to the
toString the detail of an
Object array. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
short value)
Append to the
toString a short
value. |
protected void |
appendDetail(StringBuffer buffer,
String fieldName,
short[] array)
Append to the
toString the detail of a
short array. |
void |
appendEnd(StringBuffer buffer,
Object object)
Append to the
toString the end of data indicator. |
protected void |
appendFieldEnd(StringBuffer buffer,
String fieldName)
Append to the
toString the field end. |
protected void |
appendFieldSeparator(StringBuffer buffer)
Append to the
toString the field separator. |
protected void |
appendFieldStart(StringBuffer buffer,
String fieldName)
Append to the
toString the field start. |
protected void |
appendIdentityHashCode(StringBuffer buffer,
Object object)
Append the
System.identityHashCode(java.lang.Object) . |
protected void |
appendInternal(StringBuffer buffer,
String fieldName,
Object value,
boolean detail)
Append to the
toString an Object ,
correctly interpreting its type. |
protected void |
appendNullText(StringBuffer buffer,
String fieldName)
Append to the
toString an indicator for null . |
void |
appendStart(StringBuffer buffer,
Object object)
Append to the
toString the start of data indicator. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
boolean[] array)
Append to the
toString a summary of a
boolean array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
byte[] array)
Append to the
toString a summary of a
byte array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
char[] array)
Append to the
toString a summary of a
char array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
double[] array)
Append to the
toString a summary of a
double array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
float[] array)
Append to the
toString a summary of a
float array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
int[] array)
Append to the
toString a summary of an
int array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
long[] array)
Append to the
toString a summary of a
long array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
Object value)
Append to the
toString an Object
value, printing a summary of the Object . |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
Object[] array)
Append to the
toString a summary of an
Object array. |
protected void |
appendSummary(StringBuffer buffer,
String fieldName,
short[] array)
Append to the
toString a summary of a
short array. |
protected void |
appendSummarySize(StringBuffer buffer,
String fieldName,
int size)
Append to the
toString a size summary. |
void |
appendSuper(StringBuffer buffer,
String superToString)
Append to the
toString the superclass toString. |
void |
appendToString(StringBuffer buffer,
String toString)
Append to the
toString another toString. |
protected String |
getArrayEnd()
Gets the array end text.
|
protected String |
getArraySeparator()
Gets the array separator text.
|
protected String |
getArrayStart()
Gets the array start text.
|
protected String |
getContentEnd()
Gets the content end text.
|
protected String |
getContentStart()
Gets the content start text.
|
protected String |
getFieldNameValueSeparator()
Gets the field name value separator text.
|
protected String |
getFieldSeparator()
Gets the field separator text.
|
protected String |
getNullText()
Gets the text to output when
null found. |
protected String |
getShortClassName(Class<?> cls)
Gets the short class name for a class.
|
protected String |
getSizeEndText()
Gets the end text to output when a
Collection ,
Map or array size is output. |
protected String |
getSizeStartText()
Gets the start text to output when a
Collection ,
Map or array size is output. |
protected String |
getSummaryObjectEndText()
Gets the end text to output when an
Object is
output in summary mode. |
protected String |
getSummaryObjectStartText()
Gets the start text to output when an
Object is
output in summary mode. |
protected boolean |
isArrayContentDetail()
Gets whether to output array content detail.
|
protected boolean |
isDefaultFullDetail()
Gets whether to use full detail when the caller doesn't
specify.
|
protected boolean |
isFieldSeparatorAtEnd()
Gets whether the field separator should be added at the end
of each buffer.
|
protected boolean |
isFieldSeparatorAtStart()
Gets whether the field separator should be added at the start
of each buffer.
|
protected boolean |
isFullDetail(Boolean fullDetailRequest)
Is this field to be output in full detail.
|
protected boolean |
isUseClassName()
Gets whether to use the class name.
|
protected boolean |
isUseFieldNames()
Gets whether to use the field names passed in.
|
protected boolean |
isUseIdentityHashCode()
Gets whether to use the identity hash code.
|
protected boolean |
isUseShortClassName()
Gets whether to output short or long class names.
|
protected void |
reflectionAppendArrayDetail(StringBuffer buffer,
String fieldName,
Object array)
Append to the
toString the detail of an array type. |
protected void |
removeLastFieldSeparator(StringBuffer buffer)
Remove the last field separator from the buffer.
|
protected void |
setArrayContentDetail(boolean arrayContentDetail)
Sets whether to output array content detail.
|
protected void |
setArrayEnd(String arrayEnd)
Sets the array end text.
|
protected void |
setArraySeparator(String arraySeparator)
Sets the array separator text.
|
protected void |
setArrayStart(String arrayStart)
Sets the array start text.
|
protected void |
setContentEnd(String contentEnd)
Sets the content end text.
|
protected void |
setContentStart(String contentStart)
Sets the content start text.
|
protected void |
setDefaultFullDetail(boolean defaultFullDetail)
Sets whether to use full detail when the caller doesn't
specify.
|
protected void |
setFieldNameValueSeparator(String fieldNameValueSeparator)
Sets the field name value separator text.
|
protected void |
setFieldSeparator(String fieldSeparator)
Sets the field separator text.
|
protected void |
setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd)
Sets whether the field separator should be added at the end
of each buffer.
|
protected void |
setFieldSeparatorAtStart(boolean fieldSeparatorAtStart)
Sets whether the field separator should be added at the start
of each buffer.
|
protected void |
setNullText(String nullText)
Sets the text to output when
null found. |
protected void |
setSizeEndText(String sizeEndText)
Sets the end text to output when a
Collection ,
Map or array size is output. |
protected void |
setSizeStartText(String sizeStartText)
Sets the start text to output when a
Collection ,
Map or array size is output. |
protected void |
setSummaryObjectEndText(String summaryObjectEndText)
Sets the end text to output when an
Object is
output in summary mode. |
protected void |
setSummaryObjectStartText(String summaryObjectStartText)
Sets the start text to output when an
Object is
output in summary mode. |
protected void |
setUseClassName(boolean useClassName)
Sets whether to use the class name.
|
protected void |
setUseFieldNames(boolean useFieldNames)
Sets whether to use the field names passed in.
|
protected void |
setUseIdentityHashCode(boolean useIdentityHashCode)
Sets whether to use the identity hash code.
|
protected void |
setUseShortClassName(boolean useShortClassName)
Sets whether to output short or long class names.
|
public static final ToStringStyle DEFAULT_STYLE
Person
example from ToStringBuilder
, the output would look like this:
Person@182f0db[name=John Doe,age=33,smoker=false]
public static final ToStringStyle MULTI_LINE_STYLE
Person
example from ToStringBuilder
, the output would look like this:
Person@182f0db[ name=John Doe age=33 smoker=false ]
public static final ToStringStyle NO_FIELD_NAMES_STYLE
Person
example from ToStringBuilder
, the output
would look like this:
Person@182f0db[John Doe,33,false]
public static final ToStringStyle SHORT_PREFIX_STYLE
Person
example
from ToStringBuilder
, the output would look like this:
Person[name=John Doe,age=33,smoker=false]
public static final ToStringStyle SIMPLE_STYLE
Person
example from ToStringBuilder
, the output would look like this:
John Doe,33,false
public static final ToStringStyle NO_CLASS_NAME_STYLE
Person
example from ToStringBuilder
, the output would look like this:
[name=John Doe,age=33,smoker=false]
public static final ToStringStyle JSON_STYLE
Person
example from
ToStringBuilder
, the output would look like this:
{"name": "John Doe", "age": 33, "smoker": true}Note: Since field names are mandatory in JSON, this ToStringStyle will throw an
UnsupportedOperationException
if no
field name is passed in while appending. Furthermore This ToStringStyle
will only generate valid JSON if referenced objects also produce JSON
when calling toString()
on them.public void appendSuper(StringBuffer buffer, String superToString)
Append to the toString
the superclass toString.
NOTE: It assumes that the toString has been created from the same ToStringStyle.
A null
superToString
is ignored.
buffer
- the StringBuffer
to populatesuperToString
- the super.toString()
public void appendToString(StringBuffer buffer, String toString)
Append to the toString
another toString.
NOTE: It assumes that the toString has been created from the same ToStringStyle.
A null
toString
is ignored.
buffer
- the StringBuffer
to populatetoString
- the additional toString
public void appendStart(StringBuffer buffer, Object object)
Append to the toString
the start of data indicator.
buffer
- the StringBuffer
to populateobject
- the Object
to build a toString
forpublic void appendEnd(StringBuffer buffer, Object object)
Append to the toString
the end of data indicator.
buffer
- the StringBuffer
to populateobject
- the Object
to build a
toString
for.protected void removeLastFieldSeparator(StringBuffer buffer)
Remove the last field separator from the buffer.
buffer
- the StringBuffer
to populatepublic 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.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
fullDetail
- true
for detail, false
for summary info, null
for style decidesprotected 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.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
,
not null
detail
- output detail or notprotected void appendCyclicObject(StringBuffer buffer, String fieldName, Object value)
Append to the toString
an Object
value that has been detected to participate in a cycle. This
implementation will print the standard string value of the value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
,
not null
protected void appendDetail(StringBuffer buffer, String fieldName, Object value)
Append to the toString
an Object
value, printing the full detail of the Object
.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
,
not null
protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll)
Append to the toString
a Collection
.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedcoll
- the Collection
to add to the
toString
, not null
protected void appendDetail(StringBuffer buffer, String fieldName, Map<?,?> map)
Append to the toString
a Map
.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedmap
- the Map
to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, Object value)
Append to the toString
an Object
value, printing a summary of the Object
.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, long value)
Append to the toString
a long
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, long value)
Append to the toString
a long
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, int value)
Append to the toString
an int
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, int value)
Append to the toString
an int
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, short value)
Append to the toString
a short
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, short value)
Append to the toString
a short
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, byte value)
Append to the toString
a byte
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, byte value)
Append to the toString
a byte
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, char value)
Append to the toString
a char
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, char value)
Append to the toString
a char
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, double value)
Append to the toString
a double
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, double value)
Append to the toString
a double
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, float value)
Append to the toString
a float
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, float value)
Append to the toString
a float
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, boolean value)
Append to the toString
a boolean
value.
buffer
- the StringBuffer
to populatefieldName
- the field namevalue
- the value to add to the toString
protected void appendDetail(StringBuffer buffer, String fieldName, boolean value)
Append to the toString
a boolean
value.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
public void append(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail)
Append to the toString
an Object
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, Object[] array)
Append to the toString
the detail of an
Object
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array)
Append to the toString
the detail of an array type.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, Object[] array)
Append to the toString
a summary of an
Object
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail)
Append to the toString
a long
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toString
fullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, long[] array)
Append to the toString
the detail of a
long
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, long[] array)
Append to the toString
a summary of a
long
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail)
Append to the toString
an int
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toString
fullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, int[] array)
Append to the toString
the detail of an
int
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, int[] array)
Append to the toString
a summary of an
int
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail)
Append to the toString
a short
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toString
fullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, short[] array)
Append to the toString
the detail of a
short
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, short[] array)
Append to the toString
a summary of a
short
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail)
Append to the toString
a byte
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toString
fullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, byte[] array)
Append to the toString
the detail of a
byte
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, byte[] array)
Append to the toString
a summary of a
byte
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail)
Append to the toString
a char
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toString
fullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, char[] array)
Append to the toString
the detail of a
char
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, char[] array)
Append to the toString
a summary of a
char
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail)
Append to the toString
a double
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, double[] array)
Append to the toString
the detail of a
double
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, double[] array)
Append to the toString
a summary of a
double
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail)
Append to the toString
a float
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, float[] array)
Append to the toString
the detail of a
float
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, float[] array)
Append to the toString
a summary of a
float
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
public void append(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail)
Append to the toString
a boolean
array.
buffer
- the StringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
- true
for detail, false
for summary info, null
for style decidesprotected void appendDetail(StringBuffer buffer, String fieldName, boolean[] array)
Append to the toString
the detail of a
boolean
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendSummary(StringBuffer buffer, String fieldName, boolean[] array)
Append to the toString
a summary of a
boolean
array.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedarray
- the array to add to the toString
,
not null
protected void appendClassName(StringBuffer buffer, Object object)
Append to the toString
the class name.
buffer
- the StringBuffer
to populateobject
- the Object
whose name to outputprotected void appendIdentityHashCode(StringBuffer buffer, Object object)
Append the System.identityHashCode(java.lang.Object)
.
buffer
- the StringBuffer
to populateobject
- the Object
whose id to outputprotected void appendContentStart(StringBuffer buffer)
Append to the toString
the content start.
buffer
- the StringBuffer
to populateprotected void appendContentEnd(StringBuffer buffer)
Append to the toString
the content end.
buffer
- the StringBuffer
to populateprotected void appendNullText(StringBuffer buffer, String fieldName)
Append to the toString
an indicator for null
.
The default indicator is '<null>'
.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedprotected void appendFieldSeparator(StringBuffer buffer)
Append to the toString
the field separator.
buffer
- the StringBuffer
to populateprotected void appendFieldStart(StringBuffer buffer, String fieldName)
Append to the toString
the field start.
buffer
- the StringBuffer
to populatefieldName
- the field nameprotected void appendFieldEnd(StringBuffer buffer, String fieldName)
Append to the toString
the field end.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedprotected 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>'
.
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedsize
- the size to appendprotected 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.
fullDetailRequest
- the detail level requestedprotected String getShortClassName(Class<?> cls)
Gets the short class name for a class.
The short class name is the classname excluding the package name.
cls
- the Class
to get the short name ofprotected boolean isUseClassName()
Gets whether to use the class name.
protected void setUseClassName(boolean useClassName)
Sets whether to use the class name.
useClassName
- the new useClassName flagprotected boolean isUseShortClassName()
Gets whether to output short or long class names.
protected void setUseShortClassName(boolean useShortClassName)
Sets whether to output short or long class names.
useShortClassName
- the new useShortClassName flagprotected boolean isUseIdentityHashCode()
Gets whether to use the identity hash code.
protected void setUseIdentityHashCode(boolean useIdentityHashCode)
Sets whether to use the identity hash code.
useIdentityHashCode
- the new useIdentityHashCode flagprotected boolean isUseFieldNames()
Gets whether to use the field names passed in.
protected void setUseFieldNames(boolean useFieldNames)
Sets whether to use the field names passed in.
useFieldNames
- the new useFieldNames flagprotected boolean isDefaultFullDetail()
Gets whether to use full detail when the caller doesn't specify.
protected void setDefaultFullDetail(boolean defaultFullDetail)
Sets whether to use full detail when the caller doesn't specify.
defaultFullDetail
- the new defaultFullDetail flagprotected boolean isArrayContentDetail()
Gets whether to output array content detail.
protected void setArrayContentDetail(boolean arrayContentDetail)
Sets whether to output array content detail.
arrayContentDetail
- the new arrayContentDetail flagprotected String getArrayStart()
Gets the array start text.
protected void setArrayStart(String arrayStart)
Sets the array start text.
null
is accepted, but will be converted to
an empty String.
arrayStart
- the new array start textprotected String getArrayEnd()
Gets the array end text.
protected void setArrayEnd(String arrayEnd)
Sets the array end text.
null
is accepted, but will be converted to
an empty String.
arrayEnd
- the new array end textprotected String getArraySeparator()
Gets the array separator text.
protected void setArraySeparator(String arraySeparator)
Sets the array separator text.
null
is accepted, but will be converted to
an empty String.
arraySeparator
- the new array separator textprotected String getContentStart()
Gets the content start text.
protected void setContentStart(String contentStart)
Sets the content start text.
null
is accepted, but will be converted to
an empty String.
contentStart
- the new content start textprotected String getContentEnd()
Gets the content end text.
protected void setContentEnd(String contentEnd)
Sets the content end text.
null
is accepted, but will be converted to
an empty String.
contentEnd
- the new content end textprotected String getFieldNameValueSeparator()
Gets the field name value separator text.
protected void setFieldNameValueSeparator(String fieldNameValueSeparator)
Sets the field name value separator text.
null
is accepted, but will be converted to
an empty String.
fieldNameValueSeparator
- the new field name value separator textprotected String getFieldSeparator()
Gets the field separator text.
protected void setFieldSeparator(String fieldSeparator)
Sets the field separator text.
null
is accepted, but will be converted to
an empty String.
fieldSeparator
- the new field separator textprotected boolean isFieldSeparatorAtStart()
Gets whether the field separator should be added at the start of each buffer.
protected void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart)
Sets whether the field separator should be added at the start of each buffer.
fieldSeparatorAtStart
- the fieldSeparatorAtStart flagprotected boolean isFieldSeparatorAtEnd()
Gets whether the field separator should be added at the end of each buffer.
protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd)
Sets whether the field separator should be added at the end of each buffer.
fieldSeparatorAtEnd
- the fieldSeparatorAtEnd flagprotected String getNullText()
Gets the text to output when null
found.
protected void setNullText(String nullText)
Sets the text to output when null
found.
null
is accepted, but will be converted to
an empty String.
nullText
- the new text to output when null foundprotected String getSizeStartText()
Gets the start text to output when a Collection
,
Map
or array size is output.
This is output before the size value.
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.
sizeStartText
- the new start of size textprotected String getSizeEndText()
Gets the end text to output when a Collection
,
Map
or array size is output.
This is output after the size value.
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.
sizeEndText
- the new end of size textprotected String getSummaryObjectStartText()
Gets the start text to output when an Object
is
output in summary mode.
This is output before the size value.
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.
summaryObjectStartText
- the new start of summary textprotected String getSummaryObjectEndText()
Gets the end text to output when an Object
is
output in summary mode.
This is output after the size value.
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.
summaryObjectEndText
- the new end of summary textCopyright © 2007-2020 Whitestein Technologies. All Rights Reserved.