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
This commit is contained in:
Henri Yandell 2002-10-27 19:42:04 +00:00
parent 870097e4b1
commit b556203db7
2 changed files with 12 additions and 14 deletions

View File

@ -7,7 +7,7 @@
<div align="center">
<h1>The Jakarta Commons <em>Lang</em> Component</h1>
$Id: STATUS.html,v 1.22 2002/10/04 03:22:47 bayard Exp $<br />
$Id: STATUS.html,v 1.23 2002/10/27 19:42:04 bayard Exp $<br />
<a href="#Introduction">[Introduction]</a>
<a href="#Dependencies">[Dependencies]</a>
<a href="#Release Info">[Release Info]</a>
@ -91,8 +91,6 @@ still under discussion, so please mail the list before actioning.</p>
<li>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]</li>
<li>StringUtils uncapitaliseAllWords method - String Taglib has shown that this method is missing from StringUtils. [CODED]</li>
<li>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. </li>
<li>StringUtils defaultStirng(Object) method - simliar behavior to defaultString(String), returns obj.toString() if obj != null, "" otherwise
<li>StringUtils defaultString(Object, String) method - similar behavior to defaultString(String, String), returns obj.toString() if obj != null, specified string otherwise
<li>ArrayUtils - opinion seems to be that this belongs with [lang] and not [collections]
<li>GUID and other Identifier generators - these may belong in [util], some code exists in [pattern] at the moment
<li>CharUtils - Utilities to work on a char[] in the same way as a String

View File

@ -73,7 +73,7 @@ import java.util.Iterator;
* @author <a href="mailto:rand_mcneely@yahoo.com">Rand McNeely</a>
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
* @author <a href="mailto:fredrik@westermarck.com">Fredrik Westermarck</a>
* @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 <code>null</code>,
* Return either the passed in Object, or if it is <code>null</code>,
* 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 <code>null</code>,
* Return either the passed in Object, or if it is <code>null</code>,
* 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