UriTemplateUtil { public static String expandWithVariable(String requestPath,String matchingPatternPath,String variableName,String value){ Map<String, String> map = extractUriTemplateVariables(requestPath, matchingPatternPath); map.put(variableName, value); return expand(matchingPatternPath, map); } private  UriTemplateUtil(); static String getUriTemplateVariableValue(HttpServletRequest request,String pathVarName); static boolean hasPathVarName(HttpServletRequest request,String pathVarName); static Map<String, String> getUriTemplateVariables(HttpServletRequest request); static String getBestMatchingPattern(HttpServletRequest request); static String expandBestMatchingPattern(HttpServletRequest request,String variableName,String value); static String expandWithVariable(String requestPath,String matchingPatternPath,String variableName,String value); static String expandWithVariable(String matchingPatternPath,String variableName,String value); static String clearVariablesValue(String requestPath,String matchingPatternPath,String[] variableNames); static String retainVariablesValue(String requestPath,String matchingPatternPath,String[] variableNames); static String expand(String uriTemplatePath,Map<String, String> map); static List<String> getVariableNames(String uriTemplatePath);  }
@Test public void testExpandWithVariable(){ String result = UriTemplateUtil .expandWithVariable("/c{categoryCode}/m{material}-c{color}-s{size}-k{kind}-s{style}-o{order}.htm", "color", "a"); LOGGER.debug(result); }
@Test public void testExpandWithVariable3(){ String requestPath = "/s/c-m-c-s-k-s100-o.htm"; String matchingPatternPath = "/s/c{categoryCode}-m{material}-c{color}-s{size}-k{kind}-s{style}-o{order}.htm"; String variableName = "color"; String value = "100"; LOGGER.debug(UriTemplateUtil.expandWithVariable(requestPath, matchingPatternPath, variableName, value)); }
@Test public void testExpandWithVariable2(){ String matchingPatternPath = "/s/c{categoryCode}-m{material}-c{color}-s{size}-k{kind}-s{style}-o{order}.htm"; String variableName = "color"; String value = "100"; LOGGER.debug(UriTemplateUtil.expandWithVariable(matchingPatternPath, variableName, value)); }