You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gg...@apache.org on 2003/07/21 21:34:11 UTC

cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/builder ToStringStyle.java

ggregory    2003/07/21 12:34:11

  Modified:    lang/src/java/org/apache/commons/lang/builder
                        ToStringStyle.java
  Log:
  Missing '.' caused the Javadoc warning:
    [javadoc] Generating C:\cvs-store\apache.org\jakarta\commons\lang\dist\docs\api\index-all.html...
    [javadoc] "<p>Append to the <code>toString</code> a <code>Date</code>
    [javadoc]  value, using the optional <code>DateFormat</code>"
    [javadoc] C:\cvs-store\apache.org\jakarta\commons\lang\src\java\org\apache\commons\lang\builder\ToStringStyle.java:476: warning - The first sentence is interp
  reted to be:
    [javadoc] This sentence is different from what will be interpreted as the first sentence in the
    [javadoc] next major release (when that interpretation will be internationalized), which is:
    [javadoc] "<p>Append to the <code>toString</code> a <code>Date</code>
    [javadoc]  value, using the optional <code>DateFormat</code></p>"
    [javadoc] To avoid this note, change the doc comment to make this a proper first sentence, then
    [javadoc] use -breakiterator from that point forward, which will output this new sentence.
  
  Revision  Changes    Path
  1.18      +241 -200  jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringStyle.java
  
  Index: ToStringStyle.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringStyle.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ToStringStyle.java	20 Jul 2003 15:49:58 -0000	1.17
  +++ ToStringStyle.java	21 Jul 2003 19:34:10 -0000	1.18
  @@ -55,7 +55,9 @@
   
   import java.io.Serializable;
   import java.lang.reflect.Array;
  +import java.text.DateFormat;
   import java.util.Collection;
  +import java.util.Date;
   import java.util.Map;
   
   import org.apache.commons.lang.ObjectUtils;
  @@ -88,7 +90,7 @@
    * @version $Id$
    */
   public abstract class ToStringStyle implements Serializable {
  -    
  +
       /**
        * The default toString style.
        */
  @@ -122,7 +124,7 @@
        * Whether to use the identity hash code, the default is <code>true</code>.
        */
       private boolean useIdentityHashCode = true;
  -    
  +
       /**
        * The content start <code>'['</code>.
        */
  @@ -188,18 +190,37 @@
        * The summary object text start <code>'&gt;'</code>.
        */
       private String summaryObjectEndText = ">";
  -    
  +
  +    /**
  +     * An optional <code>DateFormat</code>.
  +     */
  +    private DateFormat dateFormat = null;
  +
  +    /**
  +     * Gets the <code>DateFormat</code>, which may be <code>null</code>.
  +     */
  +    protected DateFormat getDateFormat() {
  +        return this.dateFormat;
  +    }
  +
  +    /**
  +     * Sets the <code>DateFormat</code>, which may be <code>null</code>.
  +     */
  +    protected void setDateFormat(DateFormat dateFormat) {
  +        this.dateFormat = dateFormat;
  +    }
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Constructor.</p>
        */
       protected ToStringStyle() {
           super();
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append the superclass toString.</p>
        * 
  @@ -211,7 +232,7 @@
       public void appendSuper(StringBuffer buffer, String superToString) {
           appendToString(buffer, superToString);
       }
  -    
  +
       /**
        * <p>Append a toString.</p>
        * 
  @@ -286,9 +307,9 @@
               }
           }
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> an <code>Object</code>
        * value, printing the full <code>toString</code> of the
  @@ -302,17 +323,17 @@
        */
       public void append(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (value == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else {
               appendInternal(buffer, fieldName, value, isFullDetail(fullDetail));
           }
  -        
  +
           appendFieldEnd(buffer, fieldName);
       }
  -    
  +
       /**
        * <p>Append to the <code>toString</code> an <code>Object</code>,
        * correctly interpretting its type.</p>
  @@ -333,87 +354,94 @@
        * @param detail  output detail or not
        */
       protected void appendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail) {
  -        if (ReflectionToStringBuilder.isRegistered(value) 
  -                && !(value instanceof Number || value instanceof Boolean || value instanceof Character)) {
  -                ObjectUtils.appendIdentityToString(buffer, value);
  -            
  +        if (ReflectionToStringBuilder.isRegistered(value)
  +            && !(value instanceof Number || value instanceof Boolean || value instanceof Character)) {
  +            ObjectUtils.appendIdentityToString(buffer, value);
  +
           } else if (value instanceof Collection) {
               if (detail) {
                   appendDetail(buffer, fieldName, (Collection) value);
               } else {
                   appendSummarySize(buffer, fieldName, ((Collection) value).size());
               }
  -            
  +
           } else if (value instanceof Map) {
               if (detail) {
                   appendDetail(buffer, fieldName, (Map) value);
               } else {
                   appendSummarySize(buffer, fieldName, ((Map) value).size());
               }
  -            
  +
           } else if (value instanceof long[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (long[]) value);
               } else {
                   appendSummary(buffer, fieldName, (long[]) value);
               }
  -            
  +
           } else if (value instanceof int[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (int[]) value);
               } else {
                   appendSummary(buffer, fieldName, (int[]) value);
               }
  -            
  +
           } else if (value instanceof short[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (short[]) value);
               } else {
                   appendSummary(buffer, fieldName, (short[]) value);
               }
  -            
  +
           } else if (value instanceof byte[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (byte[]) value);
               } else {
                   appendSummary(buffer, fieldName, (byte[]) value);
               }
  -            
  +
           } else if (value instanceof char[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (char[]) value);
               } else {
                   appendSummary(buffer, fieldName, (char[]) value);
               }
  -            
  +
           } else if (value instanceof double[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (double[]) value);
               } else {
                   appendSummary(buffer, fieldName, (double[]) value);
               }
  -            
  +
           } else if (value instanceof float[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (float[]) value);
               } else {
                   appendSummary(buffer, fieldName, (float[]) value);
               }
  -            
  +
           } else if (value instanceof boolean[]) {
               if (detail) {
                   appendDetail(buffer, fieldName, (boolean[]) value);
               } else {
                   appendSummary(buffer, fieldName, (boolean[]) value);
               }
  -        
  -        } else if (value.getClass().isArray()) {
  -            if (detail) {
  -                appendDetail(buffer, fieldName, (Object[]) value);
  -            } else {
  -                appendSummary(buffer, fieldName, (Object[]) value);
  -            }
  -            
  +
  +            } else if (value.getClass().isArray()) {
  +                if (detail) {
  +                    appendDetail(buffer, fieldName, (Object[]) value);
  +                } else {
  +                    appendSummary(buffer, fieldName, (Object[]) value);
  +                }
  +
  +            } else if (value instanceof Date) {
  +                if (detail) {
  +                    appendDetail(buffer, fieldName, (Date) value);
  +                } else {
  +                    appendSummary(buffer, fieldName, (Object) value);
  +                }
  +
           } else {
               if (detail) {
                   appendDetail(buffer, fieldName, (Object) value);
  @@ -422,7 +450,7 @@
               }
           }
       }
  -    
  +
       /**
        * <p>Append to the <code>toString</code> an <code>Object</code>
        * value, printing the full detail of the <code>Object</code>.</p>
  @@ -435,7 +463,20 @@
       protected void appendDetail(StringBuffer buffer, String fieldName, Object value) {
           buffer.append(value);
       }
  -    
  +
  +    /**
  +     * <p>Append to the <code>toString</code> a <code>Date</code>
  +     * value, using the optional <code>DateFormat</code>.</p>
  +     *
  +     * @param buffer  the <code>StringBuffer</code> to populate
  +     * @param fieldName  the field name, typically not used as already appended
  +     * @param value  the <code>Date</code> to add to the <code>toString</code>,
  +     *  not <code>null</code>
  +     */
  +    protected void appendDetail(StringBuffer buffer, String fieldName, Date value) {
  +        buffer.append(this.getDateFormat() != null ? this.getDateFormat().format(value) : (Object) value);
  +    }
  +
       /**
        * <p>Append to the <code>toString</code> a <code>Collection</code>.</p>
        *
  @@ -447,7 +488,7 @@
       protected void appendDetail(StringBuffer buffer, String fieldName, Collection coll) {
           buffer.append(coll);
       }
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>Map<code>.</p>
        *
  @@ -459,7 +500,7 @@
       protected void appendDetail(StringBuffer buffer, String fieldName, Map map) {
           buffer.append(map);
       }
  -    
  +
       /**
        * <p>Append to the <code>toString</code> an <code>Object</code>
        * value, printing a summary of the <code>Object</code>.</P>
  @@ -474,9 +515,9 @@
           buffer.append(getShortClassName(value.getClass()));
           buffer.append(summaryObjectEndText);
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>long</code>
        * value.</p>
  @@ -504,7 +545,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> an <code>int</code>
        * value.</p>
  @@ -532,7 +573,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>short</code>
        * value.</p>
  @@ -560,7 +601,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>byte</code>
        * value.</p>
  @@ -588,7 +629,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>char</code>
        * value.</p>
  @@ -616,7 +657,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>double</code>
        * value.</p>
  @@ -644,7 +685,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>float</code>
        * value.</p>
  @@ -672,7 +713,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>boolean</code>
        * value.</p>
  @@ -711,13 +752,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -726,7 +767,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> the detail of an
        * <code>Object</code> array.</p>
  @@ -745,7 +786,7 @@
               }
               if (item == null) {
                   appendNullText(buffer, fieldName);
  -                
  +
               } else {
                   appendInternal(buffer, fieldName, item, arrayContentDetail);
               }
  @@ -771,7 +812,7 @@
               }
               if (item == null) {
                   appendNullText(buffer, fieldName);
  -                
  +
               } else {
                   appendInternal(buffer, fieldName, item, arrayContentDetail);
               }
  @@ -793,7 +834,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>long</code>
        * array.</p>
  @@ -806,13 +847,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -854,7 +895,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> an <code>int</code>
        * array.</p>
  @@ -867,13 +908,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -915,7 +956,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>short</code>
        * array.</p>
  @@ -928,13 +969,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -976,7 +1017,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>byte</code>
        * array.</p>
  @@ -989,13 +1030,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -1037,7 +1078,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>char</code>
        * array.</p>
  @@ -1050,13 +1091,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -1098,7 +1139,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>double</code>
        * array.</p>
  @@ -1111,13 +1152,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -1159,7 +1200,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>float</code>
        * array.</p>
  @@ -1172,13 +1213,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -1220,7 +1261,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a <code>boolean</code>
        * array.</p>
  @@ -1233,13 +1274,13 @@
        */
       public void append(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail) {
           appendFieldStart(buffer, fieldName);
  -        
  +
           if (array == null) {
               appendNullText(buffer, fieldName);
  -            
  +
           } else if (isFullDetail(fullDetail)) {
               appendDetail(buffer, fieldName, array);
  -            
  +
           } else {
               appendSummary(buffer, fieldName, array);
           }
  @@ -1281,7 +1322,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Append the class name.</p>
        * 
  @@ -1319,7 +1360,7 @@
       protected void appendContentStart(StringBuffer buffer) {
           buffer.append(contentStart);
       }
  -    
  +
       /**
        * <p>Append the content end to the buffer.</p>
        * 
  @@ -1328,7 +1369,7 @@
       protected void appendContentEnd(StringBuffer buffer) {
           buffer.append(contentEnd);
       }
  -    
  +
       /**
        * <p>Append an indicator for <code>null</code> to the buffer.</p>
        *
  @@ -1340,7 +1381,7 @@
       protected void appendNullText(StringBuffer buffer, String fieldName) {
           buffer.append(nullText);
       }
  -    
  +
       /**
        * <p>Append the field separator to the buffer.</p>
        * 
  @@ -1349,7 +1390,7 @@
       protected void appendFieldSeparator(StringBuffer buffer) {
           buffer.append(fieldSeparator);
       }
  -    
  +
       /**
        * <p>Append the field start to the buffer.</p>
        * 
  @@ -1362,7 +1403,7 @@
               buffer.append(fieldNameValueSeparator);
           }
       }
  -    
  +
       /**
        * <p>Append the field end to the buffer.</p>
        * 
  @@ -1372,7 +1413,7 @@
       protected void appendFieldEnd(StringBuffer buffer, String fieldName) {
           appendFieldSeparator(buffer);
       }
  -    
  +
       /**
        * <p>Append to the <code>toString</code> a size summary.</p>
        *
  @@ -1414,7 +1455,7 @@
           }
           return fullDetailRequest.booleanValue();
       }
  -    
  +
       /**
        * <p>Gets the short class name for a class.</p>
        *
  @@ -1437,7 +1478,7 @@
       // These methods are not expected to be overridden, except to make public
       // (They are not public so that immutable subclasses can be written)
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether to use the class name.</p>
        *
  @@ -1457,7 +1498,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether to output short or long class names.</p>
        *
  @@ -1477,7 +1518,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether to use the identity hash code.</p>
        *
  @@ -1497,7 +1538,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether to use the field names passed in.</p>
        *
  @@ -1517,7 +1558,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether to use full detail when the caller doesn't
        * specify.</p>
  @@ -1539,7 +1580,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether to output array content detail.</p>
        *
  @@ -1548,7 +1589,7 @@
       protected boolean isArrayContentDetail() {
           return arrayContentDetail;
       }
  -    
  +
       /**
        * <p>Sets whether to output array content detail.</p>
        *
  @@ -1559,7 +1600,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the array start text.</p>
        *
  @@ -1585,7 +1626,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the array end text.</p>
        *
  @@ -1611,7 +1652,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the array separator text.</p>
        *
  @@ -1637,7 +1678,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the content start text.</p>
        *
  @@ -1663,7 +1704,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the content end text.</p>
        *
  @@ -1689,7 +1730,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the field name value separator text.</p>
        *
  @@ -1715,7 +1756,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the field separator text.</p>
        *
  @@ -1741,7 +1782,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether the field separator should be added at the start 
        * of each buffer.</p>
  @@ -1763,7 +1804,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets whether the field separator should be added at the end 
        * of each buffer.</p>
  @@ -1785,7 +1826,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the text to output when <code>null</code> found.</p>
        *
  @@ -1811,7 +1852,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the text to output when a <code>Collection</code>,
        * <code>Map</code> or array size is output.</p>
  @@ -1843,7 +1884,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the text to output when a <code>Collection</code>,
        * <code>Map</code> or array size is output.</p>
  @@ -1875,7 +1916,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the text to output when an <code>Object</code> is
        * output in summary mode.</p>
  @@ -1907,7 +1948,7 @@
       }
   
       //---------------------------------------------------------------------
  -    
  +
       /**
        * <p>Gets the text to output when an <code>Object</code> is
        * output in summary mode.</p>
  @@ -1939,7 +1980,7 @@
       }
   
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p>Default <code>ToStringStyle</code>.</p>
        *
  @@ -1947,7 +1988,7 @@
        * <code>StandardToStringStyle</code> to ensure its immutability.</p>
        */
       private static final class DefaultToStringStyle extends ToStringStyle {
  -        
  +
           /**
            * <p>Constructor.</p>
            *
  @@ -1956,7 +1997,7 @@
           private DefaultToStringStyle() {
               super();
           }
  -        
  +
           /**
            * <p>Ensure <code>Singleton</code> after serialization.</p>
            *
  @@ -1965,11 +2006,11 @@
           private Object readResolve() {
               return ToStringStyle.DEFAULT_STYLE;
           }
  -        
  +
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p><code>ToStringStyle</code> that does not print out
        * the field names.</p>
  @@ -1978,7 +2019,7 @@
        * <code>StandardToStringStyle</code> to ensure its immutability.
        */
       private static final class NoFieldNameToStringStyle extends ToStringStyle {
  -        
  +
           /**
            * <p>Constructor.</p>
            *
  @@ -1988,7 +2029,7 @@
               super();
               this.setUseFieldNames(false);
           }
  -        
  +
           /**
            * <p>Ensure <code>Singleton</code> after serialization.</p>
            *
  @@ -1997,11 +2038,11 @@
           private Object readResolve() {
               return ToStringStyle.NO_FIELD_NAMES_STYLE;
           }
  -        
  +
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p><code>ToStringStyle</code> that does not print out the
        * classname, identity hashcode, content start or field name.</p>
  @@ -2010,7 +2051,7 @@
        * <code>StandardToStringStyle</code> to ensure its immutability.</p>
        */
       private static final class SimpleToStringStyle extends ToStringStyle {
  -        
  +
           /**
            * <p>Constructor.</p>
            *
  @@ -2024,7 +2065,7 @@
               this.setContentStart("");
               this.setContentEnd("");
           }
  -        
  +
           /**
            * <p>Ensure <code>Singleton</ode> after serialization.</p>
            * @return the singleton
  @@ -2032,11 +2073,11 @@
           private Object readResolve() {
               return ToStringStyle.SIMPLE_STYLE;
           }
  -        
  +
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       /**
        * <p><code>ToStringStyle</code> that outputs on multiple lines.</p>
        *
  @@ -2057,7 +2098,7 @@
               this.setFieldSeparatorAtStart(true);
               this.setContentEnd(SystemUtils.LINE_SEPARATOR + "]");
           }
  -        
  +
           /**
            * <p>Ensure <code>Singleton</code> after serialization.</p>
            *
  @@ -2066,76 +2107,76 @@
           private Object readResolve() {
               return ToStringStyle.MULTI_LINE_STYLE;
           }
  -        
  +
       }
  -    
  +
       //----------------------------------------------------------------------------
  -    
  +
       // Removed, as the XML style needs more work for escaping characters, arrays,
       // collections, maps and embedded beans.
  -//    /**
  -//     * ToStringStyle that outputs in XML style
  -//     */
  -//    private static class XMLToStringStyle extends ToStringStyle {
  -//        
  -//        /**
  -//         * Constructor - use the static constant rather than instantiating.
  -//         */
  -//        private XMLToStringStyle() {
  -//            super();
  -//            nullText = "null";
  -//            sizeStartText = "size=";
  -//            sizeEndText = "";
  -//        }
  -//        
  -//        /**
  -//         * @see ToStringStyle#appendStart(StringBuffer, Object)
  -//         */
  -//        public void appendStart(StringBuffer buffer, Object object) {
  -//            buffer.append('<');
  -//            buffer.append(getShortClassName(object.getClass()));
  -//            buffer.append(" class=\"");
  -//            appendClassName(buffer, object);
  -//            buffer.append("\" hashCode=\"");
  -//            appendIdentityHashCode(buffer, object);
  -//            buffer.append("\">");
  -//            buffer.append(SystemUtils.LINE_SEPARATOR);
  -//            buffer.append("  ");
  -//        }
  -//
  -//        /**
  -//         * @see ToStringStyle#appendFieldStart(StringBuffer, String)
  -//         */
  -//        protected void appendFieldStart(StringBuffer buffer, String fieldName) {
  -//            buffer.append('<');
  -//            buffer.append(fieldName);
  -//            buffer.append('>');
  -//        }
  -//
  -//        /**
  -//         * @see ToStringStyle#appendFieldEnd(StringBuffer, String)
  -//         */
  -//        protected void appendFieldEnd(StringBuffer buffer, String fieldName) {
  -//            buffer.append("</");
  -//            buffer.append(fieldName);
  -//            buffer.append('>');
  -//            buffer.append(SystemUtils.LINE_SEPARATOR);
  -//            buffer.append("  ");
  -//        }
  -//
  -//        /**
  -//         * @see ToStringStyle#appendEnd(StringBuffer, Object)
  -//         */
  -//        public void appendEnd(StringBuffer buffer, Object object) {
  -//            int len = buffer.length();
  -//            if (len > 2 && buffer.charAt(len - 1) == ' ' && buffer.charAt(len - 2) == ' ') {
  -//                buffer.setLength(len - 2);
  -//            }
  -//            buffer.append("</");
  -//            buffer.append(getShortClassName(object.getClass()));
  -//            buffer.append("\">");
  -//        }
  -//
  -//    }
  -    
  +    //    /**
  +    //     * ToStringStyle that outputs in XML style
  +    //     */
  +    //    private static class XMLToStringStyle extends ToStringStyle {
  +    //        
  +    //        /**
  +    //         * Constructor - use the static constant rather than instantiating.
  +    //         */
  +    //        private XMLToStringStyle() {
  +    //            super();
  +    //            nullText = "null";
  +    //            sizeStartText = "size=";
  +    //            sizeEndText = "";
  +    //        }
  +    //        
  +    //        /**
  +    //         * @see ToStringStyle#appendStart(StringBuffer, Object)
  +    //         */
  +    //        public void appendStart(StringBuffer buffer, Object object) {
  +    //            buffer.append('<');
  +    //            buffer.append(getShortClassName(object.getClass()));
  +    //            buffer.append(" class=\"");
  +    //            appendClassName(buffer, object);
  +    //            buffer.append("\" hashCode=\"");
  +    //            appendIdentityHashCode(buffer, object);
  +    //            buffer.append("\">");
  +    //            buffer.append(SystemUtils.LINE_SEPARATOR);
  +    //            buffer.append("  ");
  +    //        }
  +    //
  +    //        /**
  +    //         * @see ToStringStyle#appendFieldStart(StringBuffer, String)
  +    //         */
  +    //        protected void appendFieldStart(StringBuffer buffer, String fieldName) {
  +    //            buffer.append('<');
  +    //            buffer.append(fieldName);
  +    //            buffer.append('>');
  +    //        }
  +    //
  +    //        /**
  +    //         * @see ToStringStyle#appendFieldEnd(StringBuffer, String)
  +    //         */
  +    //        protected void appendFieldEnd(StringBuffer buffer, String fieldName) {
  +    //            buffer.append("</");
  +    //            buffer.append(fieldName);
  +    //            buffer.append('>');
  +    //            buffer.append(SystemUtils.LINE_SEPARATOR);
  +    //            buffer.append("  ");
  +    //        }
  +    //
  +    //        /**
  +    //         * @see ToStringStyle#appendEnd(StringBuffer, Object)
  +    //         */
  +    //        public void appendEnd(StringBuffer buffer, Object object) {
  +    //            int len = buffer.length();
  +    //            if (len > 2 && buffer.charAt(len - 1) == ' ' && buffer.charAt(len - 2) == ' ') {
  +    //                buffer.setLength(len - 2);
  +    //            }
  +    //            buffer.append("</");
  +    //            buffer.append(getShortClassName(object.getClass()));
  +    //            buffer.append("\">");
  +    //        }
  +    //
  +    //    }
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: cvs commit: ToStringStyle date format

Posted by Stephen Colebourne <sc...@btopenworld.com>.
-1 to this change.
Reason. The design of including a DateFormat is too restrictive. It ties the
API to an inflexible implementation that we wouldn't be able to remove until
4.0.

The problem of formatting dates is a valid one. But this isn't the solution.
This is another one for 2.1/3.0 as the real solution is a pluggable
converter mechanism.

(I have backed out the change.)

Stephen

----- Original Message -----
From: <gg...@apache.org>
To: <ja...@apache.org>
Sent: Monday, July 21, 2003 8:34 PM
Subject: cvs commit:
jakarta-commons/lang/src/java/org/apache/commons/lang/builder
ToStringStyle.java


> ggregory    2003/07/21 12:34:11
>
>   Modified:    lang/src/java/org/apache/commons/lang/builder
>                         ToStringStyle.java
>   Log:
>   Missing '.' caused the Javadoc warning:
>     [javadoc] Generating
C:\cvs-store\apache.org\jakarta\commons\lang\dist\docs\api\index-all.html...
>     [javadoc] "<p>Append to the <code>toString</code> a <code>Date</code>
>     [javadoc]  value, using the optional <code>DateFormat</code>"
>     [javadoc]
C:\cvs-store\apache.org\jakarta\commons\lang\src\java\org\apache\commons\lan
g\builder\ToStringStyle.java:476: warning - The first sentence is interp
>   reted to be:
>     [javadoc] This sentence is different from what will be interpreted as
the first sentence in the
>     [javadoc] next major release (when that interpretation will be
internationalized), which is:
>     [javadoc] "<p>Append to the <code>toString</code> a <code>Date</code>
>     [javadoc]  value, using the optional <code>DateFormat</code></p>"
>     [javadoc] To avoid this note, change the doc comment to make this a
proper first sentence, then
>     [javadoc] use -breakiterator from that point forward, which will
output this new sentence.
>
>   Revision  Changes    Path
>   1.18      +241 -200
jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringStyle.
java
>
>   Index: ToStringStyle.java
>   ===================================================================
>   RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToSt
ringStyle.java,v
>   retrieving revision 1.17
>   retrieving revision 1.18
>   diff -u -r1.17 -r1.18
>   --- ToStringStyle.java 20 Jul 2003 15:49:58 -0000 1.17
>   +++ ToStringStyle.java 21 Jul 2003 19:34:10 -0000 1.18
>   @@ -55,7 +55,9 @@
>
>    import java.io.Serializable;
>    import java.lang.reflect.Array;
>   +import java.text.DateFormat;
>    import java.util.Collection;
>   +import java.util.Date;
>    import java.util.Map;
>
>    import org.apache.commons.lang.ObjectUtils;
>   @@ -88,7 +90,7 @@
>     * @version $Id$
>     */
>    public abstract class ToStringStyle implements Serializable {
>   -
>   +
>        /**
>         * The default toString style.
>         */
>   @@ -122,7 +124,7 @@
>         * Whether to use the identity hash code, the default is
<code>true</code>.
>         */
>        private boolean useIdentityHashCode = true;
>   -
>   +
>        /**
>         * The content start <code>'['</code>.
>         */
>   @@ -188,18 +190,37 @@
>         * The summary object text start <code>'&gt;'</code>.
>         */
>        private String summaryObjectEndText = ">";
>   -
>   +
>   +    /**
>   +     * An optional <code>DateFormat</code>.
>   +     */
>   +    private DateFormat dateFormat = null;
>   +
>   +    /**
>   +     * Gets the <code>DateFormat</code>, which may be
<code>null</code>.
>   +     */
>   +    protected DateFormat getDateFormat() {
>   +        return this.dateFormat;
>   +    }
>   +
>   +    /**
>   +     * Sets the <code>DateFormat</code>, which may be
<code>null</code>.
>   +     */
>   +    protected void setDateFormat(DateFormat dateFormat) {
>   +        this.dateFormat = dateFormat;
>   +    }
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Constructor.</p>
>         */
>        protected ToStringStyle() {
>            super();
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append the superclass toString.</p>
>         *
>   @@ -211,7 +232,7 @@
>        public void appendSuper(StringBuffer buffer, String superToString)
{
>            appendToString(buffer, superToString);
>        }
>   -
>   +
>        /**
>         * <p>Append a toString.</p>
>         *
>   @@ -286,9 +307,9 @@
>                }
>            }
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> an <code>Object</code>
>         * value, printing the full <code>toString</code> of the
>   @@ -302,17 +323,17 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, Object
value, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (value == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else {
>                appendInternal(buffer, fieldName, value,
isFullDetail(fullDetail));
>            }
>   -
>   +
>            appendFieldEnd(buffer, fieldName);
>        }
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> an <code>Object</code>,
>         * correctly interpretting its type.</p>
>   @@ -333,87 +354,94 @@
>         * @param detail  output detail or not
>         */
>        protected void appendInternal(StringBuffer buffer, String
fieldName, Object value, boolean detail) {
>   -        if (ReflectionToStringBuilder.isRegistered(value)
>   -                && !(value instanceof Number || value instanceof
Boolean || value instanceof Character)) {
>   -                ObjectUtils.appendIdentityToString(buffer, value);
>   -
>   +        if (ReflectionToStringBuilder.isRegistered(value)
>   +            && !(value instanceof Number || value instanceof Boolean ||
value instanceof Character)) {
>   +            ObjectUtils.appendIdentityToString(buffer, value);
>   +
>            } else if (value instanceof Collection) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (Collection) value);
>                } else {
>                    appendSummarySize(buffer, fieldName, ((Collection)
value).size());
>                }
>   -
>   +
>            } else if (value instanceof Map) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (Map) value);
>                } else {
>                    appendSummarySize(buffer, fieldName, ((Map)
value).size());
>                }
>   -
>   +
>            } else if (value instanceof long[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (long[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (long[]) value);
>                }
>   -
>   +
>            } else if (value instanceof int[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (int[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (int[]) value);
>                }
>   -
>   +
>            } else if (value instanceof short[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (short[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (short[]) value);
>                }
>   -
>   +
>            } else if (value instanceof byte[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (byte[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (byte[]) value);
>                }
>   -
>   +
>            } else if (value instanceof char[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (char[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (char[]) value);
>                }
>   -
>   +
>            } else if (value instanceof double[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (double[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (double[]) value);
>                }
>   -
>   +
>            } else if (value instanceof float[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (float[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (float[]) value);
>                }
>   -
>   +
>            } else if (value instanceof boolean[]) {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (boolean[]) value);
>                } else {
>                    appendSummary(buffer, fieldName, (boolean[]) value);
>                }
>   -
>   -        } else if (value.getClass().isArray()) {
>   -            if (detail) {
>   -                appendDetail(buffer, fieldName, (Object[]) value);
>   -            } else {
>   -                appendSummary(buffer, fieldName, (Object[]) value);
>   -            }
>   -
>   +
>   +            } else if (value.getClass().isArray()) {
>   +                if (detail) {
>   +                    appendDetail(buffer, fieldName, (Object[]) value);
>   +                } else {
>   +                    appendSummary(buffer, fieldName, (Object[]) value);
>   +                }
>   +
>   +            } else if (value instanceof Date) {
>   +                if (detail) {
>   +                    appendDetail(buffer, fieldName, (Date) value);
>   +                } else {
>   +                    appendSummary(buffer, fieldName, (Object) value);
>   +                }
>   +
>            } else {
>                if (detail) {
>                    appendDetail(buffer, fieldName, (Object) value);
>   @@ -422,7 +450,7 @@
>                }
>            }
>        }
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> an <code>Object</code>
>         * value, printing the full detail of the <code>Object</code>.</p>
>   @@ -435,7 +463,20 @@
>        protected void appendDetail(StringBuffer buffer, String fieldName,
Object value) {
>            buffer.append(value);
>        }
>   -
>   +
>   +    /**
>   +     * <p>Append to the <code>toString</code> a <code>Date</code>
>   +     * value, using the optional <code>DateFormat</code>.</p>
>   +     *
>   +     * @param buffer  the <code>StringBuffer</code> to populate
>   +     * @param fieldName  the field name, typically not used as already
appended
>   +     * @param value  the <code>Date</code> to add to the
<code>toString</code>,
>   +     *  not <code>null</code>
>   +     */
>   +    protected void appendDetail(StringBuffer buffer, String fieldName,
Date value) {
>   +        buffer.append(this.getDateFormat() != null ?
this.getDateFormat().format(value) : (Object) value);
>   +    }
>   +
>        /**
>         * <p>Append to the <code>toString</code> a
<code>Collection</code>.</p>
>         *
>   @@ -447,7 +488,7 @@
>        protected void appendDetail(StringBuffer buffer, String fieldName,
Collection coll) {
>            buffer.append(coll);
>        }
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>Map<code>.</p>
>         *
>   @@ -459,7 +500,7 @@
>        protected void appendDetail(StringBuffer buffer, String fieldName,
Map map) {
>            buffer.append(map);
>        }
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> an <code>Object</code>
>         * value, printing a summary of the <code>Object</code>.</P>
>   @@ -474,9 +515,9 @@
>            buffer.append(getShortClassName(value.getClass()));
>            buffer.append(summaryObjectEndText);
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>long</code>
>         * value.</p>
>   @@ -504,7 +545,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> an <code>int</code>
>         * value.</p>
>   @@ -532,7 +573,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>short</code>
>         * value.</p>
>   @@ -560,7 +601,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>byte</code>
>         * value.</p>
>   @@ -588,7 +629,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>char</code>
>         * value.</p>
>   @@ -616,7 +657,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>double</code>
>         * value.</p>
>   @@ -644,7 +685,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>float</code>
>         * value.</p>
>   @@ -672,7 +713,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>boolean</code>
>         * value.</p>
>   @@ -711,13 +752,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, Object[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -726,7 +767,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> the detail of an
>         * <code>Object</code> array.</p>
>   @@ -745,7 +786,7 @@
>                }
>                if (item == null) {
>                    appendNullText(buffer, fieldName);
>   -
>   +
>                } else {
>                    appendInternal(buffer, fieldName, item,
arrayContentDetail);
>                }
>   @@ -771,7 +812,7 @@
>                }
>                if (item == null) {
>                    appendNullText(buffer, fieldName);
>   -
>   +
>                } else {
>                    appendInternal(buffer, fieldName, item,
arrayContentDetail);
>                }
>   @@ -793,7 +834,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>long</code>
>         * array.</p>
>   @@ -806,13 +847,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, long[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -854,7 +895,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> an <code>int</code>
>         * array.</p>
>   @@ -867,13 +908,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, int[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -915,7 +956,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>short</code>
>         * array.</p>
>   @@ -928,13 +969,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, short[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -976,7 +1017,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>byte</code>
>         * array.</p>
>   @@ -989,13 +1030,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, byte[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -1037,7 +1078,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>char</code>
>         * array.</p>
>   @@ -1050,13 +1091,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, char[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -1098,7 +1139,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>double</code>
>         * array.</p>
>   @@ -1111,13 +1152,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, double[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -1159,7 +1200,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>float</code>
>         * array.</p>
>   @@ -1172,13 +1213,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, float[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -1220,7 +1261,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a <code>boolean</code>
>         * array.</p>
>   @@ -1233,13 +1274,13 @@
>         */
>        public void append(StringBuffer buffer, String fieldName, boolean[]
array, Boolean fullDetail) {
>            appendFieldStart(buffer, fieldName);
>   -
>   +
>            if (array == null) {
>                appendNullText(buffer, fieldName);
>   -
>   +
>            } else if (isFullDetail(fullDetail)) {
>                appendDetail(buffer, fieldName, array);
>   -
>   +
>            } else {
>                appendSummary(buffer, fieldName, array);
>            }
>   @@ -1281,7 +1322,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Append the class name.</p>
>         *
>   @@ -1319,7 +1360,7 @@
>        protected void appendContentStart(StringBuffer buffer) {
>            buffer.append(contentStart);
>        }
>   -
>   +
>        /**
>         * <p>Append the content end to the buffer.</p>
>         *
>   @@ -1328,7 +1369,7 @@
>        protected void appendContentEnd(StringBuffer buffer) {
>            buffer.append(contentEnd);
>        }
>   -
>   +
>        /**
>         * <p>Append an indicator for <code>null</code> to the buffer.</p>
>         *
>   @@ -1340,7 +1381,7 @@
>        protected void appendNullText(StringBuffer buffer, String
fieldName) {
>            buffer.append(nullText);
>        }
>   -
>   +
>        /**
>         * <p>Append the field separator to the buffer.</p>
>         *
>   @@ -1349,7 +1390,7 @@
>        protected void appendFieldSeparator(StringBuffer buffer) {
>            buffer.append(fieldSeparator);
>        }
>   -
>   +
>        /**
>         * <p>Append the field start to the buffer.</p>
>         *
>   @@ -1362,7 +1403,7 @@
>                buffer.append(fieldNameValueSeparator);
>            }
>        }
>   -
>   +
>        /**
>         * <p>Append the field end to the buffer.</p>
>         *
>   @@ -1372,7 +1413,7 @@
>        protected void appendFieldEnd(StringBuffer buffer, String
fieldName) {
>            appendFieldSeparator(buffer);
>        }
>   -
>   +
>        /**
>         * <p>Append to the <code>toString</code> a size summary.</p>
>         *
>   @@ -1414,7 +1455,7 @@
>            }
>            return fullDetailRequest.booleanValue();
>        }
>   -
>   +
>        /**
>         * <p>Gets the short class name for a class.</p>
>         *
>   @@ -1437,7 +1478,7 @@
>        // These methods are not expected to be overridden, except to make
public
>        // (They are not public so that immutable subclasses can be
written)
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether to use the class name.</p>
>         *
>   @@ -1457,7 +1498,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether to output short or long class names.</p>
>         *
>   @@ -1477,7 +1518,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether to use the identity hash code.</p>
>         *
>   @@ -1497,7 +1538,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether to use the field names passed in.</p>
>         *
>   @@ -1517,7 +1558,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether to use full detail when the caller doesn't
>         * specify.</p>
>   @@ -1539,7 +1580,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether to output array content detail.</p>
>         *
>   @@ -1548,7 +1589,7 @@
>        protected boolean isArrayContentDetail() {
>            return arrayContentDetail;
>        }
>   -
>   +
>        /**
>         * <p>Sets whether to output array content detail.</p>
>         *
>   @@ -1559,7 +1600,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the array start text.</p>
>         *
>   @@ -1585,7 +1626,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the array end text.</p>
>         *
>   @@ -1611,7 +1652,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the array separator text.</p>
>         *
>   @@ -1637,7 +1678,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the content start text.</p>
>         *
>   @@ -1663,7 +1704,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the content end text.</p>
>         *
>   @@ -1689,7 +1730,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the field name value separator text.</p>
>         *
>   @@ -1715,7 +1756,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the field separator text.</p>
>         *
>   @@ -1741,7 +1782,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether the field separator should be added at the start
>         * of each buffer.</p>
>   @@ -1763,7 +1804,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets whether the field separator should be added at the end
>         * of each buffer.</p>
>   @@ -1785,7 +1826,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the text to output when <code>null</code> found.</p>
>         *
>   @@ -1811,7 +1852,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the text to output when a <code>Collection</code>,
>         * <code>Map</code> or array size is output.</p>
>   @@ -1843,7 +1884,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the text to output when a <code>Collection</code>,
>         * <code>Map</code> or array size is output.</p>
>   @@ -1875,7 +1916,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the text to output when an <code>Object</code> is
>         * output in summary mode.</p>
>   @@ -1907,7 +1948,7 @@
>        }
>
>
//---------------------------------------------------------------------
>   -
>   +
>        /**
>         * <p>Gets the text to output when an <code>Object</code> is
>         * output in summary mode.</p>
>   @@ -1939,7 +1980,7 @@
>        }
>
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p>Default <code>ToStringStyle</code>.</p>
>         *
>   @@ -1947,7 +1988,7 @@
>         * <code>StandardToStringStyle</code> to ensure its
immutability.</p>
>         */
>        private static final class DefaultToStringStyle extends
ToStringStyle {
>   -
>   +
>            /**
>             * <p>Constructor.</p>
>             *
>   @@ -1956,7 +1997,7 @@
>            private DefaultToStringStyle() {
>                super();
>            }
>   -
>   +
>            /**
>             * <p>Ensure <code>Singleton</code> after serialization.</p>
>             *
>   @@ -1965,11 +2006,11 @@
>            private Object readResolve() {
>                return ToStringStyle.DEFAULT_STYLE;
>            }
>   -
>   +
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p><code>ToStringStyle</code> that does not print out
>         * the field names.</p>
>   @@ -1978,7 +2019,7 @@
>         * <code>StandardToStringStyle</code> to ensure its immutability.
>         */
>        private static final class NoFieldNameToStringStyle extends
ToStringStyle {
>   -
>   +
>            /**
>             * <p>Constructor.</p>
>             *
>   @@ -1988,7 +2029,7 @@
>                super();
>                this.setUseFieldNames(false);
>            }
>   -
>   +
>            /**
>             * <p>Ensure <code>Singleton</code> after serialization.</p>
>             *
>   @@ -1997,11 +2038,11 @@
>            private Object readResolve() {
>                return ToStringStyle.NO_FIELD_NAMES_STYLE;
>            }
>   -
>   +
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p><code>ToStringStyle</code> that does not print out the
>         * classname, identity hashcode, content start or field name.</p>
>   @@ -2010,7 +2051,7 @@
>         * <code>StandardToStringStyle</code> to ensure its
immutability.</p>
>         */
>        private static final class SimpleToStringStyle extends
ToStringStyle {
>   -
>   +
>            /**
>             * <p>Constructor.</p>
>             *
>   @@ -2024,7 +2065,7 @@
>                this.setContentStart("");
>                this.setContentEnd("");
>            }
>   -
>   +
>            /**
>             * <p>Ensure <code>Singleton</ode> after serialization.</p>
>             * @return the singleton
>   @@ -2032,11 +2073,11 @@
>            private Object readResolve() {
>                return ToStringStyle.SIMPLE_STYLE;
>            }
>   -
>   +
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        /**
>         * <p><code>ToStringStyle</code> that outputs on multiple
lines.</p>
>         *
>   @@ -2057,7 +2098,7 @@
>                this.setFieldSeparatorAtStart(true);
>                this.setContentEnd(SystemUtils.LINE_SEPARATOR + "]");
>            }
>   -
>   +
>            /**
>             * <p>Ensure <code>Singleton</code> after serialization.</p>
>             *
>   @@ -2066,76 +2107,76 @@
>            private Object readResolve() {
>                return ToStringStyle.MULTI_LINE_STYLE;
>            }
>   -
>   +
>        }
>   -
>   +
>
//--------------------------------------------------------------------------
--
>   -
>   +
>        // Removed, as the XML style needs more work for escaping
characters, arrays,
>        // collections, maps and embedded beans.
>   -//    /**
>   -//     * ToStringStyle that outputs in XML style
>   -//     */
>   -//    private static class XMLToStringStyle extends ToStringStyle {
>   -//
>   -//        /**
>   -//         * Constructor - use the static constant rather than
instantiating.
>   -//         */
>   -//        private XMLToStringStyle() {
>   -//            super();
>   -//            nullText = "null";
>   -//            sizeStartText = "size=";
>   -//            sizeEndText = "";
>   -//        }
>   -//
>   -//        /**
>   -//         * @see ToStringStyle#appendStart(StringBuffer, Object)
>   -//         */
>   -//        public void appendStart(StringBuffer buffer, Object object) {
>   -//            buffer.append('<');
>   -//            buffer.append(getShortClassName(object.getClass()));
>   -//            buffer.append(" class=\"");
>   -//            appendClassName(buffer, object);
>   -//            buffer.append("\" hashCode=\"");
>   -//            appendIdentityHashCode(buffer, object);
>   -//            buffer.append("\">");
>   -//            buffer.append(SystemUtils.LINE_SEPARATOR);
>   -//            buffer.append("  ");
>   -//        }
>   -//
>   -//        /**
>   -//         * @see ToStringStyle#appendFieldStart(StringBuffer, String)
>   -//         */
>   -//        protected void appendFieldStart(StringBuffer buffer, String
fieldName) {
>   -//            buffer.append('<');
>   -//            buffer.append(fieldName);
>   -//            buffer.append('>');
>   -//        }
>   -//
>   -//        /**
>   -//         * @see ToStringStyle#appendFieldEnd(StringBuffer, String)
>   -//         */
>   -//        protected void appendFieldEnd(StringBuffer buffer, String
fieldName) {
>   -//            buffer.append("</");
>   -//            buffer.append(fieldName);
>   -//            buffer.append('>');
>   -//            buffer.append(SystemUtils.LINE_SEPARATOR);
>   -//            buffer.append("  ");
>   -//        }
>   -//
>   -//        /**
>   -//         * @see ToStringStyle#appendEnd(StringBuffer, Object)
>   -//         */
>   -//        public void appendEnd(StringBuffer buffer, Object object) {
>   -//            int len = buffer.length();
>   -//            if (len > 2 && buffer.charAt(len - 1) == ' ' &&
buffer.charAt(len - 2) == ' ') {
>   -//                buffer.setLength(len - 2);
>   -//            }
>   -//            buffer.append("</");
>   -//            buffer.append(getShortClassName(object.getClass()));
>   -//            buffer.append("\">");
>   -//        }
>   -//
>   -//    }
>   -
>   +    //    /**
>   +    //     * ToStringStyle that outputs in XML style
>   +    //     */
>   +    //    private static class XMLToStringStyle extends ToStringStyle {
>   +    //
>   +    //        /**
>   +    //         * Constructor - use the static constant rather than
instantiating.
>   +    //         */
>   +    //        private XMLToStringStyle() {
>   +    //            super();
>   +    //            nullText = "null";
>   +    //            sizeStartText = "size=";
>   +    //            sizeEndText = "";
>   +    //        }
>   +    //
>   +    //        /**
>   +    //         * @see ToStringStyle#appendStart(StringBuffer, Object)
>   +    //         */
>   +    //        public void appendStart(StringBuffer buffer, Object
object) {
>   +    //            buffer.append('<');
>   +    //            buffer.append(getShortClassName(object.getClass()));
>   +    //            buffer.append(" class=\"");
>   +    //            appendClassName(buffer, object);
>   +    //            buffer.append("\" hashCode=\"");
>   +    //            appendIdentityHashCode(buffer, object);
>   +    //            buffer.append("\">");
>   +    //            buffer.append(SystemUtils.LINE_SEPARATOR);
>   +    //            buffer.append("  ");
>   +    //        }
>   +    //
>   +    //        /**
>   +    //         * @see ToStringStyle#appendFieldStart(StringBuffer,
String)
>   +    //         */
>   +    //        protected void appendFieldStart(StringBuffer buffer,
String fieldName) {
>   +    //            buffer.append('<');
>   +    //            buffer.append(fieldName);
>   +    //            buffer.append('>');
>   +    //        }
>   +    //
>   +    //        /**
>   +    //         * @see ToStringStyle#appendFieldEnd(StringBuffer,
String)
>   +    //         */
>   +    //        protected void appendFieldEnd(StringBuffer buffer, String
fieldName) {
>   +    //            buffer.append("</");
>   +    //            buffer.append(fieldName);
>   +    //            buffer.append('>');
>   +    //            buffer.append(SystemUtils.LINE_SEPARATOR);
>   +    //            buffer.append("  ");
>   +    //        }
>   +    //
>   +    //        /**
>   +    //         * @see ToStringStyle#appendEnd(StringBuffer, Object)
>   +    //         */
>   +    //        public void appendEnd(StringBuffer buffer, Object object)
{
>   +    //            int len = buffer.length();
>   +    //            if (len > 2 && buffer.charAt(len - 1) == ' ' &&
buffer.charAt(len - 2) == ' ') {
>   +    //                buffer.setLength(len - 2);
>   +    //            }
>   +    //            buffer.append("</");
>   +    //            buffer.append(getShortClassName(object.getClass()));
>   +    //            buffer.append("\">");
>   +    //        }
>   +    //
>   +    //    }
>   +
>    }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org