commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/lang/src/java/org/apache/commons/lang CharRange.java
Date Sat, 02 Aug 2003 11:20:49 GMT
scolebourne    2003/08/02 04:20:49

  Modified:    lang/src/java/org/apache/commons/lang CharRange.java
  Log:
  Improve toString() using StringBuffer
  from Chris Feldhacker
  
  Revision  Changes    Path
  1.9       +11 -10    jakarta-commons/lang/src/java/org/apache/commons/lang/CharRange.java
  
  Index: CharRange.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/CharRange.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CharRange.java	26 Jul 2003 15:33:34 -0000	1.8
  +++ CharRange.java	2 Aug 2003 11:20:49 -0000	1.9
  @@ -61,6 +61,7 @@
    *
    * @author <a href="bayard@generationjava.com">Henri Yandell</a>
    * @author Stephen Colebourne
  + * @author Chris Feldhacker
    * @since 1.0
    * @version $Id$
    */
  @@ -192,19 +193,19 @@
       /**
        * <p>Output a string representation of the character range.</p>
        * 
  -     * @return string representation
  +     * @return string representation of this range
        */
       public String toString() {
  -        String str = "";
  -        if( isNegated() ) {
  -            str += "^";
  +        StringBuffer buf = new StringBuffer(4);
  +        if (isNegated()) {
  +            buf.append('^');
           }
  -        str += start;
  -        if( isRange() ) {
  -            str += "-";
  -            str += close;
  +        buf.append(start);
  +        if (isRange()) {
  +            buf.append('-');
  +            buf.append(close);
           }
  -        return str;
  +        return buf.toString();
       }
       
   }
  
  
  

Mime
View raw message