public RewriteHandler() { _rules = new RuleContainer(); }
/** * Add a Rule * @param rule The rule to add to the end of the rules array */ public void addRule(Rule rule) { _rules.addRule(rule); }
/** * Process the contained rules * @param target target field to pass on to the contained rules * @param request request object to pass on to the contained rules * @param response response object to pass on to the contained rules */ @Override public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException { return apply(target, request, response); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isStarted()) { String returned = _rules.matchAndApply(target, request, response); target = (returned == null) ? target : returned; if (!baseRequest.isHandled()) super.handle(target, baseRequest, request, response); } }
/** * Returns the list of rules. * @return an array of {@link Rule}. */ public Rule[] getRules() { return _rules.getRules(); }
/** * @return the originalPathAttribte. If non null, this string will be used * as the attribute name to store the original request path. */ public String getOriginalPathAttribute() { return _rules.getOriginalPathAttribute(); }
/** * @return the rewriteRequestURI If true, this handler will rewrite the value * returned by {@link HttpServletRequest#getRequestURI()}. */ public boolean isRewriteRequestURI() { return _rules.isRewriteRequestURI(); }
/** * @return true if this handler will rewrite the value * returned by {@link HttpServletRequest#getPathInfo()}. */ public boolean isRewritePathInfo() { return _rules.isRewritePathInfo(); }
/** * @param originalPathAttribute If non null, this string will be used * as the attribute name to store the original request path. */ public void setOriginalPathAttribute(String originalPathAttribute) { _rules.setOriginalPathAttribute(originalPathAttribute); }
/** * @param rewritePathInfo true if this handler will rewrite the value * returned by {@link HttpServletRequest#getPathInfo()}. */ public void setRewritePathInfo(boolean rewritePathInfo) { _rules.setRewritePathInfo(rewritePathInfo); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isStarted()) { String returned = _rules.matchAndApply(target, request, response); target = (returned == null) ? target : returned; if (!baseRequest.isHandled()) super.handle(target, baseRequest, request, response); } }
/** * Returns the list of rules. * @return an array of {@link Rule}. */ public Rule[] getRules() { return _rules.getRules(); }
/** * @return the originalPathAttribte. If non null, this string will be used * as the attribute name to store the original request path. */ public String getOriginalPathAttribute() { return _rules.getOriginalPathAttribute(); }
/** * @return the rewriteRequestURI If true, this handler will rewrite the value * returned by {@link HttpServletRequest#getRequestURI()}. */ public boolean isRewriteRequestURI() { return _rules.isRewriteRequestURI(); }
/** * @return true if this handler will rewrite the value * returned by {@link HttpServletRequest#getPathInfo()}. */ public boolean isRewritePathInfo() { return _rules.isRewritePathInfo(); }
/** * @param originalPathAttribute If non null, this string will be used * as the attribute name to store the original request path. */ public void setOriginalPathAttribute(String originalPathAttribute) { _rules.setOriginalPathAttribute(originalPathAttribute); }
/** * @param rewritePathInfo true if this handler will rewrite the value * returned by {@link HttpServletRequest#getPathInfo()}. */ public void setRewritePathInfo(boolean rewritePathInfo) { _rules.setRewritePathInfo(rewritePathInfo); }
/** * Add a Rule * @param rule The rule to add to the end of the rules array */ public void addRule(Rule rule) { _rules.addRule(rule); }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (isStarted()) { String returned = _rules.matchAndApply(target, request, response); target = (returned == null) ? target : returned; if (!baseRequest.isHandled()) super.handle(target, baseRequest, request, response); } }
/** * Process the contained rules * @param target target field to pass on to the contained rules * @param request request object to pass on to the contained rules * @param response response object to pass on to the contained rules */ @Override public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException { return apply(target, request, response); }