X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fpterodactylus%2Futil%2Ffcp%2FFcpUtils.java;h=a492f2e07874460d72adeab5efca89d8628593d9;hb=9dbb34874ce7cd4fa4703f6bde00302bef2fb295;hp=989261001bf1924d1b66a7f97402bcfd3cef987d;hpb=302d406851939b0b804320c648f2346c0952ae3d;p=jSite2.git diff --git a/src/net/pterodactylus/util/fcp/FcpUtils.java b/src/net/pterodactylus/util/fcp/FcpUtils.java index 9892610..a492f2e 100644 --- a/src/net/pterodactylus/util/fcp/FcpUtils.java +++ b/src/net/pterodactylus/util/fcp/FcpUtils.java @@ -3,6 +3,7 @@ */ package net.pterodactylus.util.fcp; +import java.util.StringTokenizer; import java.util.concurrent.atomic.AtomicLong; /** @@ -25,4 +26,24 @@ public class FcpUtils { return new StringBuilder().append(System.currentTimeMillis()).append('-').append(counter.getAndIncrement()).toString(); } + /** + * Parses an integer field, separated by ‘;’ and returns the parsed values. + * + * @param field + * The field to parse + * @return An array with the parsed values + * @throws NumberFormatException + * if a value can not be converted to a number + */ + public static int[] parseMultiIntegerField(String field) throws NumberFormatException { + StringTokenizer fieldTokens = new StringTokenizer(field, ";"); + int[] result = new int[fieldTokens.countTokens()]; + int counter = 0; + while (fieldTokens.hasMoreTokens()) { + String fieldToken = fieldTokens.nextToken(); + result[counter++] = Integer.valueOf(fieldToken); + } + return result; + } + }