Added a concatenate method. While this is just a join with a "" delimiter,

the Avalon StringUtil shows that this is a valid way of looking at the
functionality.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@136939 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2002-07-23 05:21:28 +00:00
parent 46872f9f52
commit 80d827fd89
2 changed files with 14 additions and 2 deletions

View File

@ -80,7 +80,7 @@ import java.util.Iterator;
* @author <a href="mailto:ed@apache.org">Ed Korthof</a>
* @author <a href="mailto:rand_mcneely@yahoo.com>Rand McNeely</a>
* @author <a href="mailto:scolebourne@joda.org>Stephen Colebourne</a>
* @version $Id: StringUtils.java,v 1.3 2002/07/21 20:19:50 bayard Exp $
* @version $Id: StringUtils.java,v 1.4 2002/07/23 05:21:28 bayard Exp $
*/
public class StringUtils {
@ -469,6 +469,16 @@ public class StringUtils {
// Joining
//--------------------------------------------------------------------------
/**
* Concatenates elements of an array into a single string.
* The difference from join is that concatenate has no delimiter.
*
* @param array the array of values to concatenate.
* @return the concatenated string.
*/
public static String concatenate(Object[] array) {
return join(array, "");
}
/**
* Joins the elements of the provided array into a single string

View File

@ -67,7 +67,7 @@ import junit.textui.TestRunner;
* @author <a href="mailto:bayard@generationjava.com">Henri Yandell</a>
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
* @version $Id: StringUtilsTest.java,v 1.1 2002/07/19 03:35:55 bayard Exp $
* @version $Id: StringUtilsTest.java,v 1.2 2002/07/23 05:21:27 bayard Exp $
*/
public class StringUtilsTest extends TestCase
{
@ -142,6 +142,8 @@ public class StringUtilsTest extends TestCase
public void testJoin()
{
assertEquals("concatenate(Object[]) failed",
"foobarbaz", StringUtils.concatenate(ARRAY_LIST));
assertEquals("join(Object[], String) failed", TEXT_LIST,
StringUtils.join(ARRAY_LIST, SEPARATOR));
assertEquals("join(Iterator, String) failed", TEXT_LIST,