Class ToStringStyle.JsonToStringStyle
- java.lang.Object
-
- org.apache.commons.lang3.builder.ToStringStyle
-
- org.apache.commons.lang3.builder.ToStringStyle.JsonToStringStyle
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- ToStringStyle
private static final class ToStringStyle.JsonToStringStyle extends ToStringStyle
ToStringStyle
that outputs with JSON format.This is an inner class rather than using
StandardToStringStyle
to ensure its immutability.- Since:
- 3.4
- See Also:
- json.org
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
FIELD_NAME_QUOTE
private static long
serialVersionUID
-
Fields inherited from class org.apache.commons.lang3.builder.ToStringStyle
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE
-
-
Constructor Summary
Constructors Constructor Description JsonToStringStyle()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array, java.lang.Boolean fullDetail)
Append to thetoString
aboolean
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)
Append to thetoString
abyte
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)
Append to thetoString
achar
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)
Append to thetoString
adouble
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)
Append to thetoString
afloat
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)
Append to thetoString
anint
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)
Append to thetoString
along
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)
Append to thetoString
ashort
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)
Append to thetoString
anObject
array.void
append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, java.lang.Boolean fullDetail)
Append to thetoString
anObject
value, printing the fulltoString
of theObject
passed in.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)
Append to thetoString
achar
value.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)
Append to thetoString
anObject
value, printing the full detail of theObject
.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Collection<?> coll)
Append to thetoString
aCollection
.protected void
appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)
Append to thetoString
aMap
.protected void
appendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)
Append to thetoString
the field start.private void
appendValueAsString(java.lang.StringBuffer buffer, java.lang.String value)
Appends the given String enclosed in double-quotes to the given StringBuffer.private boolean
isJsonArray(java.lang.String valueAsString)
private boolean
isJsonObject(java.lang.String valueAsString)
private java.lang.Object
readResolve()
EnsureSingleton
after serialization.-
Methods inherited from class org.apache.commons.lang3.builder.ToStringStyle
append, append, append, append, append, append, append, append, appendClassName, appendContentEnd, appendContentStart, appendCyclicObject, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendDetail, appendEnd, appendFieldEnd, appendFieldSeparator, appendIdentityHashCode, appendInternal, appendNullText, appendStart, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummary, appendSummarySize, appendSuper, appendToString, getArrayEnd, getArraySeparator, getArrayStart, getContentEnd, getContentStart, getFieldNameValueSeparator, getFieldSeparator, getNullText, getRegistry, getShortClassName, getSizeEndText, getSizeStartText, getSummaryObjectEndText, getSummaryObjectStartText, isArrayContentDetail, isDefaultFullDetail, isFieldSeparatorAtEnd, isFieldSeparatorAtStart, isFullDetail, isRegistered, isUseClassName, isUseFieldNames, isUseIdentityHashCode, isUseShortClassName, reflectionAppendArrayDetail, register, removeLastFieldSeparator, setArrayContentDetail, setArrayEnd, setArraySeparator, setArrayStart, setContentEnd, setContentStart, setDefaultFullDetail, setFieldNameValueSeparator, setFieldSeparator, setFieldSeparatorAtEnd, setFieldSeparatorAtStart, setNullText, setSizeEndText, setSizeStartText, setSummaryObjectEndText, setSummaryObjectStartText, setUseClassName, setUseFieldNames, setUseIdentityHashCode, setUseShortClassName, unregister
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
FIELD_NAME_QUOTE
private static final java.lang.String FIELD_NAME_QUOTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
anObject
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
along
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to thetoString
fullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
anint
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to thetoString
fullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
ashort
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to thetoString
fullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
abyte
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to thetoString
fullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
achar
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to thetoString
fullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
adouble
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
afloat
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
aboolean
array.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namearray
- the array to add to the toStringfullDetail
-true
for detail,false
for summary info,null
for style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, java.lang.Boolean fullDetail)
Description copied from class:ToStringStyle
Append to the
toString
anObject
value, printing the fulltoString
of theObject
passed in.- Overrides:
append
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field namevalue
- the value to add to thetoString
fullDetail
-true
for detail,false
for summary info,null
for style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)
Description copied from class:ToStringStyle
Append to the
toString
achar
value.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to thetoString
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)
Description copied from class:ToStringStyle
Append to the
toString
anObject
value, printing the full detail of theObject
.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to 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)
Description copied from class:ToStringStyle
Append to the
toString
aCollection
.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedcoll
- theCollection
to add to thetoString
, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)
Description copied from class:ToStringStyle
Append to the
toString
aMap
.- Overrides:
appendDetail
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name, typically not used as already appendedmap
- theMap
to add to thetoString
, notnull
-
isJsonArray
private boolean isJsonArray(java.lang.String valueAsString)
-
isJsonObject
private boolean isJsonObject(java.lang.String valueAsString)
-
appendValueAsString
private void appendValueAsString(java.lang.StringBuffer buffer, java.lang.String value)
Appends the given String enclosed in double-quotes to the given StringBuffer.- Parameters:
buffer
- the StringBuffer to append the value to.value
- the value to append.
-
appendFieldStart
protected void appendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)
Description copied from class:ToStringStyle
Append to the
toString
the field start.- Overrides:
appendFieldStart
in classToStringStyle
- Parameters:
buffer
- theStringBuffer
to populatefieldName
- the field name
-
readResolve
private java.lang.Object readResolve()
Ensure
Singleton
after serialization.- Returns:
- the singleton
-
-