commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang/builder ToStringStyle.java ToStringBuilder.java
Date Thu, 01 Jul 2004 17:40:10 GMT
ggregory    2004/07/01 10:40:10

  Modified:    lang/src/java/org/apache/commons/lang/builder
                        ToStringStyle.java ToStringBuilder.java
  Log:
  PR: http://issues.apache.org/bugzilla/show_bug.cgi?id=27876
  [lang] ReflectionToStringBuilder.toString(null) throws exception by design
  new ToStringBuilder(null).toString() == the style's nullText.
  
  Revision  Changes    Path
  1.32      +2 -5      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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ToStringStyle.java	1 Jul 2004 17:10:47 -0000	1.31
  +++ ToStringStyle.java	1 Jul 2004 17:40:10 -0000	1.32
  @@ -251,10 +251,7 @@
        *  <code>toString</code> for.
        */
       public void appendEnd(StringBuffer buffer, Object object) {
  -        if (object == null){
  -            return;
  -        }
  -        if (fieldSeparatorAtEnd == false) {
  +        if (this.fieldSeparatorAtEnd == false) {
               removeLastFieldSeparator(buffer);
           }
           appendContentEnd(buffer);
  
  
  
  1.35      +8 -2      jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringBuilder.java
  
  Index: ToStringBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/builder/ToStringBuilder.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ToStringBuilder.java	1 Jul 2004 17:10:47 -0000	1.34
  +++ ToStringBuilder.java	1 Jul 2004 17:40:10 -0000	1.35
  @@ -1026,10 +1026,16 @@
        * <p>This method appends the end of data indicator, and can only be called once.
        * Use {@link #getStringBuffer} to get the current string state.</p>
        * 
  +     * <p>If the object is <code>null</code>, return the style's <code>nullText</code></p>
  +     * 
        * @return the String <code>toString</code>
        */
       public String toString() {
  -        style.appendEnd(this.getStringBuffer(), this.getObject());
  +        if (this.getObject() == null) {
  +            this.getStringBuffer().append(this.getStyle().getNullText());
  +        } else {
  +            style.appendEnd(this.getStringBuffer(), this.getObject());
  +        }
           return this.getStringBuffer().toString();
       }
   
  
  
  

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


Mime
View raw message