You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2013/05/13 22:06:11 UTC

svn commit: r1482069 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java

Author: doogie
Date: Mon May 13 20:06:11 2013
New Revision: 1482069

URL: http://svn.apache.org/r1482069
Log:
FEATURE: Add a join() variant that takes a collection.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=1482069&r1=1482068&r2=1482069&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Mon May 13 20:06:11 2013
@@ -165,10 +165,20 @@ public class StringUtil {
      * @return a String of all values in the list seperated by the delimiter
      */
     public static String join(List<?> list, String delim) {
-        if (UtilValidate.isEmpty(list))
+        return join ((Collection<?>) list, delim);
+    }
+
+    /**
+     * Creates a single string from a Collection of strings seperated by a delimiter.
+     * @param col a collection of strings to join
+     * @param delim the delimiter character(s) to use. (null value will join with no delimiter)
+     * @return a String of all values in the collection seperated by the delimiter
+     */
+    public static String join(Collection<?> col, String delim) {
+        if (UtilValidate.isEmpty(col))
             return null;
         StringBuilder buf = new StringBuilder();
-        Iterator<?> i = list.iterator();
+        Iterator<?> i = col.iterator();
 
         while (i.hasNext()) {
             buf.append(i.next());