Source Code Cross Referenced for ToStringStyle.java in  » Library » Apache-common-lang » org » apache » commons » lang » builder » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common lang » org.apache.commons.lang.builder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         * 
0009:         *      http://www.apache.org/licenses/LICENSE-2.0
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:        package org.apache.commons.lang.builder;
0018:
0019:        import java.io.Serializable;
0020:        import java.lang.reflect.Array;
0021:        import java.util.Collection;
0022:        import java.util.HashSet;
0023:        import java.util.Map;
0024:        import java.util.Set;
0025:
0026:        import org.apache.commons.lang.ClassUtils;
0027:        import org.apache.commons.lang.ObjectUtils;
0028:        import org.apache.commons.lang.SystemUtils;
0029:
0030:        /**
0031:         * <p>Controls <code>String</code> formatting for {@link ToStringBuilder}.
0032:         * The main public interface is always via <code>ToStringBuilder</code>.</p>
0033:         *
0034:         * <p>These classes are intended to be used as <code>Singletons</code>.
0035:         * There is no need to instantiate a new style each time. A program
0036:         * will generally use one of the predefined constants on this class.
0037:         * Alternatively, the {@link StandardToStringStyle} class can be used
0038:         * to set the individual settings. Thus most styles can be achieved
0039:         * without subclassing.</p>
0040:         *
0041:         * <p>If required, a subclass can override as many or as few of the
0042:         * methods as it requires. Each object type (from <code>boolean</code>
0043:         * to <code>long</code> to <code>Object</code> to <code>int[]</code>) has
0044:         * its own methods to output it. Most have two versions, detail and summary.
0045:         *
0046:         * <p>For example, the detail version of the array based methods will
0047:         * output the whole array, whereas the summary method will just output
0048:         * the array length.</p>
0049:         * 
0050:         * <p>If you want to format the output of certain objects, such as dates, you
0051:         * must create a subclass and override a method.
0052:         * <pre>
0053:         * public class MyStyle extends ToStringStyle {
0054:         *   protected void appendDetail(StringBuffer buffer, String fieldName, Object value) {
0055:         *     if (value instanceof Date) {
0056:         *       value = new SimpleDateFormat("yyyy-MM-dd").format(value);
0057:         *     }
0058:         *     buffer.append(value);
0059:         *   }
0060:         * }
0061:         * </pre>
0062:         * </p>
0063:         *
0064:         * @author Stephen Colebourne
0065:         * @author Gary Gregory
0066:         * @author Pete Gieser
0067:         * @author Masato Tezuka
0068:         * @since 1.0
0069:         * @version $Id: ToStringStyle.java 500497 2007-01-27 07:13:59Z bayard $
0070:         */
0071:        public abstract class ToStringStyle implements  Serializable {
0072:
0073:            /**
0074:             * The default toString style.
0075:             */
0076:            public static final ToStringStyle DEFAULT_STYLE = new DefaultToStringStyle();
0077:
0078:            /**
0079:             * The multi line toString style.
0080:             */
0081:            public static final ToStringStyle MULTI_LINE_STYLE = new MultiLineToStringStyle();
0082:
0083:            /**
0084:             * The no field names toString style.
0085:             */
0086:            public static final ToStringStyle NO_FIELD_NAMES_STYLE = new NoFieldNameToStringStyle();
0087:
0088:            /**
0089:             * The short prefix toString style.
0090:             * @since 2.1
0091:             */
0092:            public static final ToStringStyle SHORT_PREFIX_STYLE = new ShortPrefixToStringStyle();
0093:
0094:            /**
0095:             * The simple toString style.
0096:             */
0097:            public static final ToStringStyle SIMPLE_STYLE = new SimpleToStringStyle();
0098:
0099:            /**
0100:             * <p>
0101:             * A registry of objects used by <code>reflectionToString</code> methods
0102:             * to detect cyclical object references and avoid infinite loops.
0103:             * </p>
0104:             */
0105:            private static ThreadLocal registry = new ThreadLocal() {
0106:                protected synchronized Object initialValue() {
0107:                    // The HashSet implementation is not synchronized,
0108:                    // which is just what we need here.
0109:                    return new HashSet();
0110:                }
0111:            };
0112:
0113:            /**
0114:             * <p>
0115:             * Returns the registry of objects being traversed by the <code>reflectionToString</code>
0116:             * methods in the current thread.
0117:             * </p>
0118:             * 
0119:             * @return Set the registry of objects being traversed
0120:             */
0121:            static Set getRegistry() {
0122:                return (Set) registry.get();
0123:            }
0124:
0125:            /**
0126:             * <p>
0127:             * Returns <code>true</code> if the registry contains the given object.
0128:             * Used by the reflection methods to avoid infinite loops.
0129:             * </p>
0130:             * 
0131:             * @param value
0132:             *                  The object to lookup in the registry.
0133:             * @return boolean <code>true</code> if the registry contains the given
0134:             *             object.
0135:             */
0136:            static boolean isRegistered(Object value) {
0137:                return getRegistry().contains(value);
0138:            }
0139:
0140:            /**
0141:             * <p>
0142:             * Registers the given object. Used by the reflection methods to avoid
0143:             * infinite loops.
0144:             * </p>
0145:             * 
0146:             * @param value
0147:             *                  The object to register.
0148:             */
0149:            static void register(Object value) {
0150:                if (value != null) {
0151:                    getRegistry().add(value);
0152:                }
0153:            }
0154:
0155:            /**
0156:             * <p>
0157:             * Unregisters the given object.
0158:             * </p>
0159:             * 
0160:             * <p>
0161:             * Used by the reflection methods to avoid infinite loops.
0162:             * </p>
0163:             * 
0164:             * @param value
0165:             *                  The object to unregister.
0166:             */
0167:            static void unregister(Object value) {
0168:                getRegistry().remove(value);
0169:            }
0170:
0171:            /**
0172:             * Whether to use the field names, the default is <code>true</code>.
0173:             */
0174:            private boolean useFieldNames = true;
0175:
0176:            /**
0177:             * Whether to use the class name, the default is <code>true</code>.
0178:             */
0179:            private boolean useClassName = true;
0180:
0181:            /**
0182:             * Whether to use short class names, the default is <code>false</code>.
0183:             */
0184:            private boolean useShortClassName = false;
0185:
0186:            /**
0187:             * Whether to use the identity hash code, the default is <code>true</code>.
0188:             */
0189:            private boolean useIdentityHashCode = true;
0190:
0191:            /**
0192:             * The content start <code>'['</code>.
0193:             */
0194:            private String contentStart = "[";
0195:
0196:            /**
0197:             * The content end <code>']'</code>.
0198:             */
0199:            private String contentEnd = "]";
0200:
0201:            /**
0202:             * The field name value separator <code>'='</code>.
0203:             */
0204:            private String fieldNameValueSeparator = "=";
0205:
0206:            /**
0207:             * Whether the field separator should be added before any other fields.
0208:             */
0209:            private boolean fieldSeparatorAtStart = false;
0210:
0211:            /**
0212:             * Whether the field separator should be added after any other fields.
0213:             */
0214:            private boolean fieldSeparatorAtEnd = false;
0215:
0216:            /**
0217:             * The field separator <code>','</code>.
0218:             */
0219:            private String fieldSeparator = ",";
0220:
0221:            /**
0222:             * The array start <code>'{'</code>.
0223:             */
0224:            private String arrayStart = "{";
0225:
0226:            /**
0227:             * The array separator <code>','</code>.
0228:             */
0229:            private String arraySeparator = ",";
0230:
0231:            /**
0232:             * The detail for array content.
0233:             */
0234:            private boolean arrayContentDetail = true;
0235:
0236:            /**
0237:             * The array end <code>'}'</code>.
0238:             */
0239:            private String arrayEnd = "}";
0240:
0241:            /**
0242:             * The value to use when fullDetail is <code>null</code>,
0243:             * the default value is <code>true</code>.
0244:             */
0245:            private boolean defaultFullDetail = true;
0246:
0247:            /**
0248:             * The <code>null</code> text <code>'&lt;null&gt;'</code>.
0249:             */
0250:            private String nullText = "<null>";
0251:
0252:            /**
0253:             * The summary size text start <code>'<size'</code>.
0254:             */
0255:            private String sizeStartText = "<size=";
0256:
0257:            /**
0258:             * The summary size text start <code>'&gt;'</code>.
0259:             */
0260:            private String sizeEndText = ">";
0261:
0262:            /**
0263:             * The summary object text start <code>'&lt;'</code>.
0264:             */
0265:            private String summaryObjectStartText = "<";
0266:
0267:            /**
0268:             * The summary object text start <code>'&gt;'</code>.
0269:             */
0270:            private String summaryObjectEndText = ">";
0271:
0272:            //----------------------------------------------------------------------------
0273:
0274:            /**
0275:             * <p>Constructor.</p>
0276:             */
0277:            protected ToStringStyle() {
0278:                super ();
0279:            }
0280:
0281:            //----------------------------------------------------------------------------
0282:
0283:            /**
0284:             * <p>Append to the <code>toString</code> the superclass toString.</p>
0285:             * 
0286:             * <p>A <code>null</code> <code>superToString</code> is ignored.</p>
0287:             * 
0288:             * @param buffer  the <code>StringBuffer</code> to populate
0289:             * @param superToString  the <code>super.toString()</code>
0290:             * @since 2.0
0291:             */
0292:            public void appendSuper(StringBuffer buffer, String super ToString) {
0293:                appendToString(buffer, super ToString);
0294:            }
0295:
0296:            /**
0297:             * <p>Append to the <code>toString</code> another toString.</p>
0298:             * 
0299:             * <p>A <code>null</code> <code>toString</code> is ignored.</p>
0300:             * 
0301:             * @param buffer  the <code>StringBuffer</code> to populate
0302:             * @param toString  the additional <code>toString</code>
0303:             * @since 2.0
0304:             */
0305:            public void appendToString(StringBuffer buffer, String toString) {
0306:                if (toString != null) {
0307:                    int pos1 = toString.indexOf(contentStart)
0308:                            + contentStart.length();
0309:                    int pos2 = toString.lastIndexOf(contentEnd);
0310:                    if (pos1 != pos2 && pos1 >= 0 && pos2 >= 0) {
0311:                        String data = toString.substring(pos1, pos2);
0312:                        if (fieldSeparatorAtStart) {
0313:                            removeLastFieldSeparator(buffer);
0314:                        }
0315:                        buffer.append(data);
0316:                        appendFieldSeparator(buffer);
0317:                    }
0318:                }
0319:            }
0320:
0321:            /**
0322:             * <p>Append to the <code>toString</code> the start of data indicator.</p>
0323:             * 
0324:             * @param buffer  the <code>StringBuffer</code> to populate
0325:             * @param object  the <code>Object</code> to build a <code>toString</code> for
0326:             */
0327:            public void appendStart(StringBuffer buffer, Object object) {
0328:                if (object != null) {
0329:                    appendClassName(buffer, object);
0330:                    appendIdentityHashCode(buffer, object);
0331:                    appendContentStart(buffer);
0332:                    if (fieldSeparatorAtStart) {
0333:                        appendFieldSeparator(buffer);
0334:                    }
0335:                }
0336:            }
0337:
0338:            /**
0339:             * <p>Append to the <code>toString</code> the end of data indicator.</p>
0340:             * 
0341:             * @param buffer  the <code>StringBuffer</code> to populate
0342:             * @param object  the <code>Object</code> to build a
0343:             *  <code>toString</code> for.
0344:             */
0345:            public void appendEnd(StringBuffer buffer, Object object) {
0346:                if (this .fieldSeparatorAtEnd == false) {
0347:                    removeLastFieldSeparator(buffer);
0348:                }
0349:                appendContentEnd(buffer);
0350:                unregister(object);
0351:            }
0352:
0353:            /**
0354:             * <p>Remove the last field separator from the buffer.</p>
0355:             * 
0356:             * @param buffer  the <code>StringBuffer</code> to populate
0357:             * @since 2.0
0358:             */
0359:            protected void removeLastFieldSeparator(StringBuffer buffer) {
0360:                int len = buffer.length();
0361:                int sepLen = fieldSeparator.length();
0362:                if (len > 0 && sepLen > 0 && len >= sepLen) {
0363:                    boolean match = true;
0364:                    for (int i = 0; i < sepLen; i++) {
0365:                        if (buffer.charAt(len - 1 - i) != fieldSeparator
0366:                                .charAt(sepLen - 1 - i)) {
0367:                            match = false;
0368:                            break;
0369:                        }
0370:                    }
0371:                    if (match) {
0372:                        buffer.setLength(len - sepLen);
0373:                    }
0374:                }
0375:            }
0376:
0377:            //----------------------------------------------------------------------------
0378:
0379:            /**
0380:             * <p>Append to the <code>toString</code> an <code>Object</code>
0381:             * value, printing the full <code>toString</code> of the
0382:             * <code>Object</code> passed in.</p>
0383:             *
0384:             * @param buffer  the <code>StringBuffer</code> to populate
0385:             * @param fieldName  the field name
0386:             * @param value  the value to add to the <code>toString</code>
0387:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
0388:             *  for summary info, <code>null</code> for style decides
0389:             */
0390:            public void append(StringBuffer buffer, String fieldName,
0391:                    Object value, Boolean fullDetail) {
0392:                appendFieldStart(buffer, fieldName);
0393:
0394:                if (value == null) {
0395:                    appendNullText(buffer, fieldName);
0396:
0397:                } else {
0398:                    appendInternal(buffer, fieldName, value,
0399:                            isFullDetail(fullDetail));
0400:                }
0401:
0402:                appendFieldEnd(buffer, fieldName);
0403:            }
0404:
0405:            /**
0406:             * <p>Append to the <code>toString</code> an <code>Object</code>,
0407:             * correctly interpreting its type.</p>
0408:             *
0409:             * <p>This method performs the main lookup by Class type to correctly
0410:             * route arrays, <code>Collections</code>, <code>Maps</code> and
0411:             * <code>Objects</code> to the appropriate method.</p>
0412:             *
0413:             * <p>Either detail or summary views can be specified.</p>
0414:             *
0415:             * <p>If a cycle is detected, an object will be appended with the
0416:             * <code>Object.toString()</code> format.</p>
0417:             *
0418:             * @param buffer  the <code>StringBuffer</code> to populate
0419:             * @param fieldName  the field name, typically not used as already appended
0420:             * @param value  the value to add to the <code>toString</code>,
0421:             *  not <code>null</code>
0422:             * @param detail  output detail or not
0423:             */
0424:            protected void appendInternal(StringBuffer buffer,
0425:                    String fieldName, Object value, boolean detail) {
0426:                if (isRegistered(value)
0427:                        && !(value instanceof  Number
0428:                                || value instanceof  Boolean || value instanceof  Character)) {
0429:                    appendCyclicObject(buffer, fieldName, value);
0430:                    return;
0431:                }
0432:
0433:                register(value);
0434:
0435:                try {
0436:                    if (value instanceof  Collection) {
0437:                        if (detail) {
0438:                            appendDetail(buffer, fieldName, (Collection) value);
0439:                        } else {
0440:                            appendSummarySize(buffer, fieldName,
0441:                                    ((Collection) value).size());
0442:                        }
0443:
0444:                    } else if (value instanceof  Map) {
0445:                        if (detail) {
0446:                            appendDetail(buffer, fieldName, (Map) value);
0447:                        } else {
0448:                            appendSummarySize(buffer, fieldName, ((Map) value)
0449:                                    .size());
0450:                        }
0451:
0452:                    } else if (value instanceof  long[]) {
0453:                        if (detail) {
0454:                            appendDetail(buffer, fieldName, (long[]) value);
0455:                        } else {
0456:                            appendSummary(buffer, fieldName, (long[]) value);
0457:                        }
0458:
0459:                    } else if (value instanceof  int[]) {
0460:                        if (detail) {
0461:                            appendDetail(buffer, fieldName, (int[]) value);
0462:                        } else {
0463:                            appendSummary(buffer, fieldName, (int[]) value);
0464:                        }
0465:
0466:                    } else if (value instanceof  short[]) {
0467:                        if (detail) {
0468:                            appendDetail(buffer, fieldName, (short[]) value);
0469:                        } else {
0470:                            appendSummary(buffer, fieldName, (short[]) value);
0471:                        }
0472:
0473:                    } else if (value instanceof  byte[]) {
0474:                        if (detail) {
0475:                            appendDetail(buffer, fieldName, (byte[]) value);
0476:                        } else {
0477:                            appendSummary(buffer, fieldName, (byte[]) value);
0478:                        }
0479:
0480:                    } else if (value instanceof  char[]) {
0481:                        if (detail) {
0482:                            appendDetail(buffer, fieldName, (char[]) value);
0483:                        } else {
0484:                            appendSummary(buffer, fieldName, (char[]) value);
0485:                        }
0486:
0487:                    } else if (value instanceof  double[]) {
0488:                        if (detail) {
0489:                            appendDetail(buffer, fieldName, (double[]) value);
0490:                        } else {
0491:                            appendSummary(buffer, fieldName, (double[]) value);
0492:                        }
0493:
0494:                    } else if (value instanceof  float[]) {
0495:                        if (detail) {
0496:                            appendDetail(buffer, fieldName, (float[]) value);
0497:                        } else {
0498:                            appendSummary(buffer, fieldName, (float[]) value);
0499:                        }
0500:
0501:                    } else if (value instanceof  boolean[]) {
0502:                        if (detail) {
0503:                            appendDetail(buffer, fieldName, (boolean[]) value);
0504:                        } else {
0505:                            appendSummary(buffer, fieldName, (boolean[]) value);
0506:                        }
0507:
0508:                    } else if (value.getClass().isArray()) {
0509:                        if (detail) {
0510:                            appendDetail(buffer, fieldName, (Object[]) value);
0511:                        } else {
0512:                            appendSummary(buffer, fieldName, (Object[]) value);
0513:                        }
0514:
0515:                    } else {
0516:                        if (detail) {
0517:                            appendDetail(buffer, fieldName, value);
0518:                        } else {
0519:                            appendSummary(buffer, fieldName, value);
0520:                        }
0521:                    }
0522:                } finally {
0523:                    unregister(value);
0524:                }
0525:            }
0526:
0527:            /**
0528:             * <p>Append to the <code>toString</code> an <code>Object</code>
0529:             * value that has been detected to participate in a cycle. This
0530:             * implementation will print the standard string value of the value.</p>
0531:             * 
0532:             * @param buffer  the <code>StringBuffer</code> to populate
0533:             * @param fieldName  the field name, typically not used as already appended
0534:             * @param value  the value to add to the <code>toString</code>,
0535:             *  not <code>null</code>
0536:             *  
0537:             * @since 2.2
0538:             */
0539:            protected void appendCyclicObject(StringBuffer buffer,
0540:                    String fieldName, Object value) {
0541:                ObjectUtils.appendIdentityToString(buffer, value);
0542:            }
0543:
0544:            /**
0545:             * <p>Append to the <code>toString</code> an <code>Object</code>
0546:             * value, printing the full detail of the <code>Object</code>.</p>
0547:             *
0548:             * @param buffer  the <code>StringBuffer</code> to populate
0549:             * @param fieldName  the field name, typically not used as already appended
0550:             * @param value  the value to add to the <code>toString</code>,
0551:             *  not <code>null</code>
0552:             */
0553:            protected void appendDetail(StringBuffer buffer, String fieldName,
0554:                    Object value) {
0555:                buffer.append(value);
0556:            }
0557:
0558:            /**
0559:             * <p>Append to the <code>toString</code> a <code>Collection</code>.</p>
0560:             *
0561:             * @param buffer  the <code>StringBuffer</code> to populate
0562:             * @param fieldName  the field name, typically not used as already appended
0563:             * @param coll  the <code>Collection</code> to add to the
0564:             *  <code>toString</code>, not <code>null</code>
0565:             */
0566:            protected void appendDetail(StringBuffer buffer, String fieldName,
0567:                    Collection coll) {
0568:                buffer.append(coll);
0569:            }
0570:
0571:            /**
0572:             * <p>Append to the <code>toString</code> a <code>Map<code>.</p>
0573:             *
0574:             * @param buffer  the <code>StringBuffer</code> to populate
0575:             * @param fieldName  the field name, typically not used as already appended
0576:             * @param map  the <code>Map</code> to add to the <code>toString</code>,
0577:             *  not <code>null</code>
0578:             */
0579:            protected void appendDetail(StringBuffer buffer, String fieldName,
0580:                    Map map) {
0581:                buffer.append(map);
0582:            }
0583:
0584:            /**
0585:             * <p>Append to the <code>toString</code> an <code>Object</code>
0586:             * value, printing a summary of the <code>Object</code>.</P>
0587:             *
0588:             * @param buffer  the <code>StringBuffer</code> to populate
0589:             * @param fieldName  the field name, typically not used as already appended
0590:             * @param value  the value to add to the <code>toString</code>,
0591:             *  not <code>null</code>
0592:             */
0593:            protected void appendSummary(StringBuffer buffer, String fieldName,
0594:                    Object value) {
0595:                buffer.append(summaryObjectStartText);
0596:                buffer.append(getShortClassName(value.getClass()));
0597:                buffer.append(summaryObjectEndText);
0598:            }
0599:
0600:            //----------------------------------------------------------------------------
0601:
0602:            /**
0603:             * <p>Append to the <code>toString</code> a <code>long</code>
0604:             * value.</p>
0605:             *
0606:             * @param buffer  the <code>StringBuffer</code> to populate
0607:             * @param fieldName  the field name
0608:             * @param value  the value to add to the <code>toString</code>
0609:             */
0610:            public void append(StringBuffer buffer, String fieldName, long value) {
0611:                appendFieldStart(buffer, fieldName);
0612:                appendDetail(buffer, fieldName, value);
0613:                appendFieldEnd(buffer, fieldName);
0614:            }
0615:
0616:            /**
0617:             * <p>Append to the <code>toString</code> a <code>long</code>
0618:             * value.</p>
0619:             *
0620:             * @param buffer  the <code>StringBuffer</code> to populate
0621:             * @param fieldName  the field name, typically not used as already appended
0622:             * @param value  the value to add to the <code>toString</code>
0623:             */
0624:            protected void appendDetail(StringBuffer buffer, String fieldName,
0625:                    long value) {
0626:                buffer.append(value);
0627:            }
0628:
0629:            //----------------------------------------------------------------------------
0630:
0631:            /**
0632:             * <p>Append to the <code>toString</code> an <code>int</code>
0633:             * value.</p>
0634:             *
0635:             * @param buffer  the <code>StringBuffer</code> to populate
0636:             * @param fieldName  the field name
0637:             * @param value  the value to add to the <code>toString</code>
0638:             */
0639:            public void append(StringBuffer buffer, String fieldName, int value) {
0640:                appendFieldStart(buffer, fieldName);
0641:                appendDetail(buffer, fieldName, value);
0642:                appendFieldEnd(buffer, fieldName);
0643:            }
0644:
0645:            /**
0646:             * <p>Append to the <code>toString</code> an <code>int</code>
0647:             * value.</p>
0648:             *
0649:             * @param buffer  the <code>StringBuffer</code> to populate
0650:             * @param fieldName  the field name, typically not used as already appended
0651:             * @param value  the value to add to the <code>toString</code>
0652:             */
0653:            protected void appendDetail(StringBuffer buffer, String fieldName,
0654:                    int value) {
0655:                buffer.append(value);
0656:            }
0657:
0658:            //----------------------------------------------------------------------------
0659:
0660:            /**
0661:             * <p>Append to the <code>toString</code> a <code>short</code>
0662:             * value.</p>
0663:             *
0664:             * @param buffer  the <code>StringBuffer</code> to populate
0665:             * @param fieldName  the field name
0666:             * @param value  the value to add to the <code>toString</code>
0667:             */
0668:            public void append(StringBuffer buffer, String fieldName,
0669:                    short value) {
0670:                appendFieldStart(buffer, fieldName);
0671:                appendDetail(buffer, fieldName, value);
0672:                appendFieldEnd(buffer, fieldName);
0673:            }
0674:
0675:            /**
0676:             * <p>Append to the <code>toString</code> a <code>short</code>
0677:             * value.</p>
0678:             *
0679:             * @param buffer  the <code>StringBuffer</code> to populate
0680:             * @param fieldName  the field name, typically not used as already appended
0681:             * @param value  the value to add to the <code>toString</code>
0682:             */
0683:            protected void appendDetail(StringBuffer buffer, String fieldName,
0684:                    short value) {
0685:                buffer.append(value);
0686:            }
0687:
0688:            //----------------------------------------------------------------------------
0689:
0690:            /**
0691:             * <p>Append to the <code>toString</code> a <code>byte</code>
0692:             * value.</p>
0693:             *
0694:             * @param buffer  the <code>StringBuffer</code> to populate
0695:             * @param fieldName  the field name
0696:             * @param value  the value to add to the <code>toString</code>
0697:             */
0698:            public void append(StringBuffer buffer, String fieldName, byte value) {
0699:                appendFieldStart(buffer, fieldName);
0700:                appendDetail(buffer, fieldName, value);
0701:                appendFieldEnd(buffer, fieldName);
0702:            }
0703:
0704:            /**
0705:             * <p>Append to the <code>toString</code> a <code>byte</code>
0706:             * value.</p>
0707:             *
0708:             * @param buffer  the <code>StringBuffer</code> to populate
0709:             * @param fieldName  the field name, typically not used as already appended
0710:             * @param value  the value to add to the <code>toString</code>
0711:             */
0712:            protected void appendDetail(StringBuffer buffer, String fieldName,
0713:                    byte value) {
0714:                buffer.append(value);
0715:            }
0716:
0717:            //----------------------------------------------------------------------------
0718:
0719:            /**
0720:             * <p>Append to the <code>toString</code> a <code>char</code>
0721:             * value.</p>
0722:             *
0723:             * @param buffer  the <code>StringBuffer</code> to populate
0724:             * @param fieldName  the field name
0725:             * @param value  the value to add to the <code>toString</code>
0726:             */
0727:            public void append(StringBuffer buffer, String fieldName, char value) {
0728:                appendFieldStart(buffer, fieldName);
0729:                appendDetail(buffer, fieldName, value);
0730:                appendFieldEnd(buffer, fieldName);
0731:            }
0732:
0733:            /**
0734:             * <p>Append to the <code>toString</code> a <code>char</code>
0735:             * value.</p>
0736:             *
0737:             * @param buffer  the <code>StringBuffer</code> to populate
0738:             * @param fieldName  the field name, typically not used as already appended
0739:             * @param value  the value to add to the <code>toString</code>
0740:             */
0741:            protected void appendDetail(StringBuffer buffer, String fieldName,
0742:                    char value) {
0743:                buffer.append(value);
0744:            }
0745:
0746:            //----------------------------------------------------------------------------
0747:
0748:            /**
0749:             * <p>Append to the <code>toString</code> a <code>double</code>
0750:             * value.</p>
0751:             *
0752:             * @param buffer  the <code>StringBuffer</code> to populate
0753:             * @param fieldName  the field name
0754:             * @param value  the value to add to the <code>toString</code>
0755:             */
0756:            public void append(StringBuffer buffer, String fieldName,
0757:                    double value) {
0758:                appendFieldStart(buffer, fieldName);
0759:                appendDetail(buffer, fieldName, value);
0760:                appendFieldEnd(buffer, fieldName);
0761:            }
0762:
0763:            /**
0764:             * <p>Append to the <code>toString</code> a <code>double</code>
0765:             * value.</p>
0766:             *
0767:             * @param buffer  the <code>StringBuffer</code> to populate
0768:             * @param fieldName  the field name, typically not used as already appended
0769:             * @param value  the value to add to the <code>toString</code>
0770:             */
0771:            protected void appendDetail(StringBuffer buffer, String fieldName,
0772:                    double value) {
0773:                buffer.append(value);
0774:            }
0775:
0776:            //----------------------------------------------------------------------------
0777:
0778:            /**
0779:             * <p>Append to the <code>toString</code> a <code>float</code>
0780:             * value.</p>
0781:             *
0782:             * @param buffer  the <code>StringBuffer</code> to populate
0783:             * @param fieldName  the field name
0784:             * @param value  the value to add to the <code>toString</code>
0785:             */
0786:            public void append(StringBuffer buffer, String fieldName,
0787:                    float value) {
0788:                appendFieldStart(buffer, fieldName);
0789:                appendDetail(buffer, fieldName, value);
0790:                appendFieldEnd(buffer, fieldName);
0791:            }
0792:
0793:            /**
0794:             * <p>Append to the <code>toString</code> a <code>float</code>
0795:             * value.</p>
0796:             *
0797:             * @param buffer  the <code>StringBuffer</code> to populate
0798:             * @param fieldName  the field name, typically not used as already appended
0799:             * @param value  the value to add to the <code>toString</code>
0800:             */
0801:            protected void appendDetail(StringBuffer buffer, String fieldName,
0802:                    float value) {
0803:                buffer.append(value);
0804:            }
0805:
0806:            //----------------------------------------------------------------------------
0807:
0808:            /**
0809:             * <p>Append to the <code>toString</code> a <code>boolean</code>
0810:             * value.</p>
0811:             *
0812:             * @param buffer  the <code>StringBuffer</code> to populate
0813:             * @param fieldName  the field name
0814:             * @param value  the value to add to the <code>toString</code>
0815:             */
0816:            public void append(StringBuffer buffer, String fieldName,
0817:                    boolean value) {
0818:                appendFieldStart(buffer, fieldName);
0819:                appendDetail(buffer, fieldName, value);
0820:                appendFieldEnd(buffer, fieldName);
0821:            }
0822:
0823:            /**
0824:             * <p>Append to the <code>toString</code> a <code>boolean</code>
0825:             * value.</p>
0826:             *
0827:             * @param buffer  the <code>StringBuffer</code> to populate
0828:             * @param fieldName  the field name, typically not used as already appended
0829:             * @param value  the value to add to the <code>toString</code>
0830:             */
0831:            protected void appendDetail(StringBuffer buffer, String fieldName,
0832:                    boolean value) {
0833:                buffer.append(value);
0834:            }
0835:
0836:            /**
0837:             * <p>Append to the <code>toString</code> an <code>Object</code>
0838:             * array.</p>
0839:             *
0840:             * @param buffer  the <code>StringBuffer</code> to populate
0841:             * @param fieldName  the field name
0842:             * @param array  the array to add to the toString
0843:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
0844:             *  for summary info, <code>null</code> for style decides
0845:             */
0846:            public void append(StringBuffer buffer, String fieldName,
0847:                    Object[] array, Boolean fullDetail) {
0848:                appendFieldStart(buffer, fieldName);
0849:
0850:                if (array == null) {
0851:                    appendNullText(buffer, fieldName);
0852:
0853:                } else if (isFullDetail(fullDetail)) {
0854:                    appendDetail(buffer, fieldName, array);
0855:
0856:                } else {
0857:                    appendSummary(buffer, fieldName, array);
0858:                }
0859:
0860:                appendFieldEnd(buffer, fieldName);
0861:            }
0862:
0863:            //----------------------------------------------------------------------------
0864:
0865:            /**
0866:             * <p>Append to the <code>toString</code> the detail of an
0867:             * <code>Object</code> array.</p>
0868:             *
0869:             * @param buffer  the <code>StringBuffer</code> to populate
0870:             * @param fieldName  the field name, typically not used as already appended
0871:             * @param array  the array to add to the <code>toString</code>,
0872:             *  not <code>null</code>
0873:             */
0874:            protected void appendDetail(StringBuffer buffer, String fieldName,
0875:                    Object[] array) {
0876:                buffer.append(arrayStart);
0877:                for (int i = 0; i < array.length; i++) {
0878:                    Object item = array[i];
0879:                    if (i > 0) {
0880:                        buffer.append(arraySeparator);
0881:                    }
0882:                    if (item == null) {
0883:                        appendNullText(buffer, fieldName);
0884:
0885:                    } else {
0886:                        appendInternal(buffer, fieldName, item,
0887:                                arrayContentDetail);
0888:                    }
0889:                }
0890:                buffer.append(arrayEnd);
0891:            }
0892:
0893:            /**
0894:             * <p>Append to the <code>toString</code> the detail of an array type.</p>
0895:             *
0896:             * @param buffer  the <code>StringBuffer</code> to populate
0897:             * @param fieldName  the field name, typically not used as already appended
0898:             * @param array  the array to add to the <code>toString</code>,
0899:             *  not <code>null</code>
0900:             * @since 2.0
0901:             */
0902:            protected void reflectionAppendArrayDetail(StringBuffer buffer,
0903:                    String fieldName, Object array) {
0904:                buffer.append(arrayStart);
0905:                int length = Array.getLength(array);
0906:                for (int i = 0; i < length; i++) {
0907:                    Object item = Array.get(array, i);
0908:                    if (i > 0) {
0909:                        buffer.append(arraySeparator);
0910:                    }
0911:                    if (item == null) {
0912:                        appendNullText(buffer, fieldName);
0913:
0914:                    } else {
0915:                        appendInternal(buffer, fieldName, item,
0916:                                arrayContentDetail);
0917:                    }
0918:                }
0919:                buffer.append(arrayEnd);
0920:            }
0921:
0922:            /**
0923:             * <p>Append to the <code>toString</code> a summary of an
0924:             * <code>Object</code> array.</p>
0925:             *
0926:             * @param buffer  the <code>StringBuffer</code> to populate
0927:             * @param fieldName  the field name, typically not used as already appended
0928:             * @param array  the array to add to the <code>toString</code>,
0929:             *  not <code>null</code>
0930:             */
0931:            protected void appendSummary(StringBuffer buffer, String fieldName,
0932:                    Object[] array) {
0933:                appendSummarySize(buffer, fieldName, array.length);
0934:            }
0935:
0936:            //----------------------------------------------------------------------------
0937:
0938:            /**
0939:             * <p>Append to the <code>toString</code> a <code>long</code>
0940:             * array.</p>
0941:             *
0942:             * @param buffer  the <code>StringBuffer</code> to populate
0943:             * @param fieldName  the field name
0944:             * @param array  the array to add to the <code>toString</code>
0945:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
0946:             *  for summary info, <code>null</code> for style decides
0947:             */
0948:            public void append(StringBuffer buffer, String fieldName,
0949:                    long[] array, Boolean fullDetail) {
0950:                appendFieldStart(buffer, fieldName);
0951:
0952:                if (array == null) {
0953:                    appendNullText(buffer, fieldName);
0954:
0955:                } else if (isFullDetail(fullDetail)) {
0956:                    appendDetail(buffer, fieldName, array);
0957:
0958:                } else {
0959:                    appendSummary(buffer, fieldName, array);
0960:                }
0961:
0962:                appendFieldEnd(buffer, fieldName);
0963:            }
0964:
0965:            /**
0966:             * <p>Append to the <code>toString</code> the detail of a
0967:             * <code>long</code> array.</p>
0968:             *
0969:             * @param buffer  the <code>StringBuffer</code> to populate
0970:             * @param fieldName  the field name, typically not used as already appended
0971:             * @param array  the array to add to the <code>toString</code>,
0972:             *  not <code>null</code>
0973:             */
0974:            protected void appendDetail(StringBuffer buffer, String fieldName,
0975:                    long[] array) {
0976:                buffer.append(arrayStart);
0977:                for (int i = 0; i < array.length; i++) {
0978:                    if (i > 0) {
0979:                        buffer.append(arraySeparator);
0980:                    }
0981:                    appendDetail(buffer, fieldName, array[i]);
0982:                }
0983:                buffer.append(arrayEnd);
0984:            }
0985:
0986:            /**
0987:             * <p>Append to the <code>toString</code> a summary of a
0988:             * <code>long</code> array.</p>
0989:             *
0990:             * @param buffer  the <code>StringBuffer</code> to populate
0991:             * @param fieldName  the field name, typically not used as already appended
0992:             * @param array  the array to add to the <code>toString</code>,
0993:             *  not <code>null</code>
0994:             */
0995:            protected void appendSummary(StringBuffer buffer, String fieldName,
0996:                    long[] array) {
0997:                appendSummarySize(buffer, fieldName, array.length);
0998:            }
0999:
1000:            //----------------------------------------------------------------------------
1001:
1002:            /**
1003:             * <p>Append to the <code>toString</code> an <code>int</code>
1004:             * array.</p>
1005:             *
1006:             * @param buffer  the <code>StringBuffer</code> to populate
1007:             * @param fieldName  the field name
1008:             * @param array  the array to add to the <code>toString</code>
1009:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1010:             *  for summary info, <code>null</code> for style decides
1011:             */
1012:            public void append(StringBuffer buffer, String fieldName,
1013:                    int[] array, Boolean fullDetail) {
1014:                appendFieldStart(buffer, fieldName);
1015:
1016:                if (array == null) {
1017:                    appendNullText(buffer, fieldName);
1018:
1019:                } else if (isFullDetail(fullDetail)) {
1020:                    appendDetail(buffer, fieldName, array);
1021:
1022:                } else {
1023:                    appendSummary(buffer, fieldName, array);
1024:                }
1025:
1026:                appendFieldEnd(buffer, fieldName);
1027:            }
1028:
1029:            /**
1030:             * <p>Append to the <code>toString</code> the detail of an
1031:             * <code>int</code> array.</p>
1032:             *
1033:             * @param buffer  the <code>StringBuffer</code> to populate
1034:             * @param fieldName  the field name, typically not used as already appended
1035:             * @param array  the array to add to the <code>toString</code>,
1036:             *  not <code>null</code>
1037:             */
1038:            protected void appendDetail(StringBuffer buffer, String fieldName,
1039:                    int[] array) {
1040:                buffer.append(arrayStart);
1041:                for (int i = 0; i < array.length; i++) {
1042:                    if (i > 0) {
1043:                        buffer.append(arraySeparator);
1044:                    }
1045:                    appendDetail(buffer, fieldName, array[i]);
1046:                }
1047:                buffer.append(arrayEnd);
1048:            }
1049:
1050:            /**
1051:             * <p>Append to the <code>toString</code> a summary of an
1052:             * <code>int</code> array.</p>
1053:             *
1054:             * @param buffer  the <code>StringBuffer</code> to populate
1055:             * @param fieldName  the field name, typically not used as already appended
1056:             * @param array  the array to add to the <code>toString</code>,
1057:             *  not <code>null</code>
1058:             */
1059:            protected void appendSummary(StringBuffer buffer, String fieldName,
1060:                    int[] array) {
1061:                appendSummarySize(buffer, fieldName, array.length);
1062:            }
1063:
1064:            //----------------------------------------------------------------------------
1065:
1066:            /**
1067:             * <p>Append to the <code>toString</code> a <code>short</code>
1068:             * array.</p>
1069:             *
1070:             * @param buffer  the <code>StringBuffer</code> to populate
1071:             * @param fieldName  the field name
1072:             * @param array  the array to add to the <code>toString</code>
1073:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1074:             *  for summary info, <code>null</code> for style decides
1075:             */
1076:            public void append(StringBuffer buffer, String fieldName,
1077:                    short[] array, Boolean fullDetail) {
1078:                appendFieldStart(buffer, fieldName);
1079:
1080:                if (array == null) {
1081:                    appendNullText(buffer, fieldName);
1082:
1083:                } else if (isFullDetail(fullDetail)) {
1084:                    appendDetail(buffer, fieldName, array);
1085:
1086:                } else {
1087:                    appendSummary(buffer, fieldName, array);
1088:                }
1089:
1090:                appendFieldEnd(buffer, fieldName);
1091:            }
1092:
1093:            /**
1094:             * <p>Append to the <code>toString</code> the detail of a
1095:             * <code>short</code> array.</p>
1096:             *
1097:             * @param buffer  the <code>StringBuffer</code> to populate
1098:             * @param fieldName  the field name, typically not used as already appended
1099:             * @param array  the array to add to the <code>toString</code>,
1100:             *  not <code>null</code>
1101:             */
1102:            protected void appendDetail(StringBuffer buffer, String fieldName,
1103:                    short[] array) {
1104:                buffer.append(arrayStart);
1105:                for (int i = 0; i < array.length; i++) {
1106:                    if (i > 0) {
1107:                        buffer.append(arraySeparator);
1108:                    }
1109:                    appendDetail(buffer, fieldName, array[i]);
1110:                }
1111:                buffer.append(arrayEnd);
1112:            }
1113:
1114:            /**
1115:             * <p>Append to the <code>toString</code> a summary of a
1116:             * <code>short</code> array.</p>
1117:             *
1118:             * @param buffer  the <code>StringBuffer</code> to populate
1119:             * @param fieldName  the field name, typically not used as already appended
1120:             * @param array  the array to add to the <code>toString</code>,
1121:             *  not <code>null</code>
1122:             */
1123:            protected void appendSummary(StringBuffer buffer, String fieldName,
1124:                    short[] array) {
1125:                appendSummarySize(buffer, fieldName, array.length);
1126:            }
1127:
1128:            //----------------------------------------------------------------------------
1129:
1130:            /**
1131:             * <p>Append to the <code>toString</code> a <code>byte</code>
1132:             * array.</p>
1133:             *
1134:             * @param buffer  the <code>StringBuffer</code> to populate
1135:             * @param fieldName  the field name
1136:             * @param array  the array to add to the <code>toString</code>
1137:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1138:             *  for summary info, <code>null</code> for style decides
1139:             */
1140:            public void append(StringBuffer buffer, String fieldName,
1141:                    byte[] array, Boolean fullDetail) {
1142:                appendFieldStart(buffer, fieldName);
1143:
1144:                if (array == null) {
1145:                    appendNullText(buffer, fieldName);
1146:
1147:                } else if (isFullDetail(fullDetail)) {
1148:                    appendDetail(buffer, fieldName, array);
1149:
1150:                } else {
1151:                    appendSummary(buffer, fieldName, array);
1152:                }
1153:
1154:                appendFieldEnd(buffer, fieldName);
1155:            }
1156:
1157:            /**
1158:             * <p>Append to the <code>toString</code> the detail of a
1159:             * <code>byte</code> array.</p>
1160:             *
1161:             * @param buffer  the <code>StringBuffer</code> to populate
1162:             * @param fieldName  the field name, typically not used as already appended
1163:             * @param array  the array to add to the <code>toString</code>,
1164:             *  not <code>null</code>
1165:             */
1166:            protected void appendDetail(StringBuffer buffer, String fieldName,
1167:                    byte[] array) {
1168:                buffer.append(arrayStart);
1169:                for (int i = 0; i < array.length; i++) {
1170:                    if (i > 0) {
1171:                        buffer.append(arraySeparator);
1172:                    }
1173:                    appendDetail(buffer, fieldName, array[i]);
1174:                }
1175:                buffer.append(arrayEnd);
1176:            }
1177:
1178:            /**
1179:             * <p>Append to the <code>toString</code> a summary of a
1180:             * <code>byte</code> array.</p>
1181:             *
1182:             * @param buffer  the <code>StringBuffer</code> to populate
1183:             * @param fieldName  the field name, typically not used as already appended
1184:             * @param array  the array to add to the <code>toString</code>,
1185:             *  not <code>null</code>
1186:             */
1187:            protected void appendSummary(StringBuffer buffer, String fieldName,
1188:                    byte[] array) {
1189:                appendSummarySize(buffer, fieldName, array.length);
1190:            }
1191:
1192:            //----------------------------------------------------------------------------
1193:
1194:            /**
1195:             * <p>Append to the <code>toString</code> a <code>char</code>
1196:             * array.</p>
1197:             *
1198:             * @param buffer  the <code>StringBuffer</code> to populate
1199:             * @param fieldName  the field name
1200:             * @param array  the array to add to the <code>toString</code>
1201:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1202:             *  for summary info, <code>null</code> for style decides
1203:             */
1204:            public void append(StringBuffer buffer, String fieldName,
1205:                    char[] array, Boolean fullDetail) {
1206:                appendFieldStart(buffer, fieldName);
1207:
1208:                if (array == null) {
1209:                    appendNullText(buffer, fieldName);
1210:
1211:                } else if (isFullDetail(fullDetail)) {
1212:                    appendDetail(buffer, fieldName, array);
1213:
1214:                } else {
1215:                    appendSummary(buffer, fieldName, array);
1216:                }
1217:
1218:                appendFieldEnd(buffer, fieldName);
1219:            }
1220:
1221:            /**
1222:             * <p>Append to the <code>toString</code> the detail of a
1223:             * <code>char</code> array.</p>
1224:             *
1225:             * @param buffer  the <code>StringBuffer</code> to populate
1226:             * @param fieldName  the field name, typically not used as already appended
1227:             * @param array  the array to add to the <code>toString</code>,
1228:             *  not <code>null</code>
1229:             */
1230:            protected void appendDetail(StringBuffer buffer, String fieldName,
1231:                    char[] array) {
1232:                buffer.append(arrayStart);
1233:                for (int i = 0; i < array.length; i++) {
1234:                    if (i > 0) {
1235:                        buffer.append(arraySeparator);
1236:                    }
1237:                    appendDetail(buffer, fieldName, array[i]);
1238:                }
1239:                buffer.append(arrayEnd);
1240:            }
1241:
1242:            /**
1243:             * <p>Append to the <code>toString</code> a summary of a
1244:             * <code>char</code> array.</p>
1245:             *
1246:             * @param buffer  the <code>StringBuffer</code> to populate
1247:             * @param fieldName  the field name, typically not used as already appended
1248:             * @param array  the array to add to the <code>toString</code>,
1249:             *  not <code>null</code>
1250:             */
1251:            protected void appendSummary(StringBuffer buffer, String fieldName,
1252:                    char[] array) {
1253:                appendSummarySize(buffer, fieldName, array.length);
1254:            }
1255:
1256:            //----------------------------------------------------------------------------
1257:
1258:            /**
1259:             * <p>Append to the <code>toString</code> a <code>double</code>
1260:             * array.</p>
1261:             *
1262:             * @param buffer  the <code>StringBuffer</code> to populate
1263:             * @param fieldName  the field name
1264:             * @param array  the array to add to the toString
1265:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1266:             *  for summary info, <code>null</code> for style decides
1267:             */
1268:            public void append(StringBuffer buffer, String fieldName,
1269:                    double[] array, Boolean fullDetail) {
1270:                appendFieldStart(buffer, fieldName);
1271:
1272:                if (array == null) {
1273:                    appendNullText(buffer, fieldName);
1274:
1275:                } else if (isFullDetail(fullDetail)) {
1276:                    appendDetail(buffer, fieldName, array);
1277:
1278:                } else {
1279:                    appendSummary(buffer, fieldName, array);
1280:                }
1281:
1282:                appendFieldEnd(buffer, fieldName);
1283:            }
1284:
1285:            /**
1286:             * <p>Append to the <code>toString</code> the detail of a
1287:             * <code>double</code> array.</p>
1288:             *
1289:             * @param buffer  the <code>StringBuffer</code> to populate
1290:             * @param fieldName  the field name, typically not used as already appended
1291:             * @param array  the array to add to the <code>toString</code>,
1292:             *  not <code>null</code>
1293:             */
1294:            protected void appendDetail(StringBuffer buffer, String fieldName,
1295:                    double[] array) {
1296:                buffer.append(arrayStart);
1297:                for (int i = 0; i < array.length; i++) {
1298:                    if (i > 0) {
1299:                        buffer.append(arraySeparator);
1300:                    }
1301:                    appendDetail(buffer, fieldName, array[i]);
1302:                }
1303:                buffer.append(arrayEnd);
1304:            }
1305:
1306:            /**
1307:             * <p>Append to the <code>toString</code> a summary of a
1308:             * <code>double</code> array.</p>
1309:             *
1310:             * @param buffer  the <code>StringBuffer</code> to populate
1311:             * @param fieldName  the field name, typically not used as already appended
1312:             * @param array  the array to add to the <code>toString</code>,
1313:             *  not <code>null</code>
1314:             */
1315:            protected void appendSummary(StringBuffer buffer, String fieldName,
1316:                    double[] array) {
1317:                appendSummarySize(buffer, fieldName, array.length);
1318:            }
1319:
1320:            //----------------------------------------------------------------------------
1321:
1322:            /**
1323:             * <p>Append to the <code>toString</code> a <code>float</code>
1324:             * array.</p>
1325:             *
1326:             * @param buffer  the <code>StringBuffer</code> to populate
1327:             * @param fieldName  the field name
1328:             * @param array  the array to add to the toString
1329:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1330:             *  for summary info, <code>null</code> for style decides
1331:             */
1332:            public void append(StringBuffer buffer, String fieldName,
1333:                    float[] array, Boolean fullDetail) {
1334:                appendFieldStart(buffer, fieldName);
1335:
1336:                if (array == null) {
1337:                    appendNullText(buffer, fieldName);
1338:
1339:                } else if (isFullDetail(fullDetail)) {
1340:                    appendDetail(buffer, fieldName, array);
1341:
1342:                } else {
1343:                    appendSummary(buffer, fieldName, array);
1344:                }
1345:
1346:                appendFieldEnd(buffer, fieldName);
1347:            }
1348:
1349:            /**
1350:             * <p>Append to the <code>toString</code> the detail of a
1351:             * <code>float</code> array.</p>
1352:             *
1353:             * @param buffer  the <code>StringBuffer</code> to populate
1354:             * @param fieldName  the field name, typically not used as already appended
1355:             * @param array  the array to add to the <code>toString</code>,
1356:             *  not <code>null</code>
1357:             */
1358:            protected void appendDetail(StringBuffer buffer, String fieldName,
1359:                    float[] array) {
1360:                buffer.append(arrayStart);
1361:                for (int i = 0; i < array.length; i++) {
1362:                    if (i > 0) {
1363:                        buffer.append(arraySeparator);
1364:                    }
1365:                    appendDetail(buffer, fieldName, array[i]);
1366:                }
1367:                buffer.append(arrayEnd);
1368:            }
1369:
1370:            /**
1371:             * <p>Append to the <code>toString</code> a summary of a
1372:             * <code>float</code> array.</p>
1373:             *
1374:             * @param buffer  the <code>StringBuffer</code> to populate
1375:             * @param fieldName  the field name, typically not used as already appended
1376:             * @param array  the array to add to the <code>toString</code>,
1377:             *  not <code>null</code>
1378:             */
1379:            protected void appendSummary(StringBuffer buffer, String fieldName,
1380:                    float[] array) {
1381:                appendSummarySize(buffer, fieldName, array.length);
1382:            }
1383:
1384:            //----------------------------------------------------------------------------
1385:
1386:            /**
1387:             * <p>Append to the <code>toString</code> a <code>boolean</code>
1388:             * array.</p>
1389:             *
1390:             * @param buffer  the <code>StringBuffer</code> to populate
1391:             * @param fieldName  the field name
1392:             * @param array  the array to add to the toString
1393:             * @param fullDetail  <code>true</code> for detail, <code>false</code>
1394:             *  for summary info, <code>null</code> for style decides
1395:             */
1396:            public void append(StringBuffer buffer, String fieldName,
1397:                    boolean[] array, Boolean fullDetail) {
1398:                appendFieldStart(buffer, fieldName);
1399:
1400:                if (array == null) {
1401:                    appendNullText(buffer, fieldName);
1402:
1403:                } else if (isFullDetail(fullDetail)) {
1404:                    appendDetail(buffer, fieldName, array);
1405:
1406:                } else {
1407:                    appendSummary(buffer, fieldName, array);
1408:                }
1409:
1410:                appendFieldEnd(buffer, fieldName);
1411:            }
1412:
1413:            /**
1414:             * <p>Append to the <code>toString</code> the detail of a
1415:             * <code>boolean</code> array.</p>
1416:             *
1417:             * @param buffer  the <code>StringBuffer</code> to populate
1418:             * @param fieldName  the field name, typically not used as already appended
1419:             * @param array  the array to add to the <code>toString</code>,
1420:             *  not <code>null</code>
1421:             */
1422:            protected void appendDetail(StringBuffer buffer, String fieldName,
1423:                    boolean[] array) {
1424:                buffer.append(arrayStart);
1425:                for (int i = 0; i < array.length; i++) {
1426:                    if (i > 0) {
1427:                        buffer.append(arraySeparator);
1428:                    }
1429:                    appendDetail(buffer, fieldName, array[i]);
1430:                }
1431:                buffer.append(arrayEnd);
1432:            }
1433:
1434:            /**
1435:             * <p>Append to the <code>toString</code> a summary of a
1436:             * <code>boolean</code> array.</p>
1437:             *
1438:             * @param buffer  the <code>StringBuffer</code> to populate
1439:             * @param fieldName  the field name, typically not used as already appended
1440:             * @param array  the array to add to the <code>toString</code>,
1441:             *  not <code>null</code>
1442:             */
1443:            protected void appendSummary(StringBuffer buffer, String fieldName,
1444:                    boolean[] array) {
1445:                appendSummarySize(buffer, fieldName, array.length);
1446:            }
1447:
1448:            //----------------------------------------------------------------------------
1449:
1450:            /**
1451:             * <p>Append to the <code>toString</code> the class name.</p>
1452:             * 
1453:             * @param buffer  the <code>StringBuffer</code> to populate
1454:             * @param object  the <code>Object</code> whose name to output
1455:             */
1456:            protected void appendClassName(StringBuffer buffer, Object object) {
1457:                if (useClassName && object != null) {
1458:                    register(object);
1459:                    if (useShortClassName) {
1460:                        buffer.append(getShortClassName(object.getClass()));
1461:                    } else {
1462:                        buffer.append(object.getClass().getName());
1463:                    }
1464:                }
1465:            }
1466:
1467:            /**
1468:             * <p>Append the {@link System#identityHashCode(java.lang.Object)}.</p>
1469:             * 
1470:             * @param buffer  the <code>StringBuffer</code> to populate
1471:             * @param object  the <code>Object</code> whose id to output
1472:             */
1473:            protected void appendIdentityHashCode(StringBuffer buffer,
1474:                    Object object) {
1475:                if (this .isUseIdentityHashCode() && object != null) {
1476:                    register(object);
1477:                    buffer.append('@');
1478:                    buffer.append(Integer.toHexString(System
1479:                            .identityHashCode(object)));
1480:                }
1481:            }
1482:
1483:            /**
1484:             * <p>Append to the <code>toString</code> the content start.</p>
1485:             * 
1486:             * @param buffer  the <code>StringBuffer</code> to populate
1487:             */
1488:            protected void appendContentStart(StringBuffer buffer) {
1489:                buffer.append(contentStart);
1490:            }
1491:
1492:            /**
1493:             * <p>Append to the <code>toString</code> the content end.</p>
1494:             * 
1495:             * @param buffer  the <code>StringBuffer</code> to populate
1496:             */
1497:            protected void appendContentEnd(StringBuffer buffer) {
1498:                buffer.append(contentEnd);
1499:            }
1500:
1501:            /**
1502:             * <p>Append to the <code>toString</code> an indicator for <code>null</code>.</p>
1503:             *
1504:             * <p>The default indicator is <code>'&lt;null&gt;'</code>.</p>
1505:             * 
1506:             * @param buffer  the <code>StringBuffer</code> to populate
1507:             * @param fieldName  the field name, typically not used as already appended
1508:             */
1509:            protected void appendNullText(StringBuffer buffer, String fieldName) {
1510:                buffer.append(nullText);
1511:            }
1512:
1513:            /**
1514:             * <p>Append to the <code>toString</code> the field separator.</p>
1515:             * 
1516:             * @param buffer  the <code>StringBuffer</code> to populate
1517:             */
1518:            protected void appendFieldSeparator(StringBuffer buffer) {
1519:                buffer.append(fieldSeparator);
1520:            }
1521:
1522:            /**
1523:             * <p>Append to the <code>toString</code> the field start.</p>
1524:             * 
1525:             * @param buffer  the <code>StringBuffer</code> to populate
1526:             * @param fieldName  the field name
1527:             */
1528:            protected void appendFieldStart(StringBuffer buffer,
1529:                    String fieldName) {
1530:                if (useFieldNames && fieldName != null) {
1531:                    buffer.append(fieldName);
1532:                    buffer.append(fieldNameValueSeparator);
1533:                }
1534:            }
1535:
1536:            /**
1537:             * <p>Append to the <code>toString<code> the field end.</p>
1538:             * 
1539:             * @param buffer  the <code>StringBuffer</code> to populate
1540:             * @param fieldName  the field name, typically not used as already appended
1541:             */
1542:            protected void appendFieldEnd(StringBuffer buffer, String fieldName) {
1543:                appendFieldSeparator(buffer);
1544:            }
1545:
1546:            /**
1547:             * <p>Append to the <code>toString</code> a size summary.</p>
1548:             *
1549:             * <p>The size summary is used to summarize the contents of
1550:             * <code>Collections</code>, <code>Maps</code> and arrays.</p>
1551:             *
1552:             * <p>The output consists of a prefix, the passed in size
1553:             * and a suffix.</p>
1554:             *
1555:             * <p>The default format is <code>'&lt;size=n&gt;'<code>.</p>
1556:             *
1557:             * @param buffer  the <code>StringBuffer</code> to populate
1558:             * @param fieldName  the field name, typically not used as already appended
1559:             * @param size  the size to append
1560:             */
1561:            protected void appendSummarySize(StringBuffer buffer,
1562:                    String fieldName, int size) {
1563:                buffer.append(sizeStartText);
1564:                buffer.append(size);
1565:                buffer.append(sizeEndText);
1566:            }
1567:
1568:            /**
1569:             * <p>Is this field to be output in full detail.</p>
1570:             *
1571:             * <p>This method converts a detail request into a detail level.
1572:             * The calling code may request full detail (<code>true</code>),
1573:             * but a subclass might ignore that and always return
1574:             * <code>false</code>. The calling code may pass in
1575:             * <code>null</code> indicating that it doesn't care about
1576:             * the detail level. In this case the default detail level is
1577:             * used.</p>
1578:             * 
1579:             * @param fullDetailRequest  the detail level requested
1580:             * @return whether full detail is to be shown
1581:             */
1582:            protected boolean isFullDetail(Boolean fullDetailRequest) {
1583:                if (fullDetailRequest == null) {
1584:                    return defaultFullDetail;
1585:                }
1586:                return fullDetailRequest.booleanValue();
1587:            }
1588:
1589:            /**
1590:             * <p>Gets the short class name for a class.</p>
1591:             *
1592:             * <p>The short class name is the classname excluding
1593:             * the package name.</p>
1594:             *
1595:             * @param cls  the <code>Class</code> to get the short name of
1596:             * @return the short name
1597:             */
1598:            protected String getShortClassName(Class cls) {
1599:                return ClassUtils.getShortClassName(cls);
1600:            }
1601:
1602:            // Setters and getters for the customizable parts of the style
1603:            // These methods are not expected to be overridden, except to make public
1604:            // (They are not public so that immutable subclasses can be written)
1605:            //---------------------------------------------------------------------
1606:
1607:            /**
1608:             * <p>Gets whether to use the class name.</p>
1609:             *
1610:             * @return the current useClassName flag
1611:             */
1612:            protected boolean isUseClassName() {
1613:                return useClassName;
1614:            }
1615:
1616:            /**
1617:             * <p>Sets whether to use the class name.</p>
1618:             *
1619:             * @param useClassName  the new useClassName flag
1620:             */
1621:            protected void setUseClassName(boolean useClassName) {
1622:                this .useClassName = useClassName;
1623:            }
1624:
1625:            //---------------------------------------------------------------------
1626:
1627:            /**
1628:             * <p>Gets whether to output short or long class names.</p>
1629:             *
1630:             * @return the current useShortClassName flag
1631:             * @since 2.0
1632:             */
1633:            protected boolean isUseShortClassName() {
1634:                return useShortClassName;
1635:            }
1636:
1637:            /**
1638:             * <p>Gets whether to output short or long class names.</p>
1639:             *
1640:             * @return the current shortClassName flag
1641:             * @deprecated Use {@link #isUseShortClassName()}
1642:             *             Method will be removed in Commons Lang 3.0.
1643:             */
1644:            protected boolean isShortClassName() {
1645:                return useShortClassName;
1646:            }
1647:
1648:            /**
1649:             * <p>Sets whether to output short or long class names.</p>
1650:             *
1651:             * @param useShortClassName  the new useShortClassName flag
1652:             * @since 2.0
1653:             */
1654:            protected void setUseShortClassName(boolean useShortClassName) {
1655:                this .useShortClassName = useShortClassName;
1656:            }
1657:
1658:            /**
1659:             * <p>Sets whether to output short or long class names.</p>
1660:             *
1661:             * @param shortClassName  the new shortClassName flag
1662:             * @deprecated Use {@link #setUseShortClassName(boolean)}
1663:             *             Method will be removed in Commons Lang 3.0.
1664:             */
1665:            protected void setShortClassName(boolean shortClassName) {
1666:                this .useShortClassName = shortClassName;
1667:            }
1668:
1669:            //---------------------------------------------------------------------
1670:
1671:            /**
1672:             * <p>Gets whether to use the identity hash code.</p>
1673:             *
1674:             * @return the current useIdentityHashCode flag
1675:             */
1676:            protected boolean isUseIdentityHashCode() {
1677:                return useIdentityHashCode;
1678:            }
1679:
1680:            /**
1681:             * <p>Sets whether to use the identity hash code.</p>
1682:             *
1683:             * @param useIdentityHashCode  the new useIdentityHashCode flag
1684:             */
1685:            protected void setUseIdentityHashCode(boolean useIdentityHashCode) {
1686:                this .useIdentityHashCode = useIdentityHashCode;
1687:            }
1688:
1689:            //---------------------------------------------------------------------
1690:
1691:            /**
1692:             * <p>Gets whether to use the field names passed in.</p>
1693:             *
1694:             * @return the current useFieldNames flag
1695:             */
1696:            protected boolean isUseFieldNames() {
1697:                return useFieldNames;
1698:            }
1699:
1700:            /**
1701:             * <p>Sets whether to use the field names passed in.</p>
1702:             *
1703:             * @param useFieldNames  the new useFieldNames flag
1704:             */
1705:            protected void setUseFieldNames(boolean useFieldNames) {
1706:                this .useFieldNames = useFieldNames;
1707:            }
1708:
1709:            //---------------------------------------------------------------------
1710:
1711:            /**
1712:             * <p>Gets whether to use full detail when the caller doesn't
1713:             * specify.</p>
1714:             *
1715:             * @return the current defaultFullDetail flag
1716:             */
1717:            protected boolean isDefaultFullDetail() {
1718:                return defaultFullDetail;
1719:            }
1720:
1721:            /**
1722:             * <p>Sets whether to use full detail when the caller doesn't
1723:             * specify.</p>
1724:             *
1725:             * @param defaultFullDetail  the new defaultFullDetail flag
1726:             */
1727:            protected void setDefaultFullDetail(boolean defaultFullDetail) {
1728:                this .defaultFullDetail = defaultFullDetail;
1729:            }
1730:
1731:            //---------------------------------------------------------------------
1732:
1733:            /**
1734:             * <p>Gets whether to output array content detail.</p>
1735:             *
1736:             * @return the current array content detail setting
1737:             */
1738:            protected boolean isArrayContentDetail() {
1739:                return arrayContentDetail;
1740:            }
1741:
1742:            /**
1743:             * <p>Sets whether to output array content detail.</p>
1744:             *
1745:             * @param arrayContentDetail  the new arrayContentDetail flag
1746:             */
1747:            protected void setArrayContentDetail(boolean arrayContentDetail) {
1748:                this .arrayContentDetail = arrayContentDetail;
1749:            }
1750:
1751:            //---------------------------------------------------------------------
1752:
1753:            /**
1754:             * <p>Gets the array start text.</p>
1755:             *
1756:             * @return the current array start text
1757:             */
1758:            protected String getArrayStart() {
1759:                return arrayStart;
1760:            }
1761:
1762:            /**
1763:             * <p>Sets the array start text.</p>
1764:             *
1765:             * <p><code>null</code> is accepted, but will be converted to
1766:             * an empty String.</p>
1767:             *
1768:             * @param arrayStart  the new array start text
1769:             */
1770:            protected void setArrayStart(String arrayStart) {
1771:                if (arrayStart == null) {
1772:                    arrayStart = "";
1773:                }
1774:                this .arrayStart = arrayStart;
1775:            }
1776:
1777:            //---------------------------------------------------------------------
1778:
1779:            /**
1780:             * <p>Gets the array end text.</p>
1781:             *
1782:             * @return the current array end text
1783:             */
1784:            protected String getArrayEnd() {
1785:                return arrayEnd;
1786:            }
1787:
1788:            /**
1789:             * <p>Sets the array end text.</p>
1790:             *
1791:             * <p><code>null</code> is accepted, but will be converted to
1792:             * an empty String.</p>
1793:             *
1794:             * @param arrayEnd  the new array end text
1795:             */
1796:            protected void setArrayEnd(String arrayEnd) {
1797:                if (arrayEnd == null) {
1798:                    arrayEnd = "";
1799:                }
1800:                this .arrayEnd = arrayEnd;
1801:            }
1802:
1803:            //---------------------------------------------------------------------
1804:
1805:            /**
1806:             * <p>Gets the array separator text.</p>
1807:             *
1808:             * @return the current array separator text
1809:             */
1810:            protected String getArraySeparator() {
1811:                return arraySeparator;
1812:            }
1813:
1814:            /**
1815:             * <p>Sets the array separator text.</p>
1816:             *
1817:             * <p><code>null</code> is accepted, but will be converted to
1818:             * an empty String.</p>
1819:             *
1820:             * @param arraySeparator  the new array separator text
1821:             */
1822:            protected void setArraySeparator(String arraySeparator) {
1823:                if (arraySeparator == null) {
1824:                    arraySeparator = "";
1825:                }
1826:                this .arraySeparator = arraySeparator;
1827:            }
1828:
1829:            //---------------------------------------------------------------------
1830:
1831:            /**
1832:             * <p>Gets the content start text.</p>
1833:             *
1834:             * @return the current content start text
1835:             */
1836:            protected String getContentStart() {
1837:                return contentStart;
1838:            }
1839:
1840:            /**
1841:             * <p>Sets the content start text.</p>
1842:             *
1843:             * <p><code>null</code> is accepted, but will be converted to
1844:             * an empty String.</p>
1845:             *
1846:             * @param contentStart  the new content start text
1847:             */
1848:            protected void setContentStart(String contentStart) {
1849:                if (contentStart == null) {
1850:                    contentStart = "";
1851:                }
1852:                this .contentStart = contentStart;
1853:            }
1854:
1855:            //---------------------------------------------------------------------
1856:
1857:            /**
1858:             * <p>Gets the content end text.</p>
1859:             *
1860:             * @return the current content end text
1861:             */
1862:            protected String getContentEnd() {
1863:                return contentEnd;
1864:            }
1865:
1866:            /**
1867:             * <p>Sets the content end text.</p>
1868:             *
1869:             * <p><code>null</code> is accepted, but will be converted to
1870:             * an empty String.</p>
1871:             *
1872:             * @param contentEnd  the new content end text
1873:             */
1874:            protected void setContentEnd(String contentEnd) {
1875:                if (contentEnd == null) {
1876:                    contentEnd = "";
1877:                }
1878:                this .contentEnd = contentEnd;
1879:            }
1880:
1881:            //---------------------------------------------------------------------
1882:
1883:            /**
1884:             * <p>Gets the field name value separator text.</p>
1885:             *
1886:             * @return the current field name value separator text
1887:             */
1888:            protected String getFieldNameValueSeparator() {
1889:                return fieldNameValueSeparator;
1890:            }
1891:
1892:            /**
1893:             * <p>Sets the field name value separator text.</p>
1894:             *
1895:             * <p><code>null</code> is accepted, but will be converted to
1896:             * an empty String.</p>
1897:             *
1898:             * @param fieldNameValueSeparator  the new field name value separator text
1899:             */
1900:            protected void setFieldNameValueSeparator(
1901:                    String fieldNameValueSeparator) {
1902:                if (fieldNameValueSeparator == null) {
1903:                    fieldNameValueSeparator = "";
1904:                }
1905:                this .fieldNameValueSeparator = fieldNameValueSeparator;
1906:            }
1907:
1908:            //---------------------------------------------------------------------
1909:
1910:            /**
1911:             * <p>Gets the field separator text.</p>
1912:             *
1913:             * @return the current field separator text
1914:             */
1915:            protected String getFieldSeparator() {
1916:                return fieldSeparator;
1917:            }
1918:
1919:            /**
1920:             * <p>Sets the field separator text.</p>
1921:             *
1922:             * <p><code>null</code> is accepted, but will be converted to
1923:             * an empty String.</p>
1924:             *
1925:             * @param fieldSeparator  the new field separator text
1926:             */
1927:            protected void setFieldSeparator(String fieldSeparator) {
1928:                if (fieldSeparator == null) {
1929:                    fieldSeparator = "";
1930:                }
1931:                this .fieldSeparator = fieldSeparator;
1932:            }
1933:
1934:            //---------------------------------------------------------------------
1935:
1936:            /**
1937:             * <p>Gets whether the field separator should be added at the start 
1938:             * of each buffer.</p>
1939:             * 
1940:             * @return the fieldSeparatorAtStart flag
1941:             * @since 2.0
1942:             */
1943:            protected boolean isFieldSeparatorAtStart() {
1944:                return fieldSeparatorAtStart;
1945:            }
1946:
1947:            /**
1948:             * <p>Sets whether the field separator should be added at the start 
1949:             * of each buffer.</p>
1950:             * 
1951:             * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
1952:             * @since 2.0
1953:             */
1954:            protected void setFieldSeparatorAtStart(
1955:                    boolean fieldSeparatorAtStart) {
1956:                this .fieldSeparatorAtStart = fieldSeparatorAtStart;
1957:            }
1958:
1959:            //---------------------------------------------------------------------
1960:
1961:            /**
1962:             * <p>Gets whether the field separator should be added at the end 
1963:             * of each buffer.</p>
1964:             * 
1965:             * @return fieldSeparatorAtEnd flag
1966:             * @since 2.0
1967:             */
1968:            protected boolean isFieldSeparatorAtEnd() {
1969:                return fieldSeparatorAtEnd;
1970:            }
1971:
1972:            /**
1973:             * <p>Sets whether the field separator should be added at the end 
1974:             * of each buffer.</p>
1975:             * 
1976:             * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
1977:             * @since 2.0
1978:             */
1979:            protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
1980:                this .fieldSeparatorAtEnd = fieldSeparatorAtEnd;
1981:            }
1982:
1983:            //---------------------------------------------------------------------
1984:
1985:            /**
1986:             * <p>Gets the text to output when <code>null</code> found.</p>
1987:             *
1988:             * @return the current text to output when null found
1989:             */
1990:            protected String getNullText() {
1991:                return nullText;
1992:            }
1993:
1994:            /**
1995:             * <p>Sets the text to output when <code>null</code> found.</p>
1996:             *
1997:             * <p><code>null</code> is accepted, but will be converted to
1998:             * an empty String.</p>
1999:             *
2000:             * @param nullText  the new text to output when null found
2001:             */
2002:            protected void setNullText(String nullText) {
2003:                if (nullText == null) {
2004:                    nullText = "";
2005:                }
2006:                this .nullText = nullText;
2007:            }
2008:
2009:            //---------------------------------------------------------------------
2010:
2011:            /**
2012:             * <p>Gets the start text to output when a <code>Collection</code>,
2013:             * <code>Map</code> or array size is output.</p>
2014:             *
2015:             * <p>This is output before the size value.</p>
2016:             *
2017:             * @return the current start of size text
2018:             */
2019:            protected String getSizeStartText() {
2020:                return sizeStartText;
2021:            }
2022:
2023:            /**
2024:             * <p>Sets the start text to output when a <code>Collection</code>,
2025:             * <code>Map</code> or array size is output.</p>
2026:             *
2027:             * <p>This is output before the size value.</p>
2028:             *
2029:             * <p><code>null</code> is accepted, but will be converted to
2030:             * an empty String.</p>
2031:             *
2032:             * @param sizeStartText  the new start of size text
2033:             */
2034:            protected void setSizeStartText(String sizeStartText) {
2035:                if (sizeStartText == null) {
2036:                    sizeStartText = "";
2037:                }
2038:                this .sizeStartText = sizeStartText;
2039:            }
2040:
2041:            //---------------------------------------------------------------------
2042:
2043:            /**
2044:             * <p>Gets the end text to output when a <code>Collection</code>,
2045:             * <code>Map</code> or array size is output.</p>
2046:             *
2047:             * <p>This is output after the size value.</p>
2048:             *
2049:             * @return the current end of size text
2050:             */
2051:            protected String getSizeEndText() {
2052:                return sizeEndText;
2053:            }
2054:
2055:            /**
2056:             * <p>Sets the end text to output when a <code>Collection</code>,
2057:             * <code>Map</code> or array size is output.</p>
2058:             *
2059:             * <p>This is output after the size value.</p>
2060:             *
2061:             * <p><code>null</code> is accepted, but will be converted to
2062:             * an empty String.</p>
2063:             *
2064:             * @param sizeEndText  the new end of size text
2065:             */
2066:            protected void setSizeEndText(String sizeEndText) {
2067:                if (sizeEndText == null) {
2068:                    sizeEndText = "";
2069:                }
2070:                this .sizeEndText = sizeEndText;
2071:            }
2072:
2073:            //---------------------------------------------------------------------
2074:
2075:            /**
2076:             * <p>Gets the start text to output when an <code>Object</code> is
2077:             * output in summary mode.</p>
2078:             *
2079:             * <p>This is output before the size value.</p>
2080:             *
2081:             * @return the current start of summary text
2082:             */
2083:            protected String getSummaryObjectStartText() {
2084:                return summaryObjectStartText;
2085:            }
2086:
2087:            /**
2088:             * <p>Sets the start text to output when an <code>Object</code> is
2089:             * output in summary mode.</p>
2090:             *
2091:             * <p>This is output before the size value.</p>
2092:             *
2093:             * <p><code>null</code> is accepted, but will be converted to
2094:             * an empty String.</p>
2095:             *
2096:             * @param summaryObjectStartText  the new start of summary text
2097:             */
2098:            protected void setSummaryObjectStartText(
2099:                    String summaryObjectStartText) {
2100:                if (summaryObjectStartText == null) {
2101:                    summaryObjectStartText = "";
2102:                }
2103:                this .summaryObjectStartText = summaryObjectStartText;
2104:            }
2105:
2106:            //---------------------------------------------------------------------
2107:
2108:            /**
2109:             * <p>Gets the end text to output when an <code>Object</code> is
2110:             * output in summary mode.</p>
2111:             *
2112:             * <p>This is output after the size value.</p>
2113:             *
2114:             * @return the current end of summary text
2115:             */
2116:            protected String getSummaryObjectEndText() {
2117:                return summaryObjectEndText;
2118:            }
2119:
2120:            /**
2121:             * <p>Sets the end text to output when an <code>Object</code> is
2122:             * output in summary mode.</p>
2123:             *
2124:             * <p>This is output after the size value.</p>
2125:             *
2126:             * <p><code>null</code> is accepted, but will be converted to
2127:             * an empty String.</p>
2128:             *
2129:             * @param summaryObjectEndText  the new end of summary text
2130:             */
2131:            protected void setSummaryObjectEndText(String summaryObjectEndText) {
2132:                if (summaryObjectEndText == null) {
2133:                    summaryObjectEndText = "";
2134:                }
2135:                this .summaryObjectEndText = summaryObjectEndText;
2136:            }
2137:
2138:            //----------------------------------------------------------------------------
2139:
2140:            /**
2141:             * <p>Default <code>ToStringStyle</code>.</p>
2142:             *
2143:             * <p>This is an inner class rather than using
2144:             * <code>StandardToStringStyle</code> to ensure its immutability.</p>
2145:             */
2146:            private static final class DefaultToStringStyle extends
2147:                    ToStringStyle {
2148:
2149:                /**
2150:                 * Required for serialization support.
2151:                 * 
2152:                 * @see java.io.Serializable
2153:                 */
2154:                private static final long serialVersionUID = 1L;
2155:
2156:                /**
2157:                 * <p>Constructor.</p>
2158:                 *
2159:                 * <p>Use the static constant rather than instantiating.</p>
2160:                 */
2161:                DefaultToStringStyle() {
2162:                    super ();
2163:                }
2164:
2165:                /**
2166:                 * <p>Ensure <code>Singleton</code> after serialization.</p>
2167:                 *
2168:                 * @return the singleton
2169:                 */
2170:                private Object readResolve() {
2171:                    return ToStringStyle.DEFAULT_STYLE;
2172:                }
2173:
2174:            }
2175:
2176:            //----------------------------------------------------------------------------
2177:
2178:            /**
2179:             * <p><code>ToStringStyle</code> that does not print out
2180:             * the field names.</p>
2181:             *
2182:             * <p>This is an inner class rather than using
2183:             * <code>StandardToStringStyle</code> to ensure its immutability.
2184:             */
2185:            private static final class NoFieldNameToStringStyle extends
2186:                    ToStringStyle {
2187:
2188:                private static final long serialVersionUID = 1L;
2189:
2190:                /**
2191:                 * <p>Constructor.</p>
2192:                 *
2193:                 * <p>Use the static constant rather than instantiating.</p>
2194:                 */
2195:                NoFieldNameToStringStyle() {
2196:                    super ();
2197:                    this .setUseFieldNames(false);
2198:                }
2199:
2200:                /**
2201:                 * <p>Ensure <code>Singleton</code> after serialization.</p>
2202:                 *
2203:                 * @return the singleton
2204:                 */
2205:                private Object readResolve() {
2206:                    return ToStringStyle.NO_FIELD_NAMES_STYLE;
2207:                }
2208:
2209:            }
2210:
2211:            //----------------------------------------------------------------------------
2212:
2213:            /**
2214:             * <p><code>ToStringStyle</code> that prints out the short
2215:             * class name and no identity hashcode.</p>
2216:             *
2217:             * <p>This is an inner class rather than using
2218:             * <code>StandardToStringStyle</code> to ensure its immutability.</p>
2219:             */
2220:            private static final class ShortPrefixToStringStyle extends
2221:                    ToStringStyle {
2222:
2223:                private static final long serialVersionUID = 1L;
2224:
2225:                /**
2226:                 * <p>Constructor.</p>
2227:                 *
2228:                 * <p>Use the static constant rather than instantiating.</p>
2229:                 */
2230:                ShortPrefixToStringStyle() {
2231:                    super ();
2232:                    this .setUseShortClassName(true);
2233:                    this .setUseIdentityHashCode(false);
2234:                }
2235:
2236:                /**
2237:                 * <p>Ensure <code>Singleton</ode> after serialization.</p>
2238:                 * @return the singleton
2239:                 */
2240:                private Object readResolve() {
2241:                    return ToStringStyle.SHORT_PREFIX_STYLE;
2242:                }
2243:
2244:            }
2245:
2246:            /**
2247:             * <p><code>ToStringStyle</code> that does not print out the
2248:             * classname, identity hashcode, content start or field name.</p>
2249:             *
2250:             * <p>This is an inner class rather than using
2251:             * <code>StandardToStringStyle</code> to ensure its immutability.</p>
2252:             */
2253:            private static final class SimpleToStringStyle extends
2254:                    ToStringStyle {
2255:
2256:                private static final long serialVersionUID = 1L;
2257:
2258:                /**
2259:                 * <p>Constructor.</p>
2260:                 *
2261:                 * <p>Use the static constant rather than instantiating.</p>
2262:                 */
2263:                SimpleToStringStyle() {
2264:                    super ();
2265:                    this .setUseClassName(false);
2266:                    this .setUseIdentityHashCode(false);
2267:                    this .setUseFieldNames(false);
2268:                    this .setContentStart("");
2269:                    this .setContentEnd("");
2270:                }
2271:
2272:                /**
2273:                 * <p>Ensure <code>Singleton</ode> after serialization.</p>
2274:                 * @return the singleton
2275:                 */
2276:                private Object readResolve() {
2277:                    return ToStringStyle.SIMPLE_STYLE;
2278:                }
2279:
2280:            }
2281:
2282:            //----------------------------------------------------------------------------
2283:
2284:            /**
2285:             * <p><code>ToStringStyle</code> that outputs on multiple lines.</p>
2286:             *
2287:             * <p>This is an inner class rather than using
2288:             * <code>StandardToStringStyle</code> to ensure its immutability.</p>
2289:             */
2290:            private static final class MultiLineToStringStyle extends
2291:                    ToStringStyle {
2292:
2293:                private static final long serialVersionUID = 1L;
2294:
2295:                /**
2296:                 * <p>Constructor.</p>
2297:                 *
2298:                 * <p>Use the static constant rather than instantiating.</p>
2299:                 */
2300:                MultiLineToStringStyle() {
2301:                    super ();
2302:                    this .setContentStart("[");
2303:                    this .setFieldSeparator(SystemUtils.LINE_SEPARATOR + "  ");
2304:                    this .setFieldSeparatorAtStart(true);
2305:                    this .setContentEnd(SystemUtils.LINE_SEPARATOR + "]");
2306:                }
2307:
2308:                /**
2309:                 * <p>Ensure <code>Singleton</code> after serialization.</p>
2310:                 *
2311:                 * @return the singleton
2312:                 */
2313:                private Object readResolve() {
2314:                    return ToStringStyle.MULTI_LINE_STYLE;
2315:                }
2316:
2317:            }
2318:
2319:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.