rewrite-config-servlet 2.0.0.Beta3

org.ocpsoft.rewrite.servlet.config
Class Header

java.lang.Object
  extended by org.ocpsoft.rewrite.config.DefaultConditionBuilder
      extended by org.ocpsoft.rewrite.servlet.config.HttpCondition
          extended by org.ocpsoft.rewrite.servlet.config.Header
All Implemented Interfaces:
Condition, ConditionBuilder, Parameterized

public class Header
extends HttpCondition
implements Parameterized

A Condition responsible for asserting on specified values of HttpServletRequest.getHeader(String).

Author:
Lincoln Baxter, III

Method Summary
 boolean evaluateHttp(HttpServletRewrite event, EvaluationContext context)
           
static Header exists(String name)
          Create a Header condition that matches only against the existence of a header with a name matching the given pattern.
 Set<String> getRequiredParameterNames()
           
static Header matches(String name, String value)
          Create a Header condition that matches against both header name and values.
 void setParameterStore(ParameterStore store)
           
static Header valueExists(String value)
          Create a Header condition that matches only against the existence of a header with value matching the given pattern.
 
Methods inherited from class org.ocpsoft.rewrite.servlet.config.HttpCondition
evaluate
 
Methods inherited from class org.ocpsoft.rewrite.config.DefaultConditionBuilder
and, andNot, or, orNot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

matches

public static Header matches(String name,
                             String value)
Create a Header condition that matches against both header name and values.

The given name and value patterns may be parameterized:

Header.matches("Accept-Encoding", "{encoding}")
Header.matches("Accept-{type}", "{value}")
...

Parameters:
name - ParameterizedPattern matching the header name.
value - ParameterizedPattern matching the header value.
See Also:
ConfigurationRuleParameterBuilder#where(String) {@link HttpServletRequest#getHeader(String)}

exists

public static Header exists(String name)
Create a Header condition that matches only against the existence of a header with a name matching the given pattern. The header value is ignored.

The given name pattern may be parameterized:

Header.exists("Accept-Encoding")
Header.exists("Accept-{acceptType}")
Header.exists("{anything}")
...

Parameters:
name - ParameterizedPattern matching the header name.
See Also:
ConfigurationRuleParameterBuilder#where(String) {@link HttpServletRequest#getHeader(String)}

valueExists

public static Header valueExists(String value)
Create a Header condition that matches only against the existence of a header with value matching the given pattern. The header name is ignored.

The given value pattern may be parameterized:

Header.valueExists("application/xml")
Header.valueExists("application/{type}")
Header.valueExists("{anything}")
...

Parameters:
value - ParameterizedPattern matching the header value.
See Also:
ConfigurationRuleParameterBuilder#where(String) {@link HttpServletRequest#getHeader(String)}

evaluateHttp

public boolean evaluateHttp(HttpServletRewrite event,
                            EvaluationContext context)
Specified by:
evaluateHttp in class HttpCondition

getRequiredParameterNames

public Set<String> getRequiredParameterNames()
Specified by:
getRequiredParameterNames in interface Parameterized

setParameterStore

public void setParameterStore(ParameterStore store)
Specified by:
setParameterStore in interface Parameterized

rewrite-config-servlet 2.0.0.Beta3

Copyright © 2013 OCPsoft. All Rights Reserved.