diff --git a/src/java/com/samskivert/util/StringUtil.java b/src/java/com/samskivert/util/StringUtil.java index d778bbca..8ebe62da 100644 --- a/src/java/com/samskivert/util/StringUtil.java +++ b/src/java/com/samskivert/util/StringUtil.java @@ -934,6 +934,23 @@ public class StringUtil return vals; } + /** + * Parses an array of booleans from its string representation. The array should be represented + * as a bare list of numbers separated by commas, for example: + * + *
false, false, true, false+ */ + public static boolean[] parseBooleanArray (String source) + { + StringTokenizer tok = new StringTokenizer(source, ","); + boolean[] vals = new boolean[tok.countTokens()]; + for (int i = 0; tok.hasMoreTokens(); i++) { + // trim the whitespace from the token + vals[i] = Boolean.parseBoolean(tok.nextToken().trim()); + } + return vals; + } + /** * Parses an array of strings from a single string. The array should be represented as a bare * list of strings separated by commas, for example: