* @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;
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();
+ }
+
}