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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

jleroux@apache.org
Author: jleroux
Date: Fri Dec  9 22:50:01 2011
New Revision: 1212673

URL: http://svn.apache.org/viewvc?rev=1212673&view=rev
Log:
Improves StringUtil.strToMap() by adding a delimiter as parameter

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=1212673&r1=1212672&r2=1212673&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 Fri Dec  9 22:50:01 2011
@@ -223,13 +223,14 @@ public class StringUtil {
     /**
      * Creates a Map from an encoded name/value pair string
      * @param str The string to decode and format
+     * @param delim the delimiter character(s) to join on (null will split on whitespace)
      * @param trim Trim whitespace off fields
      * @return a Map of name/value pairs
      */
-    public static Map<String, String> strToMap(String str, boolean trim) {
+    public static Map<String, String> strToMap(String str, String delim, boolean trim) {
         if (str == null) return null;
         Map<String, String> decodedMap = FastMap.newInstance();
-        List<String> elements = split(str, "|");
+        List<String> elements = split(str, delim);
 
         for (String s: elements) {
             List<String> e = split(s, "=");
@@ -263,7 +264,16 @@ public class StringUtil {
      * @return a Map of name/value pairs
      */
     public static Map<String, String> strToMap(String str) {
-        return strToMap(str, false);
+        return strToMap(str, "|", false);
+    }
+
+    /**
+     * Creates a Map from an encoded name/value pair string
+     * @param str The string to decode and format
+     * @return a Map of name/value pairs
+     */
+    public static Map<String, String> strToMap(String str, String delim) {
+        return strToMap(str, delim, false);
     }
 
     /**