## org.mortbay.jetty.handler.rewrite
Class RuleContainer

    java.lang.Object
      org.mortbay.jetty.handler.rewrite.Rule
          org.mortbay.jetty.handler.rewrite.RuleContainer

Direct Known Subclasses:
  LowThreadsRuleContainer, VirtualHostRuleContainer

    public class RuleContainer

extends Rule

Base container to group rules. Can be extended so that the contained rules will only be applied under certain conditions

Author:
  Athena Yao

Field Summary
`protected boolean` `_handled`
`protected LegacyRule` `_legacy`
`protected java.lang.String` `_originalPathAttribute`
`protected boolean` `_rewritePathInfo`
`protected boolean` `_rewriteRequestURI`
`protected Rule[]` `_rules`

Fields inherited from class org.mortbay.jetty.handler.rewrite.Rule
`_handling, _terminating`

Constructor Summary
`RuleContainer()`

Method Summary
`void` `addRewriteRule(java.lang.String pattern, java.lang.String prefix)` Deprecated.
`void` `addRule(Rule rule)` Add a Rule
`protected java.lang.String` `apply(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Process the contained rules (called by matchAndApply)
`java.lang.String` `getOriginalPathAttribute()`
`PathMap` `getRewrite()` Deprecated.
`Rule[]` `getRules()` Returns the list of rules.
`boolean` `isHandled()` Deprecated. not thread safe, better to rely on baseRequest.isHandled()
`boolean` `isRewritePathInfo()`
`boolean` `isRewriteRequestURI()`
`java.lang.String` `matchAndApply(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Process the contained rules
`void` `setHandled(boolean handled)` Deprecated. best to use the baseRequest.isHandled()
`void` `setLegacyRule(LegacyRule legacyRule)` To enable configuration from jetty.xml on rewriteRequestURI, rewritePathInfo and originalPathAttribute
`void` `setOriginalPathAttribute(java.lang.String originalPathAttribte)`
`void` `setRewrite(PathMap rewrite)` Deprecated.
`void` `setRewritePathInfo(boolean rewritePathInfo)`
`void` `setRewriteRequestURI(boolean rewriteRequestURI)`
`void` `setRules(Rule[] rules)` Assigns the rules to process.

Methods inherited from class org.mortbay.jetty.handler.rewrite.Rule
`isHandling, isTerminating, setHandling, setTerminating, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### _rules

    protected Rule[] _rules

### _handled

    protected boolean _handled

### _originalPathAttribute

    protected java.lang.String _originalPathAttribute

### _rewriteRequestURI

    protected boolean _rewriteRequestURI

### _rewritePathInfo

    protected boolean _rewritePathInfo

### _legacy

    protected LegacyRule _legacy

Constructor Detail

### RuleContainer

    public RuleContainer()

Method Detail

### setLegacyRule

    public void setLegacyRule(LegacyRule legacyRule)

  To enable configuration from jetty.xml on rewriteRequestURI, rewritePathInfo and originalPathAttribute

  Parameters:
    `legacyRule` - old style rewrite rule

### getRules

    public Rule[] getRules()

  Returns the list of rules.

  Returns:
    an array of `Rule`.

### setRules

    public void setRules(Rule[] rules)

  Assigns the rules to process.

  Parameters:
    `rules` - an array of `Rule`.

### addRule

    public void addRule(Rule rule)

  Add a Rule

  Parameters:
    `rule` - The rule to add to the end of the rules array

### isRewriteRequestURI

    public boolean isRewriteRequestURI()

  Returns:
    the rewriteRequestURI If true, this handler will rewrite the value returned by `HttpServletRequest.getRequestURI()`.

### setRewriteRequestURI

    public void setRewriteRequestURI(boolean rewriteRequestURI)

  Parameters:
    `rewriteRequestURI` - true if this handler will rewrite the value returned by `HttpServletRequest.getRequestURI()`.

### isRewritePathInfo

    public boolean isRewritePathInfo()

  Returns:
    true if this handler will rewrite the value returned by `HttpServletRequest.getPathInfo()`.

### setRewritePathInfo

    public void setRewritePathInfo(boolean rewritePathInfo)

  Parameters:
    `rewritePathInfo` - true if this handler will rewrite the value returned by `HttpServletRequest.getPathInfo()`.

### getOriginalPathAttribute

    public java.lang.String getOriginalPathAttribute()

  Returns:
    the originalPathAttribte. If non null, this string will be used as the attribute name to store the original request path.

### setOriginalPathAttribute

    public void setOriginalPathAttribute(java.lang.String originalPathAttribte)

  Parameters:
    `originalPathAttribte` - If non null, this string will be used as the attribute name to store the original request path.

### getRewrite

    public PathMap getRewrite()

  Deprecated.

### setRewrite

    public void setRewrite(PathMap rewrite)

  Deprecated.

### addRewriteRule

    public void addRewriteRule(java.lang.String pattern,
                               java.lang.String prefix)

  Deprecated.

### isHandled

    public boolean isHandled()

  Deprecated. not thread safe, better to rely on baseRequest.isHandled()

  Returns:
    handled true if one of the rules within the rule container is handling the request
  See Also:
    `http://jira.codehaus.org/browse/JETTY-1287`

### setHandled

    public void setHandled(boolean handled)

  Deprecated. best to use the baseRequest.isHandled()

  Parameters:
    `handled` - true if one of the rules within the rule container is handling the request

### matchAndApply

    public java.lang.String matchAndApply(java.lang.String target,
                                          javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)
                                   throws java.io.IOException

  Process the contained rules

  Specified by:
    `matchAndApply` in class `Rule`
  Parameters:
    `target` - target field to pass on to the contained rules
    `request` - request object to pass on to the contained rules
    `response` - response object to pass on to the contained rules
  Returns:
    The new target if the rule has matched, else null
  Throws:
    `java.io.IOException` - TODO

### apply

    protected java.lang.String apply(java.lang.String target,
                                     javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response)
                              throws java.io.IOException

  Process the contained rules (called by matchAndApply)

  Parameters:
    `target` - target field to pass on to the contained rules
    `request` - request object to pass on to the contained rules
    `response` - response object to pass on to the contained rules
  Throws:
    `java.io.IOException`

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.