001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.lang3.builder;
018
019import java.lang.reflect.Array;
020import java.util.Collection;
021import java.util.Map;
022
023/**
024 * Works with {@link ToStringBuilder} to create a {@code toString}.
025 *
026 * <p>This class is intended to be used as a singleton.
027 * There is no need to instantiate a new style each time.
028 * Simply instantiate the class once, customize the values as required, and
029 * store the result in a public static final variable for the rest of the
030 * program to access.</p>
031 *
032 * @since 1.0
033 */
034public class StandardToStringStyle extends ToStringStyle {
035
036    /**
037     * Required for serialization support.
038     *
039     * @see java.io.Serializable
040     */
041    private static final long serialVersionUID = 1L;
042
043    /**
044     * Constructor.
045     */
046    public StandardToStringStyle() {
047    }
048
049    /**
050     * Gets the array end text.
051     *
052     * @return the current array end text
053     */
054    @Override
055    public String getArrayEnd() {
056        return super.getArrayEnd();
057    }
058
059    /**
060     * Gets the array separator text.
061     *
062     * @return the current array separator text
063     */
064    @Override
065    public String getArraySeparator() {
066        return super.getArraySeparator();
067    }
068
069    /**
070     * Gets the array start text.
071     *
072     * @return the current array start text
073     */
074    @Override
075    public String getArrayStart() {
076        return super.getArrayStart();
077    }
078
079    /**
080     * Gets the content end text.
081     *
082     * @return the current content end text
083     */
084    @Override
085    public String getContentEnd() {
086        return super.getContentEnd();
087    }
088
089    /**
090     * Gets the content start text.
091     *
092     * @return the current content start text
093     */
094    @Override
095    public String getContentStart() {
096        return super.getContentStart();
097    }
098
099    /**
100     * Gets the field name value separator text.
101     *
102     * @return the current field name value separator text
103     */
104    @Override
105    public String getFieldNameValueSeparator() {
106        return super.getFieldNameValueSeparator();
107    }
108
109    /**
110     * Gets the field separator text.
111     *
112     * @return the current field separator text
113     */
114    @Override
115    public String getFieldSeparator() {
116        return super.getFieldSeparator();
117    }
118
119    /**
120     * Gets the text to output when {@code null} found.
121     *
122     * @return the current text to output when {@code null} found
123     */
124    @Override
125    public String getNullText() {
126        return super.getNullText();
127    }
128
129    /**
130     * Gets the end text to output when a {@link Collection},
131     * {@link Map} or {@link Array} size is output.
132     *
133     * <p>This is output after the size value.</p>
134     *
135     * @return the current end of size text
136     */
137    @Override
138    public String getSizeEndText() {
139        return super.getSizeEndText();
140    }
141
142    /**
143     * Gets the text to output when a {@link Collection},
144     * {@link Map} or {@link Array} size is output.
145     *
146     * <p>This is output before the size value.</p>
147     *
148     * @return the current start of size text
149     */
150    @Override
151    public String getSizeStartText() {
152        return super.getSizeStartText();
153    }
154
155    /**
156     * Gets the end text to output when an {@link Object} is
157     * output in summary mode.
158     *
159     * <p>This is output after the size value.</p>
160     *
161     * @return the current end of summary text
162     */
163    @Override
164    public String getSummaryObjectEndText() {
165        return super.getSummaryObjectEndText();
166    }
167
168    /**
169     * Gets the start text to output when an {@link Object} is
170     * output in summary mode.
171     *
172     * <p>This is output before the size value.</p>
173     *
174     * @return the current start of summary text
175     */
176    @Override
177    public String getSummaryObjectStartText() {
178        return super.getSummaryObjectStartText();
179    }
180
181    /**
182     * Gets whether to output array content detail.
183     *
184     * @return the current array content detail setting
185     */
186    @Override
187    public boolean isArrayContentDetail() {
188        return super.isArrayContentDetail();
189    }
190
191    /**
192     * Gets whether to use full detail when the caller doesn't
193     * specify.
194     *
195     * @return the current defaultFullDetail flag
196     */
197    @Override
198    public boolean isDefaultFullDetail() {
199        return super.isDefaultFullDetail();
200    }
201
202    /**
203     * Gets whether the field separator should be added at the end
204     * of each buffer.
205     *
206     * @return fieldSeparatorAtEnd flag
207     * @since 2.0
208     */
209    @Override
210    public boolean isFieldSeparatorAtEnd() {
211        return super.isFieldSeparatorAtEnd();
212    }
213
214    /**
215     * Gets whether the field separator should be added at the start
216     * of each buffer.
217     *
218     * @return the fieldSeparatorAtStart flag
219     * @since 2.0
220     */
221    @Override
222    public boolean isFieldSeparatorAtStart() {
223        return super.isFieldSeparatorAtStart();
224    }
225
226    /**
227     * Gets whether to use the class name.
228     *
229     * @return the current useClassName flag
230     */
231    @Override
232    public boolean isUseClassName() {
233        return super.isUseClassName();
234    }
235
236    /**
237     * Gets whether to use the field names passed in.
238     *
239     * @return the current useFieldNames flag
240     */
241    @Override
242    public boolean isUseFieldNames() {
243        return super.isUseFieldNames();
244    }
245
246    /**
247     * Gets whether to use the identity hash code.
248     * @return the current useIdentityHashCode flag
249     */
250    @Override
251    public boolean isUseIdentityHashCode() {
252        return super.isUseIdentityHashCode();
253    }
254
255    /**
256     * Gets whether to output short or long class names.
257     *
258     * @return the current useShortClassName flag
259     * @since 2.0
260     */
261    @Override
262    public boolean isUseShortClassName() {
263        return super.isUseShortClassName();
264    }
265
266    /**
267     * Sets whether to output array content detail.
268     *
269     * @param arrayContentDetail  the new arrayContentDetail flag
270     */
271    @Override
272    public void setArrayContentDetail(final boolean arrayContentDetail) {
273        super.setArrayContentDetail(arrayContentDetail);
274    }
275
276    /**
277     * Sets the array end text.
278     *
279     * <p>{@code null} is accepted, but will be converted
280     * to an empty String.</p>
281     *
282     * @param arrayEnd  the new array end text
283     */
284    @Override
285    public void setArrayEnd(final String arrayEnd) {
286        super.setArrayEnd(arrayEnd);
287    }
288
289    /**
290     * Sets the array separator text.
291     *
292     * <p>{@code null} is accepted, but will be converted
293     * to an empty String.</p>
294     *
295     * @param arraySeparator  the new array separator text
296     */
297    @Override
298    public void setArraySeparator(final String arraySeparator) {
299        super.setArraySeparator(arraySeparator);
300    }
301
302    /**
303     * Sets the array start text.
304     *
305     * <p>{@code null} is accepted, but will be converted
306     * to an empty String.</p>
307     *
308     * @param arrayStart  the new array start text
309     */
310    @Override
311    public void setArrayStart(final String arrayStart) {
312        super.setArrayStart(arrayStart);
313    }
314
315    /**
316     * Sets the content end text.
317     *
318     * <p>{@code null} is accepted, but will be converted
319     * to an empty String.</p>
320     *
321     * @param contentEnd  the new content end text
322     */
323    @Override
324    public void setContentEnd(final String contentEnd) {
325        super.setContentEnd(contentEnd);
326    }
327
328    /**
329     * Sets the content start text.
330     *
331     * <p>{@code null} is accepted, but will be converted
332     * to an empty String.</p>
333     *
334     * @param contentStart  the new content start text
335     */
336    @Override
337    public void setContentStart(final String contentStart) {
338        super.setContentStart(contentStart);
339    }
340
341    /**
342     * Sets whether to use full detail when the caller doesn't
343     * specify.
344     *
345     * @param defaultFullDetail  the new defaultFullDetail flag
346     */
347    @Override
348    public void setDefaultFullDetail(final boolean defaultFullDetail) {
349        super.setDefaultFullDetail(defaultFullDetail);
350    }
351
352    /**
353     * Sets the field name value separator text.
354     *
355     * <p>{@code null} is accepted, but will be converted
356     * to an empty String.</p>
357     *
358     * @param fieldNameValueSeparator  the new field name value separator text
359     */
360    @Override
361    public void setFieldNameValueSeparator(final String fieldNameValueSeparator) {
362        super.setFieldNameValueSeparator(fieldNameValueSeparator);
363    }
364
365    /**
366     * Sets the field separator text.
367     *
368     * <p>{@code null} is accepted, but will be converted
369     * to an empty String.</p>
370     *
371     * @param fieldSeparator  the new field separator text
372     */
373    @Override
374    public void setFieldSeparator(final String fieldSeparator) {
375        super.setFieldSeparator(fieldSeparator);
376    }
377
378    /**
379     * Sets whether the field separator should be added at the end
380     * of each buffer.
381     *
382     * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
383     * @since 2.0
384     */
385    @Override
386    public void setFieldSeparatorAtEnd(final boolean fieldSeparatorAtEnd) {
387        super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
388    }
389
390    /**
391     * Sets whether the field separator should be added at the start
392     * of each buffer.
393     *
394     * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
395     * @since 2.0
396     */
397    @Override
398    public void setFieldSeparatorAtStart(final boolean fieldSeparatorAtStart) {
399        super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
400    }
401
402    /**
403     * Sets the text to output when {@code null} found.
404     *
405     * <p>{@code null} is accepted, but will be converted
406     * to an empty String.</p>
407     *
408     * @param nullText  the new text to output when {@code null} found
409     */
410    @Override
411    public void setNullText(final String nullText) {
412        super.setNullText(nullText);
413    }
414
415    /**
416     * Sets the end text to output when a {@link Collection},
417     * {@link Map} or {@link Array} size is output.
418     *
419     * <p>This is output after the size value.</p>
420     *
421     * <p>{@code null} is accepted, but will be converted
422     * to an empty String.</p>
423     *
424     * @param sizeEndText  the new end of size text
425     */
426    @Override
427    public void setSizeEndText(final String sizeEndText) {
428        super.setSizeEndText(sizeEndText);
429    }
430
431    /**
432     * Sets the start text to output when a {@link Collection},
433     * {@link Map} or {@link Array} size is output.
434     *
435     * <p>This is output before the size value.</p>
436     *
437     * <p>{@code null} is accepted, but will be converted to
438     * an empty String.</p>
439     *
440     * @param sizeStartText  the new start of size text
441     */
442    @Override
443    public void setSizeStartText(final String sizeStartText) {
444        super.setSizeStartText(sizeStartText);
445    }
446
447    /**
448     * Sets the end text to output when an {@link Object} is
449     * output in summary mode.
450     *
451     * <p>This is output after the size value.</p>
452     *
453     * <p>{@code null} is accepted, but will be converted to
454     * an empty String.</p>
455     *
456     * @param summaryObjectEndText  the new end of summary text
457     */
458    @Override
459    public void setSummaryObjectEndText(final String summaryObjectEndText) {
460        super.setSummaryObjectEndText(summaryObjectEndText);
461    }
462
463    /**
464     * Sets the start text to output when an {@link Object} is
465     * output in summary mode.
466     *
467     * <p>This is output before the size value.</p>
468     *
469     * <p>{@code null} is accepted, but will be converted to
470     * an empty String.</p>
471     *
472     * @param summaryObjectStartText  the new start of summary text
473     */
474    @Override
475    public void setSummaryObjectStartText(final String summaryObjectStartText) {
476        super.setSummaryObjectStartText(summaryObjectStartText);
477    }
478
479    /**
480     * Sets whether to use the class name.
481     *
482     * @param useClassName  the new useClassName flag
483     */
484    @Override
485    public void setUseClassName(final boolean useClassName) {
486        super.setUseClassName(useClassName);
487    }
488
489    /**
490     * Sets whether to use the field names passed in.
491     *
492     * @param useFieldNames  the new useFieldNames flag
493     */
494    @Override
495    public void setUseFieldNames(final boolean useFieldNames) {
496        super.setUseFieldNames(useFieldNames);
497    }
498
499    /**
500     * Sets whether to use the identity hash code.
501     *
502     * @param useIdentityHashCode  the new useIdentityHashCode flag
503     */
504    @Override
505    public void setUseIdentityHashCode(final boolean useIdentityHashCode) {
506        super.setUseIdentityHashCode(useIdentityHashCode);
507    }
508
509    /**
510     * Sets whether to output short or long class names.
511     *
512     * @param useShortClassName  the new useShortClassName flag
513     * @since 2.0
514     */
515    @Override
516    public void setUseShortClassName(final boolean useShortClassName) {
517        super.setUseShortClassName(useShortClassName);
518    }
519
520}