FilterMap (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.tomcat.util.descriptor.web, class: FilterMap

# Class FilterMap

java.lang.Object
org.apache.tomcat.util.descriptor.web.XmlEncodingBase
org.apache.tomcat.util.descriptor.web.FilterMap

All Implemented Interfaces:
  `Serializable`

public class FilterMap extends XmlEncodingBase implements Serializable
Representation of a filter mapping for a web application, as represented in a `<filter-mapping>` element in the deployment descriptor. Each filter mapping must contain a filter name plus either a URL pattern or a servlet name.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ASYNC`
  Dispatcher type constant for async dispatch.
  `static final int`
  `ERROR`
  Dispatcher type constant for error dispatch.
  `static final int`
  `FORWARD`
  Dispatcher type constant for forward dispatch.
  `static final int`
  `INCLUDE`
  Dispatcher type constant for include dispatch.
  `static final int`
  `REQUEST`
  Dispatcher type constant for request dispatch.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FilterMap()`
  Default constructor for FilterMap.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addServletName(String servletName)`
  Adds a servlet name to the set of servlet names this mapping matches.
  `void`
  `addURLPattern(String urlPattern)`
  Adds a URL pattern to the set of URL patterns this mapping matches.
  `void`
  `addURLPatternDecoded(String urlPattern)`
  Adds a decoded URL pattern to the set of URL patterns this mapping matches.
  `int`
  `getDispatcherMapping()`
  Returns the dispatcher mapping bitmask for this filter mapping.
  `String[]`
  `getDispatcherNames()`
  Returns the names of the dispatchers mapped to this filter.
  `String`
  `getFilterName()`
  Returns the name of the filter associated with this mapping.
  `boolean`
  `getMatchAllServletNames()`
  Returns whether this mapping matches all servlet names.
  `boolean`
  `getMatchAllUrlPatterns()`
  Returns whether this mapping matches all URL patterns.
  `String[]`
  `getServletNames()`
  Returns the servlet names this mapping matches.
  `String[]`
  `getURLPatterns()`
  Returns the URL patterns this mapping matches.
  `void`
  `setDispatcher(String dispatcherString)`
  This method will be used to set the current state of the FilterMap representing the state of when filters should be applied.
  `void`
  `setFilterName(String filterName)`
  Sets the name of the filter associated with this mapping.
  `String`
  `toString()`
  Render a String representation of this object.

  ### Methods inherited from class XmlEncodingBase

  `getCharset, setCharset`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### ERROR

    public static final int ERROR
    Dispatcher type constant for error dispatch.
    See Also:
      - Constant Field Values

  - ### FORWARD

    public static final int FORWARD
    Dispatcher type constant for forward dispatch.
    See Also:
      - Constant Field Values

  - ### INCLUDE

    public static final int INCLUDE
    Dispatcher type constant for include dispatch.
    See Also:
      - Constant Field Values

  - ### REQUEST

    public static final int REQUEST
    Dispatcher type constant for request dispatch.
    See Also:
      - Constant Field Values

  - ### ASYNC

    public static final int ASYNC
    Dispatcher type constant for async dispatch.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### FilterMap

    public FilterMap()
    Default constructor for FilterMap.

- ## Method Details

  - ### getFilterName

    public String getFilterName()
    Returns the name of the filter associated with this mapping.
    Returns:
      The filter name

  - ### setFilterName

    public void setFilterName(String filterName)
    Sets the name of the filter associated with this mapping.
    Parameters:
      `filterName` - The filter name

  - ### getServletNames

    public String[] getServletNames()
    Returns the servlet names this mapping matches.
    Returns:
      The servlet names, or an empty array if all servlet names match

  - ### addServletName

    public void addServletName(String servletName)
    Adds a servlet name to the set of servlet names this mapping matches.
    Parameters:
      `servletName` - The servlet name to add

  - ### getMatchAllUrlPatterns

    public boolean getMatchAllUrlPatterns()
    Returns whether this mapping matches all URL patterns.
    Returns:
      True if all URL patterns match

  - ### getMatchAllServletNames

    public boolean getMatchAllServletNames()
    Returns whether this mapping matches all servlet names.
    Returns:
      True if all servlet names match

  - ### getURLPatterns

    public String[] getURLPatterns()
    Returns the URL patterns this mapping matches.
    Returns:
      The URL patterns, or an empty array if all URL patterns match

  - ### addURLPattern

    public void addURLPattern(String urlPattern)
    Adds a URL pattern to the set of URL patterns this mapping matches.
    Parameters:
      `urlPattern` - The URL pattern to add

  - ### addURLPatternDecoded

    public void addURLPatternDecoded(String urlPattern)
    Adds a decoded URL pattern to the set of URL patterns this mapping matches.
    Parameters:
      `urlPattern` - The decoded URL pattern to add

  - ### setDispatcher

    public void setDispatcher(String dispatcherString)
    This method will be used to set the current state of the FilterMap representing the state of when filters should be applied.
    Parameters:
      `dispatcherString` - the dispatcher type which should match this filter

  - ### getDispatcherMapping

    public int getDispatcherMapping()
    Returns the dispatcher mapping bitmask for this filter mapping.
    Returns:
      The dispatcher mapping bitmask, defaulting to REQUEST if not set

  - ### getDispatcherNames

    public String[] getDispatcherNames()
    Returns the names of the dispatchers mapped to this filter.
    Returns:
      Array of dispatcher type names

  - ### toString

    public String toString()
    Render a String representation of this object.
    Overrides:
      `toString` in class `Object`