/** * @param key the key for the desired parameter * @return an array of Number objects associated with the given key, * or <code>null</code> if Numbers are not associated with it. */ public Number[] getNumbers(String key) { Object[] array = getValues(key); if (array == null || Number.class.isAssignableFrom(array.getClass().getComponentType())) { return (Number[])array; } Number[] ret = new Number[array.length]; for (int i = 0; i < array.length; ++i) { ret[i] = ConversionUtils.toNumber(array[i], getFormat(), getLocale()); } return ret; }
/** * @param key the desired parameter's key * @return a {@link Integer} for the specified key or * <code>null</code> if no matching parameter is found */ public Integer getInteger(String key) { Object value = getValue(key); if (value == null) { return null; } Number number = ConversionUtils.toNumber(value, getFormat(), getLocale()); return number == null ? null : number.intValue(); }
/** * @param key the desired parameter's key * @return a {@link Double} for the specified key or * <code>null</code> if no matching parameter is found */ public Double getDouble(String key) { Object value = getValue(key); if (value == null) { return null; } Number number = ConversionUtils.toNumber(value, getFormat(), getLocale()); return number == null ? null : number.doubleValue(); }
/** * @param key the key for the desired parameter * @return an array of int values associated with the given key, * or <code>null</code> if numbers are not associated with it. */ public int[] getInts(String key) { Object[] array = getValues(key); if (array == null) { return null; } int[] ret = new int[array.length]; for (int i = 0; i < array.length; ++i) { ret[i] = ConversionUtils.toNumber(array[i], getFormat(), getLocale()).intValue(); } return ret; }
/** * @param key the desired parameter's key * @return a {@link Number} for the specified key or * <code>null</code> if no matching parameter is found */ public Number getNumber(String key) { return ConversionUtils.toNumber(getValue(key), getFormat(), getLocale()); }
/** * @param key the key for the desired parameter * @return an array of double values associated with the given key, * or <code>null</code> if numbers are not associated with it. */ public double[] getDoubles(String key) { Object[] array = getValues(key); if (array == null) { return null; } double[] ret = new double[array.length]; for (int i = 0; i < array.length; ++i) { ret[i] = ConversionUtils.toNumber(array[i], getFormat(), getLocale()).doubleValue(); } return ret; }