dlr         01/08/26 19:22:19

  Modified:    util/src/java/org/apache/commons/util StringUtils.java
  Log:
  Optimized and better documented firstLetterCaps(String).
  
  Revision  Changes    Path
  1.14      +8 -8      
jakarta-commons-sandbox/util/src/java/org/apache/commons/util/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/StringUtils.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -u -r1.13 -r1.14
  --- StringUtils.java  2001/08/26 19:38:27     1.13
  +++ StringUtils.java  2001/08/27 02:22:18     1.14
  @@ -81,7 +81,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Greg Coladonato</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Bayard</a>
  - * @version $Id: StringUtils.java,v 1.13 2001/08/26 19:38:27 dlr Exp $
  + * @version $Id: StringUtils.java,v 1.14 2001/08/27 02:22:18 dlr Exp $
    */
   public class StringUtils
   {
  @@ -206,14 +206,15 @@
       }
   
       /**
  -     * Makes the first letter caps and leaves the rest as is.
  +     * Makes the first letter capital and leaves the rest as is.
  +     *
  +     * @param text The text to modify.
  +     * @return The modified text.
        */
  -    public static String firstLetterCaps ( String data )
  +    public static String firstLetterCaps(String text)
       {
  -        StringBuffer sbuf = new StringBuffer(data.length());
  -        sbuf.append(data.substring(0, 1).toUpperCase())
  -            .append(data.substring(1));
  -        return sbuf.toString();
  +        return (text == null ? null :
  +                text.substring(0, 1).toUpperCase() + text.substring(1));
       }
   
       /**
  @@ -231,7 +232,6 @@
       {
           return split(text, separator, -1);
       }
  -
   
       /**
        * Splits the provided text into a list, based on a given
  
  
  

Reply via email to