    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     */
    017    package org.apache.commons.lang.builder;
    018
    019    /**
    020     * <p>Works with {@link ToStringBuilder} to create a <code>toString</code>.</p>
    021     *
    022     * <p>This class is intended to be used as a singleton.
    023     * There is no need to instantiate a new style each time.
    024     * Simply instantiate the class once, customize the values as required, and
    025     * store the result in a public static final variable for the rest of the
    026     * program to access.</p>
    027     *
    028     * @author Apache Software Foundation
    029     * @author Pete Gieser
    030     * @author Gary Gregory
    031     * @since 1.0
    032     * @version $Id: StandardToStringStyle.java 905636 2010-02-02 14:03:32Z niallp $
    033     */
    034    public 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         * <p>Constructor.</p>
    045         */
    046        public StandardToStringStyle() {
    047            super();
    048        }
    049
    050        //---------------------------------------------------------------------
    051
    052        /**
    053         * <p>Gets whether to use the class name.</p>
    054         *
    055         * @return the current useClassName flag
    056         */
    057        public boolean isUseClassName() {
    058            return super.isUseClassName();
    059        }
    060
    061        /**
    062         * <p>Sets whether to use the class name.</p>
    063         *
    064         * @param useClassName  the new useClassName flag
    065         */
    066        public void setUseClassName(boolean useClassName) {
    067            super.setUseClassName(useClassName);
    068        }
    069
    070        //---------------------------------------------------------------------
    071
    072        /**
    073         * <p>Gets whether to output short or long class names.</p>
    074         *
    075         * @return the current useShortClassName flag
    076         * @since 2.0
    077         */
    078        public boolean isUseShortClassName() {
    079            return super.isUseShortClassName();
    080        }
    081
    082        /**
    083         * <p>Gets whether to output short or long class names.</p>
    084         *
    085         * @return the current shortClassName flag
    086         * @deprecated Use {@link #isUseShortClassName()}
    087         *             Method will be removed in Commons Lang 3.0.
    088         */
    089        public boolean isShortClassName() {
    090            return super.isUseShortClassName();
    091        }
    092
    093        /**
    094         * <p>Sets whether to output short or long class names.</p>
    095         *
    096         * @param useShortClassName  the new useShortClassName flag
    097         * @since 2.0
    098         */
    099        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    }