if (matchedLength > 0) {
if (matchedLength != -1) {
    protected void beforeHandle(Request request, Response response) {        if (getTemplate() != null) {            String remainingPart = request.getResourceRef().getRemainingPart();            int matchedLength = getTemplate().parse(remainingPart, request);            if (getLogger().isLoggable(Level.FINER)) {                getLogger().finer(                        "Attempting to match this pattern: "                                + getTemplate().getPattern() + " >> "                                + matchedLength);            }            if (matchedLength > 0) {                // Updates the context                String matchedPart = remainingPart.substring(0, matchedLength);                Reference baseRef = request.getResourceRef().getBaseRef();                if (baseRef == null) {                    baseRef = new Reference(matchedPart);                } else {                    baseRef = new Reference(baseRef.toString(false, false)                            + matchedPart);                }                request.getResourceRef().setBaseRef(baseRef);                if (getLogger().isLoggable(Level.FINE)) {                    getLogger().fine(                            "New base URI: "                                    + request.getResourceRef().getBaseRef());                    getLogger().fine(                            "New remaining part: "                                    + request.getResourceRef()                                            .getRemainingPart());                }                if (getLogger().isLoggable(Level.FINE)) {                    getLogger().fine(                            "Delegating the call to the target Restlet");                }            } else {                response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);            }        }        // Now extract attributes        extractAttributes(request, response);    }