add ListPersistentRequests and WatchGlobal command
[jSite2.git] / src / net / pterodactylus / util / fcp / FcpUtils.java
index a492f2e..3a5d5ba 100644 (file)
@@ -35,7 +35,7 @@ public class FcpUtils {
         * @throws NumberFormatException
         *             if a value can not be converted to a number
         */
-       public static int[] parseMultiIntegerField(String field) throws NumberFormatException {
+       public static int[] decodeMultiIntegerField(String field) throws NumberFormatException {
                StringTokenizer fieldTokens = new StringTokenizer(field, ";");
                int[] result = new int[fieldTokens.countTokens()];
                int counter = 0;
@@ -46,4 +46,23 @@ public class FcpUtils {
                return result;
        }
 
+       /**
+        * Encodes the given integer array into a string, separating the values by
+        * ‘;’.
+        * 
+        * @param values
+        *            The values to encode
+        * @return The encoded values
+        */
+       public static String encodeMultiIntegerField(int[] values) {
+               StringBuilder encodedField = new StringBuilder();
+               for (int value: values) {
+                       if (encodedField.length() > 0) {
+                               encodedField.append(';');
+                       }
+                       encodedField.append(value);
+               }
+               return encodedField.toString();
+       }
+
 }