@Test public void testGetKeyedIntegerArray() { assertArrayEquals(INT_ARRAY_VAL, ParameterMap.getKeyedIntegerArray(m_map, "keyedIntegerArray", DEFAULT_INT_ARRAY)); assertArrayEquals(INT_ARRAY_VAL, ParameterMap.getKeyedIntegerArray(m_map, "keyedIntegerArrayStringWithColons", DEFAULT_INT_ARRAY)); assertArrayEquals(INT_ARRAY_VAL, ParameterMap.getKeyedIntegerArray(m_map, "keyedIntegerArrayStringWithSpaces", DEFAULT_INT_ARRAY)); assertArrayEquals(INT_ARRAY_VAL, ParameterMap.getKeyedIntegerArray(m_map, "keyedIntegerArrayStringWithSemis", DEFAULT_INT_ARRAY)); assertArrayEquals(INT_ARRAY_VAL, ParameterMap.getKeyedIntegerArray(m_map, "keyedIntegerArrayStringWithCommas", DEFAULT_INT_ARRAY)); assertArrayEquals(DEFAULT_INT_ARRAY, ParameterMap.getKeyedIntegerArray(m_map, "noSuchKey", DEFAULT_INT_ARRAY)); assertArrayEquals(DEFAULT_INT_ARRAY, ParameterMap.getKeyedIntegerArray(null, "keyedIntegerArray", DEFAULT_INT_ARRAY)); }
@SuppressWarnings("unchecked") public final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues) { if (map == null) return defValues; int[] result = defValues; Object oValue = map.get(key); if (oValue != null && oValue instanceof int[]) { result = (int[]) oValue; } else if (oValue != null) { List<Integer> tmpList = new ArrayList<Integer>(5); StringTokenizer ints = new StringTokenizer(oValue.toString(), " ;:,"); while (ints.hasMoreElements()) { String token = ints.nextToken(); try { int x = Integer.parseInt(token); tmpList.add(Integer.valueOf(x)); } catch (NumberFormatException e) { LogUtils.warnf(ParameterMap.class, e, "getKeyedIntegerArray: failed to convert value %s to int array for key %s due to value %s", oValue, key, token); } } result = new int[tmpList.size()]; for (int x = 0; x < result.length; x++) result[x] = ((Integer) tmpList.get(x)).intValue(); map.put(key, result); } return result; }
ParameterMap { @SuppressWarnings("unchecked") public final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues) { if (map == null) return defValues; int[] result = defValues; Object oValue = map.get(key); if (oValue != null && oValue instanceof int[]) { result = (int[]) oValue; } else if (oValue != null) { List<Integer> tmpList = new ArrayList<Integer>(5); StringTokenizer ints = new StringTokenizer(oValue.toString(), " ;:,"); while (ints.hasMoreElements()) { String token = ints.nextToken(); try { int x = Integer.parseInt(token); tmpList.add(Integer.valueOf(x)); } catch (NumberFormatException e) { LogUtils.warnf(ParameterMap.class, e, "getKeyedIntegerArray: failed to convert value %s to int array for key %s due to value %s", oValue, key, token); } } result = new int[tmpList.size()]; for (int x = 0; x < result.length; x++) result[x] = ((Integer) tmpList.get(x)).intValue(); map.put(key, result); } return result; } }
ParameterMap { @SuppressWarnings("unchecked") public final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues) { if (map == null) return defValues; int[] result = defValues; Object oValue = map.get(key); if (oValue != null && oValue instanceof int[]) { result = (int[]) oValue; } else if (oValue != null) { List<Integer> tmpList = new ArrayList<Integer>(5); StringTokenizer ints = new StringTokenizer(oValue.toString(), " ;:,"); while (ints.hasMoreElements()) { String token = ints.nextToken(); try { int x = Integer.parseInt(token); tmpList.add(Integer.valueOf(x)); } catch (NumberFormatException e) { LogUtils.warnf(ParameterMap.class, e, "getKeyedIntegerArray: failed to convert value %s to int array for key %s due to value %s", oValue, key, token); } } result = new int[tmpList.size()]; for (int x = 0; x < result.length; x++) result[x] = ((Integer) tmpList.get(x)).intValue(); map.put(key, result); } return result; }  }
ParameterMap { @SuppressWarnings("unchecked") public final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues) { if (map == null) return defValues; int[] result = defValues; Object oValue = map.get(key); if (oValue != null && oValue instanceof int[]) { result = (int[]) oValue; } else if (oValue != null) { List<Integer> tmpList = new ArrayList<Integer>(5); StringTokenizer ints = new StringTokenizer(oValue.toString(), " ;:,"); while (ints.hasMoreElements()) { String token = ints.nextToken(); try { int x = Integer.parseInt(token); tmpList.add(Integer.valueOf(x)); } catch (NumberFormatException e) { LogUtils.warnf(ParameterMap.class, e, "getKeyedIntegerArray: failed to convert value %s to int array for key %s due to value %s", oValue, key, token); } } result = new int[tmpList.size()]; for (int x = 0; x < result.length; x++) result[x] = ((Integer) tmpList.get(x)).intValue(); map.put(key, result); } return result; }  @SuppressWarnings("unchecked") static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue); static int getKeyedInteger(@SuppressWarnings("rawtypes") final Map map, final String key, final int defValue); @SuppressWarnings("unchecked") final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues); @SuppressWarnings("unchecked") static String getKeyedString(@SuppressWarnings("rawtypes") final Map map, final String key, final String defValue); @SuppressWarnings("unchecked") static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue); static T getKeyedValue(final Map<String,T> map, final String key, final T defValue); }
ParameterMap { @SuppressWarnings("unchecked") public final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues) { if (map == null) return defValues; int[] result = defValues; Object oValue = map.get(key); if (oValue != null && oValue instanceof int[]) { result = (int[]) oValue; } else if (oValue != null) { List<Integer> tmpList = new ArrayList<Integer>(5); StringTokenizer ints = new StringTokenizer(oValue.toString(), " ;:,"); while (ints.hasMoreElements()) { String token = ints.nextToken(); try { int x = Integer.parseInt(token); tmpList.add(Integer.valueOf(x)); } catch (NumberFormatException e) { LogUtils.warnf(ParameterMap.class, e, "getKeyedIntegerArray: failed to convert value %s to int array for key %s due to value %s", oValue, key, token); } } result = new int[tmpList.size()]; for (int x = 0; x < result.length; x++) result[x] = ((Integer) tmpList.get(x)).intValue(); map.put(key, result); } return result; }  @SuppressWarnings("unchecked") static long getKeyedLong(@SuppressWarnings("rawtypes") final Map map, final String key, final long defValue); static int getKeyedInteger(@SuppressWarnings("rawtypes") final Map map, final String key, final int defValue); @SuppressWarnings("unchecked") final static int[] getKeyedIntegerArray(@SuppressWarnings("rawtypes") final Map map, final String key, final int[] defValues); @SuppressWarnings("unchecked") static String getKeyedString(@SuppressWarnings("rawtypes") final Map map, final String key, final String defValue); @SuppressWarnings("unchecked") static boolean getKeyedBoolean(@SuppressWarnings("rawtypes") final Map map, final String key, final boolean defValue); static T getKeyedValue(final Map<String,T> map, final String key, final T defValue);  }