From b556203db74b0c151ece264cbb8f900b6e0c2945 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Sun, 27 Oct 2002 19:42:04 +0000 Subject: [PATCH] Changed the signature of StringUtils.defaultString(String,String) and (String) to (Object, String) and (Object). A note needs to be made in the next release that code using defaultString needs to be recompiled else it will grumble. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137102 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS.html | 4 +--- .../org/apache/commons/lang/StringUtils.java | 22 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/STATUS.html b/STATUS.html index 8b1131d51..dd230a370 100644 --- a/STATUS.html +++ b/STATUS.html @@ -7,7 +7,7 @@

The Jakarta Commons Lang Component

-$Id: STATUS.html,v 1.22 2002/10/04 03:22:47 bayard Exp $
+$Id: STATUS.html,v 1.23 2002/10/27 19:42:04 bayard Exp $
[Introduction] [Dependencies] [Release Info] @@ -91,8 +91,6 @@ still under discussion, so please mail the list before actioning.

  • StringUtils parseBoolean method - This method is in OSCore's TextUtils and seems very reusable. It could go in a BooleanUtils if such a need was seen. [CODED]
  • StringUtils uncapitaliseAllWords method - String Taglib has shown that this method is missing from StringUtils. [CODED]
  • StringUtils unescape method - String Taglib has shown that this method is missing from StringUtils. It would take a String with "\n" in and convert it to the Java character. unescape and escape should be symmetric.
  • -
  • StringUtils defaultStirng(Object) method - simliar behavior to defaultString(String), returns obj.toString() if obj != null, "" otherwise -
  • StringUtils defaultString(Object, String) method - similar behavior to defaultString(String, String), returns obj.toString() if obj != null, specified string otherwise
  • ArrayUtils - opinion seems to be that this belongs with [lang] and not [collections]
  • GUID and other Identifier generators - these may belong in [util], some code exists in [pattern] at the moment
  • CharUtils - Utilities to work on a char[] in the same way as a String diff --git a/src/java/org/apache/commons/lang/StringUtils.java b/src/java/org/apache/commons/lang/StringUtils.java index c2c763938..fce14cb54 100644 --- a/src/java/org/apache/commons/lang/StringUtils.java +++ b/src/java/org/apache/commons/lang/StringUtils.java @@ -73,7 +73,7 @@ import java.util.Iterator; * @author Rand McNeely * @author Stephen Colebourne * @author Fredrik Westermarck - * @version $Id: StringUtils.java,v 1.19 2002/10/19 17:18:49 bayard Exp $ + * @version $Id: StringUtils.java,v 1.20 2002/10/27 19:42:04 bayard Exp $ */ public class StringUtils { @@ -1453,26 +1453,26 @@ public class StringUtils { //-------------------------------------------------------------------------- /** - * Return either the passed in String, or if it is null, + * Return either the passed in Object, or if it is null, * then an empty String. * - * @param str the String to check - * @return the passed in String, or blank if it was null + * @param str the Object to check + * @return the passed in Object's toString, or blank if it was null */ - public static String defaultString(String str) { - return defaultString(str, ""); + public static String defaultString(Object obj) { + return defaultString(obj, ""); } /** - * Return either the passed in String, or if it is null, + * Return either the passed in Object, or if it is null, * then a passed in default String. * - * @param str the String to check - * @param defaultString the default String to return is str is null + * @param obj the Object to check + * @param defaultString the default String to return if str is null * @return the passed in string, or the default if it was null */ - public static String defaultString(String str, String defaultString) { - return (str == null) ? defaultString : str; + public static String defaultString(Object obj, String defaultString) { + return (obj == null) ? defaultString : obj.toString(); } // Reversing