private RouteMatch _find(RenderContext context) { // Match first the static parameteters for (RouteParam param : routeParamArray) { RenderContext.Parameter entry = context.getParameter(param.name); if (entry != null && !entry.isMatched() && param.value.equals(entry.getValue())) { entry.remove(entry.getValue()); } else { return null; } } // Match any request parameter for (RequestParam requestParamDef : requestParamArray) { RenderContext.Parameter entry = context.getParameter(requestParamDef.name); boolean matched = false; if (entry != null && !entry.isMatched()) { if (requestParamDef.matchPattern == null || context.matcher(requestParamDef.matchPattern).matches(entry.getValue())) { matched = true; } } if (matched) { entry.remove(entry.getValue()); } else { switch (requestParamDef.controlMode) { case OPTIONAL: // Do nothing break; case REQUIRED: return null; default: throw new AssertionError(); } } } // Match any pattern parameter if (this instanceof PatternRoute) { PatternRoute prt = (PatternRoute) this; for (int i = 0; i < prt.params.length; i++) { PathParam param = prt.params[i]; RenderContext.Parameter s = context.getParameter(param.name); String matched = null; if (s != null && !s.isMatched()) { switch (param.encodingMode) { case FORM: case PRESERVE_PATH: for (int j = 0; j < param.matchingRegex.length; j++) { Regex renderingRegex = param.matchingRegex[j]; if (context.matcher(renderingRegex).matches(s.getValue())) { matched = param.templatePrefixes[j] + s.getValue() + param.templateSuffixes[j]; break; } } break; default: throw new AssertionError(); } } if (matched != null) { s.remove(matched); } else { return null; } } } // if (context.isEmpty() && terminal) { Map<QualifiedName, String> matches = Collections.emptyMap(); for (QualifiedName name : context.getNames()) { RenderContext.Parameter parameter = context.getParameter(name); if (matches.isEmpty()) { matches = new HashMap<QualifiedName, String>(); } String match = parameter.getMatch(); matches.put(name, match); } return new RouteMatch(context, this, matches); } // for (Route route : children) { RouteMatch a = route.find(context); if (a != null) { return a; } } // return null; }