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

    java.lang.Object
      org.mortbay.jetty.handler.rewrite.Rule
          org.mortbay.jetty.handler.rewrite.PatternRule
              org.mortbay.jetty.handler.rewrite.HeaderPatternRule

    public class HeaderPatternRule

extends PatternRule

Sets the header in the response whenever the rule finds a match.

Field Summary

Fields inherited from class org.mortbay.jetty.handler.rewrite.PatternRule
`_pattern`

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

Constructor Summary
`HeaderPatternRule()`

Method Summary
`java.lang.String` `apply(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Invokes this method when a match found.
`java.lang.String` `getName()` Returns the header name.
`java.lang.String` `getValue()` Returns the header value.
`boolean` `isAdd()` Returns the add flag value.
`void` `setAdd(boolean add)` Sets the Add flag.
`void` `setName(java.lang.String name)` Sets the header name.
`void` `setValue(java.lang.String value)` Sets the header value.
`java.lang.String` `toString()` Returns the header contents.

Methods inherited from class org.mortbay.jetty.handler.rewrite.PatternRule
`getPattern, matchAndApply, setPattern`

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

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

Constructor Detail

### HeaderPatternRule

    public HeaderPatternRule()

Method Detail

### setName

    public void setName(java.lang.String name)

  Sets the header name.

  Parameters:
    `name` - name of the header field

### setValue

    public void setValue(java.lang.String value)

  Sets the header value. The value can be either a `String` or `int` value.

  Parameters:
    `value` - of the header field

### setAdd

    public void setAdd(boolean add)

  Sets the Add flag.

  Parameters:
    `add` - If true, the header is added to the response, otherwise the header it is set on the response.

### apply

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

  Invokes this method when a match found. If the header had already been set, the new value overwrites the previous one. Otherwise, it adds the new header name and value.

  Specified by:
    `apply` in class `PatternRule`
  Parameters:
    `target` - field to attempt match
    `request` - request object
    `response` - response object
  Returns:
    The target (possible updated)
  Throws:
    `java.io.IOException` - exceptions dealing with operating on request or response objects
  See Also:
    `Rule.matchAndApply(String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)`

### getName

    public java.lang.String getName()

  Returns the header name.

  Returns:
    the header name.

### getValue

    public java.lang.String getValue()

  Returns the header value.

  Returns:
    the header value.

### isAdd

    public boolean isAdd()

  Returns the add flag value.

### toString

    public java.lang.String toString()

  Returns the header contents.

  Overrides:
    `toString` in class `PatternRule`

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