View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.lang.builder;
18  
19  /**
20   * <p>Works with {@link ToStringBuilder} to create a <code>toString</code>.</p>
21   *
22   * <p>This class is intended to be used as a singleton.
23   * There is no need to instantiate a new style each time.
24   * Simply instantiate the class once, customize the values as required, and
25   * store the result in a public static final variable for the rest of the
26   * program to access.</p>
27   *
28   * @author Stephen Colebourne
29   * @author Pete Gieser
30   * @author Gary Gregory
31   * @since 1.0
32   * @version $Id: StandardToStringStyle.java 437554 2006-08-28 06:21:41Z bayard $
33   */
34  public class StandardToStringStyle extends ToStringStyle {
35      
36      /**
37       * Required for serialization support.
38       * 
39       * @see java.io.Serializable
40       */
41      private static final long serialVersionUID = 1L;
42  
43      /**
44       * <p>Constructor.</p>
45       */
46      public StandardToStringStyle() {
47          super();
48      }
49      
50      //---------------------------------------------------------------------
51      
52      /**
53       * <p>Gets whether to use the class name.</p>
54       *
55       * @return the current useClassName flag
56       */
57      public boolean isUseClassName() {
58          return super.isUseClassName();
59      }
60  
61      /**
62       * <p>Sets whether to use the class name.</p>
63       *
64       * @param useClassName  the new useClassName flag
65       */
66      public void setUseClassName(boolean useClassName) {
67          super.setUseClassName(useClassName);
68      }
69  
70      //---------------------------------------------------------------------
71      
72      /**
73       * <p>Gets whether to output short or long class names.</p>
74       *
75       * @return the current useShortClassName flag
76       * @since 2.0
77       */
78      public boolean isUseShortClassName() {
79          return super.isUseShortClassName();
80      }
81  
82      /**
83       * <p>Gets whether to output short or long class names.</p>
84       *
85       * @return the current shortClassName flag
86       * @deprecated Use {@link #isUseShortClassName()}
87       *             Method will be removed in Commons Lang 3.0.
88       */
89      public boolean isShortClassName() {
90          return super.isUseShortClassName();
91      }
92  
93      /**
94       * <p>Sets whether to output short or long class names.</p>
95       *
96       * @param useShortClassName  the new useShortClassName flag
97       * @since 2.0
98       */
99      public void setUseShortClassName(boolean useShortClassName) {
100         super.setUseShortClassName(useShortClassName);
101     }
102 
103     /**
104      * <p>Sets whether to output short or long class names.</p>
105      *
106      * @param shortClassName  the new shortClassName flag
107      * @deprecated Use {@link #setUseShortClassName(boolean)}
108      *             Method will be removed in Commons Lang 3.0.
109      */
110     public void setShortClassName(boolean shortClassName) {
111         super.setUseShortClassName(shortClassName);
112     }
113 
114     //---------------------------------------------------------------------
115     
116     /**
117      * <p>Gets whether to use the identity hash code.</p>
118      * @return the current useIdentityHashCode flag
119      */
120     public boolean isUseIdentityHashCode() {
121         return super.isUseIdentityHashCode();
122     }
123 
124     /**
125      * <p>Sets whether to use the identity hash code.</p>
126      *
127      * @param useIdentityHashCode  the new useIdentityHashCode flag
128      */
129     public void setUseIdentityHashCode(boolean useIdentityHashCode) {
130         super.setUseIdentityHashCode(useIdentityHashCode);
131     }
132 
133     //---------------------------------------------------------------------
134     
135     /**
136      * <p>Gets whether to use the field names passed in.</p>
137      *
138      * @return the current useFieldNames flag
139      */
140     public boolean isUseFieldNames() {
141         return super.isUseFieldNames();
142     }
143 
144     /**
145      * <p>Sets whether to use the field names passed in.</p>
146      *
147      * @param useFieldNames  the new useFieldNames flag
148      */
149     public void setUseFieldNames(boolean useFieldNames) {
150         super.setUseFieldNames(useFieldNames);
151     }
152 
153     //---------------------------------------------------------------------
154     
155     /**
156      * <p>Gets whether to use full detail when the caller doesn't
157      * specify.</p>
158      *
159      * @return the current defaultFullDetail flag
160      */
161     public boolean isDefaultFullDetail() {
162         return super.isDefaultFullDetail();
163     }
164 
165     /**
166      * <p>Sets whether to use full detail when the caller doesn't
167      * specify.</p>
168      *
169      * @param defaultFullDetail  the new defaultFullDetail flag
170      */
171     public void setDefaultFullDetail(boolean defaultFullDetail) {
172         super.setDefaultFullDetail(defaultFullDetail);
173     }
174 
175     //---------------------------------------------------------------------
176     
177     /**
178      * <p>Gets whether to output array content detail.</p>
179      *
180      * @return the current array content detail setting
181      */
182     public boolean isArrayContentDetail() {
183         return super.isArrayContentDetail();
184     }
185     
186     /**
187      * <p>Sets whether to output array content detail.</p>
188      *
189      * @param arrayContentDetail  the new arrayContentDetail flag
190      */
191     public void setArrayContentDetail(boolean arrayContentDetail) {
192         super.setArrayContentDetail(arrayContentDetail);
193     }
194 
195     //---------------------------------------------------------------------
196     
197     /**
198      * <p>Gets the array start text.</p>
199      *
200      * @return the current array start text
201      */
202     public String getArrayStart() {
203         return super.getArrayStart();
204     }
205 
206     /**
207      * <p>Sets the array start text.</p>
208      *
209      * <p><code>null</code> is accepted, but will be converted
210      * to an empty String.</p>
211      *
212      * @param arrayStart  the new array start text
213      */
214     public void setArrayStart(String arrayStart) {
215         super.setArrayStart(arrayStart);
216     }
217 
218     //---------------------------------------------------------------------
219     
220     /**
221      * <p>Gets the array end text.</p>
222      *
223      * @return the current array end text
224      */
225     public String getArrayEnd() {
226         return super.getArrayEnd();
227     }
228 
229     /**
230      * <p>Sets the array end text.</p>
231      *
232      * <p><code>null</code> is accepted, but will be converted
233      * to an empty String.</p>
234      *
235      * @param arrayEnd  the new array end text
236      */
237     public void setArrayEnd(String arrayEnd) {
238         super.setArrayEnd(arrayEnd);
239     }
240 
241     //---------------------------------------------------------------------
242     
243     /**
244      * <p>Gets the array separator text.</p>
245      *
246      * @return the current array separator text
247      */
248     public String getArraySeparator() {
249         return super.getArraySeparator();
250     }
251 
252     /**
253      * <p>Sets the array separator text.</p>
254      *
255      * <p><code>null</code> is accepted, but will be converted
256      * to an empty String.</p>
257      *
258      * @param arraySeparator  the new array separator text
259      */
260     public void setArraySeparator(String arraySeparator) {
261         super.setArraySeparator(arraySeparator);
262     }
263 
264     //---------------------------------------------------------------------
265     
266     /**
267      * <p>Gets the content start text.</p>
268      *
269      * @return the current content start text
270      */
271     public String getContentStart() {
272         return super.getContentStart();
273     }
274 
275     /**
276      * <p>Sets the content start text.</p>
277      *
278      * <p><code>null</code> is accepted, but will be converted
279      * to an empty String.</p>
280      *
281      * @param contentStart  the new content start text
282      */
283     public void setContentStart(String contentStart) {
284         super.setContentStart(contentStart);
285     }
286 
287     //---------------------------------------------------------------------
288     
289     /**
290      * <p>Gets the content end text.</p>
291      *
292      * @return the current content end text
293      */
294     public String getContentEnd() {
295         return super.getContentEnd();
296     }
297 
298     /**
299      * <p>Sets the content end text.</p>
300      *
301      * <p><code>null</code> is accepted, but will be converted
302      * to an empty String.</p>
303      *
304      * @param contentEnd  the new content end text
305      */
306     public void setContentEnd(String contentEnd) {
307         super.setContentEnd(contentEnd);
308     }
309 
310     //---------------------------------------------------------------------
311     
312     /**
313      * <p>Gets the field name value separator text.</p>
314      *
315      * @return the current field name value separator text
316      */
317     public String getFieldNameValueSeparator() {
318         return super.getFieldNameValueSeparator();
319     }
320 
321     /**
322      * <p>Sets the field name value separator text.</p>
323      *
324      * <p><code>null</code> is accepted, but will be converted
325      * to an empty String.</p>
326      *
327      * @param fieldNameValueSeparator  the new field name value separator text
328      */
329     public void setFieldNameValueSeparator(String fieldNameValueSeparator) {
330         super.setFieldNameValueSeparator(fieldNameValueSeparator);
331     }
332 
333     //---------------------------------------------------------------------
334     
335     /**
336      * <p>Gets the field separator text.</p>
337      *
338      * @return the current field separator text
339      */
340     public String getFieldSeparator() {
341         return super.getFieldSeparator();
342     }
343 
344     /**
345      * <p>Sets the field separator text.</p>
346      *
347      * <p><code>null</code> is accepted, but will be converted
348      * to an empty String.</p>
349      *
350      * @param fieldSeparator  the new field separator text
351      */
352     public void setFieldSeparator(String fieldSeparator) {
353         super.setFieldSeparator(fieldSeparator);
354     }
355 
356     //---------------------------------------------------------------------
357     
358     /**
359      * <p>Gets whether the field separator should be added at the start 
360      * of each buffer.</p>
361      * 
362      * @return the fieldSeparatorAtStart flag
363      * @since 2.0
364      */
365     public boolean isFieldSeparatorAtStart() {
366         return super.isFieldSeparatorAtStart();
367     }
368 
369     /**
370      * <p>Sets whether the field separator should be added at the start 
371      * of each buffer.</p>
372      * 
373      * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
374      * @since 2.0
375      */
376     public void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) {
377         super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
378     }
379 
380     //---------------------------------------------------------------------
381     
382     /**
383      * <p>Gets whether the field separator should be added at the end 
384      * of each buffer.</p>
385      * 
386      * @return fieldSeparatorAtEnd flag
387      * @since 2.0
388      */
389     public boolean isFieldSeparatorAtEnd() {
390         return super.isFieldSeparatorAtEnd();
391     }
392 
393     /**
394      * <p>Sets whether the field separator should be added at the end 
395      * of each buffer.</p>
396      * 
397      * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
398      * @since 2.0
399      */
400     public void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
401         super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
402     }
403 
404     //---------------------------------------------------------------------
405     
406     /**
407      * <p>Gets the text to output when <code>null</code> found.</p>
408      *
409      * @return the current text to output when <code>null</code> found
410      */
411     public String getNullText() {
412         return super.getNullText();
413     }
414 
415     /**
416      * <p>Sets the text to output when <code>null</code> found.</p>
417      *
418      * <p><code>null</code> is accepted, but will be converted
419      * to an empty String.</p>
420      *
421      * @param nullText  the new text to output when <code>null</code> found
422      */
423     public void setNullText(String nullText) {
424         super.setNullText(nullText);
425     }
426 
427     //---------------------------------------------------------------------
428     
429     /**
430      * <p>Gets the text to output when a <code>Collection</code>,
431      * <code>Map</code> or <code>Array</code> size is output.</p>
432      *
433      * <p>This is output before the size value.</p>
434      *
435      * @return the current start of size text
436      */
437     public String getSizeStartText() {
438         return super.getSizeStartText();
439     }
440 
441     /**
442      * <p>Sets the start text to output when a <code>Collection</code>,
443      * <code>Map</code> or <code>Array</code> size is output.</p>
444      *
445      * <p>This is output before the size value.</p>
446      *
447      * <p><code>null</code> is accepted, but will be converted to
448      * an empty String.</p>
449      *
450      * @param sizeStartText  the new start of size text
451      */
452     public void setSizeStartText(String sizeStartText) {
453         super.setSizeStartText(sizeStartText);
454     }
455 
456     //---------------------------------------------------------------------
457     
458     /**
459      * Gets the end text to output when a <code>Collection</code>,
460      * <code>Map</code> or <code>Array</code> size is output.</p>
461      *
462      * <p>This is output after the size value.</p>
463      *
464      * @return the current end of size text
465      */
466     public String getSizeEndText() {
467         return super.getSizeEndText();
468     }
469 
470     /**
471      * <p>Sets the end text to output when a <code>Collection</code>,
472      * <code>Map</code> or <code>Array</code> size is output.</p>
473      *
474      * <p>This is output after the size value.</p>
475      *
476      * <p><code>null</code> is accepted, but will be converted
477      * to an empty String.</p>
478      *
479      * @param sizeEndText  the new end of size text
480      */
481     public void setSizeEndText(String sizeEndText) {
482         super.setSizeEndText(sizeEndText);
483     }
484 
485     //---------------------------------------------------------------------
486     
487     /**
488      * <p>Gets the start text to output when an <code>Object</code> is
489      * output in summary mode.</p>
490      *
491      * <P>This is output before the size value.</p>
492      *
493      * @return the current start of summary text
494      */
495     public String getSummaryObjectStartText() {
496         return super.getSummaryObjectStartText();
497     }
498 
499     /**
500      * <p>Sets the start text to output when an <code>Object</code> is
501      * output in summary mode.</p>
502      *
503      * <p>This is output before the size value.</p>
504      *
505      * <p><code>null</code> is accepted, but will be converted to
506      * an empty String.</p>
507      *
508      * @param summaryObjectStartText  the new start of summary text
509      */
510     public void setSummaryObjectStartText(String summaryObjectStartText) {
511         super.setSummaryObjectStartText(summaryObjectStartText);
512     }
513 
514     //---------------------------------------------------------------------
515     
516     /**
517      * <p>Gets the end text to output when an <code>Object</code> is
518      * output in summary mode.</p>
519      *
520      * <p>This is output after the size value.</p>
521      *
522      * @return the current end of summary text
523      */
524     public String getSummaryObjectEndText() {
525         return super.getSummaryObjectEndText();
526     }
527 
528     /**
529      * <p>Sets the end text to output when an <code>Object</code> is
530      * output in summary mode.</p>
531      *
532      * <p>This is output after the size value.</p>
533      *
534      * <p><code>null</code> is accepted, but will be converted to
535      * an empty String.</p>
536      *
537      * @param summaryObjectEndText  the new end of summary text
538      */
539     public void setSummaryObjectEndText(String summaryObjectEndText) {
540         super.setSummaryObjectEndText(summaryObjectEndText);
541     }
542 
543     //---------------------------------------------------------------------
544     
545 }