Class ToStringStyle.JsonToStringStyle
- All Implemented Interfaces:
Serializable
- Enclosing class:
- 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:
-
Field Summary
FieldsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail) Append to thetoString
aboolean
array.void
append
(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail) Append to thetoString
abyte
array.void
append
(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail) Append to thetoString
achar
array.void
append
(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail) Append to thetoString
adouble
array.void
append
(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail) Append to thetoString
afloat
array.void
append
(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail) Append to thetoString
anint
array.void
append
(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail) Append to thetoString
along
array.void
append
(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail) Append to thetoString
ashort
array.void
append
(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail) Append to thetoString
anObject
array.void
append
(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) Append to thetoString
anObject
value, printing the fulltoString
of theObject
passed in.protected void
appendDetail
(StringBuffer buffer, String fieldName, char value) Append to thetoString
achar
value.protected void
appendDetail
(StringBuffer buffer, String fieldName, Object value) Append to thetoString
anObject
value, printing the full detail of theObject
.protected void
appendDetail
(StringBuffer buffer, String fieldName, Collection<?> coll) Append to thetoString
aCollection
.protected void
appendDetail
(StringBuffer buffer, String fieldName, Map<?, ?> map) Append to thetoString
aMap
.protected void
appendFieldStart
(StringBuffer buffer, String fieldName) Append to thetoString
the field start.private void
appendValueAsString
(StringBuffer buffer, String value) Appends the given String enclosed in double-quotes to the given StringBuffer.private boolean
isJsonArray
(String valueAsString) private boolean
isJsonObject
(String valueAsString) private Object
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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
FIELD_NAME_QUOTE
- See Also:
-
-
Constructor Details
-
JsonToStringStyle
JsonToStringStyle()Constructor.
Use the static constant rather than instantiating.
-
-
Method Details
-
append
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-
isJsonObject
-
appendValueAsString
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
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
Ensure
Singleton
after serialization.- Returns:
- the singleton
-