- java.lang.Object
-
- com.github.robtimus.servlet.FilterConfigWrapper
-
- All Implemented Interfaces:
FilterConfig
public class FilterConfigWrapper extends Object implements FilterConfig
A wrapper around an existingFilterConfig
instance. By default it delegates all methods. However, it also allows initialization parameters to be added or overwritten. This can be useful when a sub class of some filter needs to provide hard-coded or calculated initialization parameter values to its parent class. For instance:public void init(FilterConfig filterConfig) { super.init(new FilterConfigWrapper(filterConfig) .withInitParameter("booleanParameter", true) .withInitParameter("intParameter", 100)); }
- Author:
- Rob Spoor
-
-
Constructor Summary
Constructors Constructor Description FilterConfigWrapper(FilterConfig filterConfig)
Creates a newFilterConfig
wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getFilterName()
String
getInitParameter(String name)
Enumeration<String>
getInitParameterNames()
ServletContext
getServletContext()
FilterConfigWrapper
withInitParameter(String name, Object value)
Adds or overwrites an initialization parameter.
-
-
-
Constructor Detail
-
FilterConfigWrapper
public FilterConfigWrapper(FilterConfig filterConfig)
Creates a newFilterConfig
wrapper.- Parameters:
filterConfig
- TheFilterConfig
object to wrap.- Throws:
NullPointerException
- If the givenFilterConfig
object isnull
.
-
-
Method Detail
-
getFilterName
public String getFilterName()
- Specified by:
getFilterName
in interfaceFilterConfig
-
getServletContext
public ServletContext getServletContext()
- Specified by:
getServletContext
in interfaceFilterConfig
-
getInitParameter
public String getInitParameter(String name)
- Specified by:
getInitParameter
in interfaceFilterConfig
-
getInitParameterNames
public Enumeration<String> getInitParameterNames()
- Specified by:
getInitParameterNames
in interfaceFilterConfig
-
withInitParameter
public FilterConfigWrapper withInitParameter(String name, Object value)
Adds or overwrites an initialization parameter.- Parameters:
name
- The name of the initialization parameter.value
- The value for the initialization parameter. Itsstring representation
will be used.- Returns:
- This object.
- Throws:
NullPointerException
- If the given name or value isnull
.
-
-