Package org.apache.commons.lang3.builder
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()Constructs a new instance.
-
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)Appends to thetoStringabooleanarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, byte[] array, java.lang.Boolean fullDetail)Appends to thetoStringabytearray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, char[] array, java.lang.Boolean fullDetail)Appends to thetoStringachararray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, double[] array, java.lang.Boolean fullDetail)Appends to thetoStringadoublearray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, float[] array, java.lang.Boolean fullDetail)Appends to thetoStringafloatarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, int[] array, java.lang.Boolean fullDetail)Appends to thetoStringanintarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, long[] array, java.lang.Boolean fullDetail)Appends to thetoStringalongarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, short[] array, java.lang.Boolean fullDetail)Appends to thetoStringashortarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)Appends to thetoStringanObjectarray.voidappend(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value, java.lang.Boolean fullDetail)Appends to thetoStringanObjectvalue, printing the fulltoStringof theObjectpassed in.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, char value)Appends to thetoStringacharvalue.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Appends to thetoStringanObjectvalue, printing the full detail of theObject.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Collection<?> coll)Appends to thetoStringaCollection.protected voidappendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.util.Map<?,?> map)Appends to thetoStringaMap.protected voidappendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)Appends 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 voidcheckAppendInput(java.lang.String fieldName, java.lang.Boolean fullDetail)private voidcheckFieldName(java.lang.String fieldName)private voidcheckIsFullDetail(java.lang.Boolean fullDetail)private booleanisJsonArray(java.lang.String valueAsString)private booleanisJsonObject(java.lang.String valueAsString)private java.lang.ObjectreadResolve()Ensure Singleton 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, boolean[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringabooleanarray.- 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, byte[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringabytearray.- 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:ToStringStyleAppends to thetoStringachararray.- 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:ToStringStyleAppends to thetoStringadoublearray.- 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:ToStringStyleAppends to thetoStringafloatarray.- 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, int[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringanintarray.- 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, long[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringalongarray.- 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, java.lang.Object value, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringanObjectvalue, 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
-
append
public void append(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringanObjectarray.- 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, short[] array, java.lang.Boolean fullDetail)Description copied from class:ToStringStyleAppends to thetoStringashortarray.- Overrides:
appendin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field namearray- the array 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:ToStringStyleAppends to thetoStringacharvalue.- 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.util.Collection<?> coll)Description copied from class:ToStringStyleAppends to thetoStringaCollection.- 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:ToStringStyleAppends to thetoStringaMap.- Overrides:
appendDetailin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field name, typically not used as already appendedmap- theMapto add to thetoString, notnull
-
appendDetail
protected void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)Description copied from class:ToStringStyleAppends to thetoStringanObjectvalue, 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
-
appendFieldStart
protected void appendFieldStart(java.lang.StringBuffer buffer, java.lang.String fieldName)Description copied from class:ToStringStyleAppends to thetoStringthe field start.- Overrides:
appendFieldStartin classToStringStyle- Parameters:
buffer- theStringBufferto populatefieldName- the field name
-
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.
-
checkAppendInput
private void checkAppendInput(java.lang.String fieldName, java.lang.Boolean fullDetail)
-
checkFieldName
private void checkFieldName(java.lang.String fieldName)
-
checkIsFullDetail
private void checkIsFullDetail(java.lang.Boolean fullDetail)
-
isJsonArray
private boolean isJsonArray(java.lang.String valueAsString)
-
isJsonObject
private boolean isJsonObject(java.lang.String valueAsString)
-
readResolve
private java.lang.Object readResolve()
Ensure Singleton after serialization.- Returns:
- the singleton
-
-