Author: toad
Date: 2006-12-22 01:29:18 +0000 (Fri, 22 Dec 2006)
New Revision: 11509

Modified:
   trunk/freenet/src/freenet/config/StringArrOption.java
Log:
String array options: "" means no values (String[0]). "" in an option is 
represented as ":".

Modified: trunk/freenet/src/freenet/config/StringArrOption.java
===================================================================
--- trunk/freenet/src/freenet/config/StringArrOption.java       2006-12-21 
23:12:24 UTC (rev 11508)
+++ trunk/freenet/src/freenet/config/StringArrOption.java       2006-12-22 
01:29:18 UTC (rev 11509)
@@ -44,9 +44,14 @@
        }

        private String[] stringToArray(String val) throws 
URLEncodedFormatException {
+               if(val.length() == 0) return new String[0];
                String[] out = val.split(delimiter);
-               for(int i=0;i<out.length;i++)
-                       out[i] = URLDecoder.decode(out[i], true /* FIXME false 
*/);
+               for(int i=0;i<out.length;i++) {
+                       if(out[i].equals(":"))
+                               out[i] = "";
+                       else
+                               out[i] = URLDecoder.decode(out[i], true /* 
FIXME false */);
+               }
                return out;
        }

@@ -70,8 +75,13 @@
                if (arr == null)
                        return null;
                StringBuffer sb = new StringBuffer();
-               for (int i = 0 ; i < arr.length ; i++)
-                       sb.append(URLEncoder.encode(arr[i])).append(delimiter);
+               for (int i = 0 ; i < arr.length ; i++) {
+                       String val = arr[i];
+                       if(val.length() == 0)
+                               sb.append(":").append(delimiter);
+                       else
+                               
sb.append(URLEncoder.encode(arr[i])).append(delimiter);
+               }
                if(sb.length() > 0) sb.setLength(sb.length()-1); // drop 
surplus delimiter
                return sb.toString();
        }


Reply via email to