X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Futil%2Ffcp%2FFcpUtils.java;h=3a5d5baf55bf8d87fea6fe75d9a467c1b7b9a16b;hb=02b10d6be186d790c6beefb3f8e30f3ec14d007d;hp=a492f2e07874460d72adeab5efca89d8628593d9;hpb=9dbb34874ce7cd4fa4703f6bde00302bef2fb295;p=jSite2.git diff --git a/src/net/pterodactylus/util/fcp/FcpUtils.java b/src/net/pterodactylus/util/fcp/FcpUtils.java index a492f2e..3a5d5ba 100644 --- a/src/net/pterodactylus/util/fcp/FcpUtils.java +++ b/src/net/pterodactylus/util/fcp/FcpUtils.java @@ -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(); + } + }