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
ToStringStylethat outputs with JSON format.This is an inner class rather than using
StandardToStringStyleto ensure its immutability.- Since:
- 3.4
- See Also:
- json.org
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringFIELD_NAME_QUOTEprivate static longserialVersionUID-
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 voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array, java.lang.Boolean fullDetail)Append to thetoStringabooleanarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)Append to thetoStringabytearray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)Append to thetoStringachararray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)Append to thetoStringadoublearray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)Append to thetoStringafloatarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)Append to thetoStringanintarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)Append to thetoStringalongarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)Append to thetoStringashortarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)Append to thetoStringanObjectarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, java.lang.Boolean fullDetail)Append to thetoStringanObjectvalue, printing the fulltoStringof theObjectpassed in.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Append to thetoStringacharvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Append to thetoStringanObjectvalue, printing the full detail of theObject.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Collection<?> coll)Append to thetoStringaCollection.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)Append to thetoStringaMap.protected voidappendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)Append to thetoStringthe field start.private voidappendValueAsString(java.lang.StringBuffer buffer, java.lang.String value)Appends the given String enclosed in double-quotes to the given StringBuffer.private booleanisJsonArray(java.lang.String valueAsString)private booleanisJsonObject(java.lang.String valueAsString)private java.lang.ObjectreadResolve()EnsureSingletonafter 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:ToStringStyleAppend to the
toStringanObjectarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringalongarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringanintarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringashortarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringabytearray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringachararray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringadoublearray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringafloatarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, boolean[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppend to the
toStringabooleanarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array to add to the toStringfullDetail-truefor detail,falsefor summary info,nullfor 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:ToStringStyleAppend to the
toStringanObjectvalue, printing the fulltoStringof theObjectpassed in.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namevalue- the value to add to thetoStringfullDetail-truefor detail,falsefor summary info,nullfor style decides
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Description copied from class:ToStringStyleAppend to the
toStringacharvalue.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- theStringBufferto 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:ToStringStyleAppend to the
toStringanObjectvalue, printing the full detail of theObject.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedvalue- the value to add to thetoString, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Collection<?> coll)Description copied from class:ToStringStyleAppend to the
toStringaCollection.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedcoll- theCollectionto add to thetoString, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)Description copied from class:ToStringStyleAppend to the
toStringaMap.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedmap- theMapto 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:ToStringStyleAppend to the
toStringthe field start.- Overrides:
appendFieldStartin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field name
-
readResolve
private java.lang.Object readResolve()
Ensure
Singletonafter serialization.- Returns:
- the singleton
-
-