RandomizedTextRewriteMap (Apache Tomcat 11.0.23 API Documentation)
Description: declaration: package: org.apache.catalina.valves.rewrite, class: RandomizedTextRewriteMap

# Class RandomizedTextRewriteMap

java.lang.Object
org.apache.catalina.valves.rewrite.RandomizedTextRewriteMap

All Implemented Interfaces:
  `RewriteMap`

public class RandomizedTextRewriteMap extends Object implements RewriteMap
Implement a map for the txt: and rnd: mod_rewrite capabilities.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final StringManager`
  `sm`
  StringManager for this package.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RandomizedTextRewriteMap(String txtFilePath, boolean useRandom)`
  Create a map from a text file according to the mod_rewrite syntax.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `lookup(String key)`
  Looks up a key in the map and returns the mapped value.
  `String`
  `setParameters(String params)`
  Sets optional parameters for the map.

  ### Methods inherited from class Object

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

  ### Methods inherited from interface RewriteMap

  `setParameters`

- ## Field Details

  - ### sm

    protected static final StringManager sm
    StringManager for this package.

- ## Constructor Details

  - ### RandomizedTextRewriteMap

    public RandomizedTextRewriteMap(String txtFilePath, boolean useRandom)
    Create a map from a text file according to the mod_rewrite syntax.
    Parameters:
      `txtFilePath` - the text file path
      `useRandom` - if the map should produce random results

- ## Method Details

  - ### setParameters

    public String setParameters(String params)
    Sets optional parameters for the map. This implementation does not support additional parameters and always throws an exception.
    Specified by:
      `setParameters` in interface `RewriteMap`
    Parameters:
      `params` - the optional parameter
    Returns:
      never returns, always throws `IllegalArgumentException`

  - ### lookup

    public String lookup(String key)
    Looks up a key in the map and returns the mapped value. If the map was created with random mode enabled and the value contains multiple options separated by '|', a random option is returned.
    Specified by:
      `lookup` in interface `RewriteMap`
    Parameters:
      `key` - the key to look up
    Returns:
      the mapped value or `null` if the key is not found