public static double[] parseDoubleArray(String value, boolean single,
			int tupleSize) throws Exception {
		value = value.trim();
		if (value.length() == 0)
			return new double[0];

		String[] splits = value.split(WS_COMMA_SEPARATOR);

		if (tupleSize != ARBRITARY_SIZE) {
			if (single && splits.length != tupleSize)
				throw new Exception("Expected " + tupleSize
						+ " values but found " + splits.length + " (" + value
						+ ").");

			if (!single && splits.length % tupleSize != 0)
				throw new Exception("Expected multiple of "
						+ tupleSize + " values but found " + splits.length
						+ " (" + value + ").");
		}

		double[] result = new double[splits.length];
		int i = 0;
		try {
			for (i = 0; i < splits.length; i++) {
				result[i] = Double.parseDouble(splits[i]);
			}
		} catch (NumberFormatException e) {
			throw new IllegalArgumentException("Error parsing value number "
					+ i + ".", e);
		}
		return result;
	}