Class RuleContainer

java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RuleContainer
All Implemented Interfaces:
Iterable<Rule>, Dumpable
Direct Known Subclasses:
RewriteCustomizer, VirtualHostRuleContainer

public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable

A container that groups Rules and is itself a Rule.

The contained rules will be applied only if the container rule matches.

  • Field Details

    • ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX

      public static final String ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX
      See Also:
  • Constructor Details

    • RuleContainer

      public RuleContainer()
  • Method Details

    • getRules

      public List<Rule> getRules()
      Returns:
      the list of Rules
    • setRules

      public void setRules(List<Rule> rules)
      Set the list of Rule..
      Parameters:
      rules - the list of Rule.
    • iterator

      public Iterator<Rule> iterator()
      Specified by:
      iterator in interface Iterable<Rule>
    • addRule

      public void addRule(Rule rule)

      Adds a Rule to the existing ones.

      Parameters:
      rule - the rule to add to the rules list
    • clear

      public void clear()

      Removes all the rules.

    • getOriginalPathAttribute

      public String getOriginalPathAttribute()
      Returns:
      the request attribute name used to store the request original path
      See Also:
    • setOriginalPathAttribute

      public void setOriginalPathAttribute(String originalPathAttribute)

      Sets a request attribute name that will be used to store the request original path.

      A request attribute name that stores the request original query is derived from this attribute name by adding ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX, as in:

       String originalQueryAttribute = ruleContainer.getOriginalPathAttribute() + ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX;
       
      Parameters:
      originalPathAttribute - the request attribute name used to store the request original path
    • matchAndApply

      public Rule.Handler matchAndApply(Rule.Handler input) throws IOException

      Processes the rules.

      Specified by:
      matchAndApply in class Rule
      Parameters:
      input - the input Request and Handler
      Returns:
      a Request and Handler, possibly wrapped by rules to implement the rule's logic, or null if no rule matched
      Throws:
      IOException - if applying the rule fails
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Description copied from interface: Dumpable
      Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
      Specified by:
      dump in interface Dumpable
      Parameters:
      out - The appendable to dump to
      indent - The indent to apply after any new lines.
      Throws:
      IOException - if unable to write to Appendable