# Class Substitution

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

public class Substitution extends Object
Represents a URL substitution pattern for rewrite rules. Supports back-references to rewrite rules and conditions, server variables, and map lookups.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `class`
  `Substitution.MapElement`
  Substitution element that performs a rewrite map lookup.
  `static class`
  `Substitution.RewriteCondBackReferenceElement`
  Substitution element that produces a back-reference to a rewrite condition group.
  `class`
  `Substitution.RewriteRuleBackReferenceElement`
  Substitution element that produces a back-reference to a rewrite rule group.
  `static class`
  `Substitution.ServerVariableElement`
  Substitution element that resolves a server variable.
  `static class`
  `Substitution.ServerVariableEnvElement`
  Substitution element that resolves an environment variable.
  `static class`
  `Substitution.ServerVariableHttpElement`
  Substitution element that resolves an HTTP header variable.
  `static class`
  `Substitution.ServerVariableSslElement`
  Substitution element that resolves an SSL variable.
  `static class`
  `Substitution.StaticElement`
  Substitution element that produces a static string value.
  `static class`
  `Substitution.SubstitutionElement`
  Abstract base class for individual substitution elements.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Substitution.SubstitutionElement[]`
  `elements`
  The parsed substitution elements.
  `protected static final StringManager`
  `sm`
  The string manager for this package.
  `protected String`
  `sub`
  The raw substitution string.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Substitution()`
  Constructs a new Substitution.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `evaluate(Matcher rule, Matcher cond, Resolver resolver)`
  Evaluate the substitution based on the context.
  `String`
  `getSub()`
  Returns the raw substitution string.
  `void`
  `parse(Map<String, RewriteMap> maps)`
  Parses the substitution string into individual elements.
  `void`
  `setSub(String sub)`
  Sets the raw substitution string to be parsed.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### sm

    protected static final StringManager sm
    The string manager for this package.

  - ### elements

    protected Substitution.SubstitutionElement[] elements
    The parsed substitution elements.

  - ### sub

    protected String sub
    The raw substitution string.

- ## Constructor Details

  - ### Substitution

    public Substitution()
    Constructs a new Substitution.

- ## Method Details

  - ### getSub

    public String getSub()
    Returns the raw substitution string.
    Returns:
      the substitution string

  - ### setSub

    public void setSub(String sub)
    Sets the raw substitution string to be parsed.
    Parameters:
      `sub` - the substitution string

  - ### parse

    public void parse(Map<String, RewriteMap> maps)
    Parses the substitution string into individual elements.
    Parameters:
      `maps` - the available rewrite maps

  - ### evaluate

    public String evaluate(Matcher rule, Matcher cond, Resolver resolver)
    Evaluate the substitution based on the context.
    Parameters:
      `rule` - corresponding matched rule
      `cond` - last matched condition
      `resolver` - The property resolver
    Returns:
      The substitution result