@Test public void testExtractOptionalFieldParams() { Map<String, String> values = optionalView.extractOptionalFieldParams("attendances.1"); assertEquals("Should match", "attendances", values.get(OptionalFieldAppenderFactory.APPENDER_PREFIX)); assertEquals("Should match", "1", values.get(OptionalFieldAppenderFactory.PARAM_PREFIX)); values = optionalView.extractOptionalFieldParams("attendances"); assertEquals("Should match", "attendances", values.get(OptionalFieldAppenderFactory.APPENDER_PREFIX)); assertEquals("Should match", null, values.get(OptionalFieldAppenderFactory.PARAM_PREFIX)); values = optionalView.extractOptionalFieldParams("attendances.1.2.3"); assertEquals("Should match", "attendances", values.get(OptionalFieldAppenderFactory.APPENDER_PREFIX)); assertEquals("Should match", "1", values.get(OptionalFieldAppenderFactory.PARAM_PREFIX)); values = optionalView.extractOptionalFieldParams("attendances%1"); assertEquals("Should match", "attendances%1", values.get(OptionalFieldAppenderFactory.APPENDER_PREFIX)); assertEquals("Should match", null, values.get(OptionalFieldAppenderFactory.PARAM_PREFIX)); values = optionalView.extractOptionalFieldParams("attendances.someparam"); assertEquals("Should match", "attendances", values.get(OptionalFieldAppenderFactory.APPENDER_PREFIX)); assertEquals("Should match", "someparam", values.get(OptionalFieldAppenderFactory.PARAM_PREFIX)); }
protected Map<String, String> extractOptionalFieldParams(String optionalFieldValue) { Map<String, String> values = new HashMap<String, String>(); String appender = null, params = null; if (optionalFieldValue.contains(".")) { StringTokenizer st = new StringTokenizer(optionalFieldValue, "."); int index = 0; String token = null; while (st.hasMoreTokens()) { token = st.nextToken(); switch (index) { case 0: appender = token; break; case 1: params = token; break; } ++index; } } else { appender = optionalFieldValue; } values.put(OptionalFieldAppenderFactory.APPENDER_PREFIX, appender); values.put(OptionalFieldAppenderFactory.PARAM_PREFIX, params); return values; }
OptionalView implements View { protected Map<String, String> extractOptionalFieldParams(String optionalFieldValue) { Map<String, String> values = new HashMap<String, String>(); String appender = null, params = null; if (optionalFieldValue.contains(".")) { StringTokenizer st = new StringTokenizer(optionalFieldValue, "."); int index = 0; String token = null; while (st.hasMoreTokens()) { token = st.nextToken(); switch (index) { case 0: appender = token; break; case 1: params = token; break; } ++index; } } else { appender = optionalFieldValue; } values.put(OptionalFieldAppenderFactory.APPENDER_PREFIX, appender); values.put(OptionalFieldAppenderFactory.PARAM_PREFIX, params); return values; } }
OptionalView implements View { protected Map<String, String> extractOptionalFieldParams(String optionalFieldValue) { Map<String, String> values = new HashMap<String, String>(); String appender = null, params = null; if (optionalFieldValue.contains(".")) { StringTokenizer st = new StringTokenizer(optionalFieldValue, "."); int index = 0; String token = null; while (st.hasMoreTokens()) { token = st.nextToken(); switch (index) { case 0: appender = token; break; case 1: params = token; break; } ++index; } } else { appender = optionalFieldValue; } values.put(OptionalFieldAppenderFactory.APPENDER_PREFIX, appender); values.put(OptionalFieldAppenderFactory.PARAM_PREFIX, params); return values; }  }
OptionalView implements View { protected Map<String, String> extractOptionalFieldParams(String optionalFieldValue) { Map<String, String> values = new HashMap<String, String>(); String appender = null, params = null; if (optionalFieldValue.contains(".")) { StringTokenizer st = new StringTokenizer(optionalFieldValue, "."); int index = 0; String token = null; while (st.hasMoreTokens()) { token = st.nextToken(); switch (index) { case 0: appender = token; break; case 1: params = token; break; } ++index; } } else { appender = optionalFieldValue; } values.put(OptionalFieldAppenderFactory.APPENDER_PREFIX, appender); values.put(OptionalFieldAppenderFactory.PARAM_PREFIX, params); return values; }  @Override List<EntityBody> add(List<EntityBody> entities, final String resource, MultivaluedMap<String, String> queryParams); }
OptionalView implements View { protected Map<String, String> extractOptionalFieldParams(String optionalFieldValue) { Map<String, String> values = new HashMap<String, String>(); String appender = null, params = null; if (optionalFieldValue.contains(".")) { StringTokenizer st = new StringTokenizer(optionalFieldValue, "."); int index = 0; String token = null; while (st.hasMoreTokens()) { token = st.nextToken(); switch (index) { case 0: appender = token; break; case 1: params = token; break; } ++index; } } else { appender = optionalFieldValue; } values.put(OptionalFieldAppenderFactory.APPENDER_PREFIX, appender); values.put(OptionalFieldAppenderFactory.PARAM_PREFIX, params); return values; }  @Override List<EntityBody> add(List<EntityBody> entities, final String resource, MultivaluedMap<String, String> queryParams);  }