/** * Creates a new route for the given URI pattern, target and matching mode. The route will match * the URI query string depending on the result of {@link #getDefaultMatchingQuery()}. * * @param uriPattern The URI pattern that must match the relative part of the resource URI. * @param target The target Restlet to attach. * @param matchingMode The matching mode. * @return The created route. */ protected TemplateRoute createRoute(String uriPattern, Restlet target, int matchingMode) { TemplateRoute result = new TemplateRoute(this, uriPattern, target); result.getTemplate().setMatchingMode(matchingMode); result.setMatchingQuery(getDefaultMatchingQuery()); return result; }
/** * Attaches a Restlet to this router as the default target to invoke when no route matches. It * actually sets a default route that scores all calls to 1.0. * * @param defaultTarget The Restlet to use as the default target. * @return The created route. */ public TemplateRoute attachDefault(Restlet defaultTarget) { TemplateRoute result = createRoute("", defaultTarget); result.setMatchingMode(Template.MODE_STARTS_WITH); setDefaultRoute(result); return result; }