dlr         01/08/26 12:28:54

  Modified:    util/src/java/org/apache/commons/util StringUtils.java
  Log:
  Renamed makeString(Strin) to clean(String) and made trim(String) a
  safe to pass null references to.  JavaDoc'd both.
  
  Revision  Changes    Path
  1.12      +20 -11    
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.11
  retrieving revision 1.12
  diff -u -u -r1.11 -r1.12
  --- StringUtils.java  2001/08/26 05:54:41     1.11
  +++ StringUtils.java  2001/08/26 19:28:54     1.12
  @@ -81,23 +81,36 @@
    * @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.11 2001/08/26 05:54:41 dlr Exp $
  + * @version $Id: StringUtils.java,v 1.12 2001/08/26 19:28:54 dlr Exp $
    */
   public class StringUtils
   {
       /**
  -     * Deal with null strings converting them to "" instead.  It also
  -     * invokes String.trim() on the output.
  +     * Trims text safely, dealing with <code>null</code> references by
  +     * converting them to <code>""</code> (the empty string).
        *
  -     * @param foo A String.
  -     * @return A String.
  +     * @param s The text to trim.
  +     * @return The trimmed text (never <code>null</code>).
        */
  -    public static final String makeString(String foo)
  +    public static final String clean(String s)
       {
  -        return (foo == null ? "" : foo.trim());
  +        return (s == null ? "" : s.trim());
       }
   
       /**
  +     * Trims text safely, dealing with <code>null</code> references by
  +     * returning <code>null</code> (rather than throwing a
  +     * NullPointerException).
  +     *
  +     * @param s The text to trim.
  +     * @return The trimmed text (or <code>null</code>).
  +     */
  +    public static final String trim(String s)
  +    {
  +        return (s == null ? null : s.trim());
  +    }
  +
  +    /**
        * Validates that the supplied string is neither <code>null</code>
        * nor the empty string.
        *
  @@ -1601,10 +1614,6 @@
   
       static public String lowerCase(String str) {
           return str.toLowerCase();
  -    }
  -
  -    static public String trim(String str) {
  -        return str.trim();
       }
   
       static public String substring(String str, String start) {
  
  
  

Reply via email to