From 80d827fd89567b86d3408f9125d62cf426b73662 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 23 Jul 2002 05:21:28 +0000 Subject: [PATCH] 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 --- src/java/org/apache/commons/lang/StringUtils.java | 12 +++++++++++- .../org/apache/commons/lang/StringUtilsTest.java | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/commons/lang/StringUtils.java b/src/java/org/apache/commons/lang/StringUtils.java index 2034bcffc..100b52835 100644 --- a/src/java/org/apache/commons/lang/StringUtils.java +++ b/src/java/org/apache/commons/lang/StringUtils.java @@ -80,7 +80,7 @@ import java.util.Iterator; * @author Ed Korthof * @author Stephen Colebourne - * @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 diff --git a/src/test/org/apache/commons/lang/StringUtilsTest.java b/src/test/org/apache/commons/lang/StringUtilsTest.java index 09d2b71c0..415c1dde3 100644 --- a/src/test/org/apache/commons/lang/StringUtilsTest.java +++ b/src/test/org/apache/commons/lang/StringUtilsTest.java @@ -67,7 +67,7 @@ import junit.textui.TestRunner; * @author Henri Yandell * @author Stephen Colebourne * @author Ringo De Smet - * @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,