org.apache.struts2.util

## Class RegexPatternMatcher

- java.lang.Object
- - org.apache.struts2.util.RegexPatternMatcher

- All Implemented Interfaces:
    PatternMatcher<RegexPatternMatcherExpression>

      public class RegexPatternMatcher
      extends Object
      implements PatternMatcher<RegexPatternMatcherExpression>

  Allows regular expressions to be used in action names. The regular expressions can be in the form {FIELD_NAME} or {FIELD_NAME:REGULAR_EXPRESSION}. For example:

        <action name="/{bio:.+}/test/{name}" class="org.apache.struts2.showcase.UITagExample">
             <result>/tags/ui/example.jsp</result>
        </action>

  For this to work it is important to set the following:

       <constant name="struts.enable.SlashesInActionNames" value="true"/>
       <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
       <constant name="struts.patternMatcher" value="regex" />

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RegexPatternMatcher()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `RegexPatternMatcherExpression` | `compilePattern(String data)` Translate the given `String` into an object representing the pattern matchable by this class.
    `boolean` | `isLiteral(String pattern)` Determines if the pattern is a simple literal string or contains wildcards that will need to be processed
    `boolean` | `match(Map<String,String> map, String data, RegexPatternMatcherExpression expr)` Match a pattern against a string

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### RegexPatternMatcher

          public RegexPatternMatcher()

  - ### Method Detail

    - #### compilePattern

          public RegexPatternMatcherExpression compilePattern(String data)

      Description copied from interface: `PatternMatcher`

      Translate the given `String` into an object representing the pattern matchable by this class.

      Specified by:
        `compilePattern` in interface `PatternMatcher<RegexPatternMatcherExpression>`
      Parameters:
        `data` - The string to translate.
      Returns:
        The encoded string

    - #### isLiteral

          public boolean isLiteral(String pattern)

      Description copied from interface: `PatternMatcher`
      Determines if the pattern is a simple literal string or contains wildcards that will need to be processed
      Specified by:
        `isLiteral` in interface `PatternMatcher<RegexPatternMatcherExpression>`
      Parameters:
        `pattern` - The string pattern
      Returns:
        True if the pattern doesn't contain processing elements, false otherwise

    - #### match

          public boolean match(Map<String,String> map,
                               String data,
                               RegexPatternMatcherExpression expr)

      Description copied from interface: `PatternMatcher`
      Match a pattern against a string
      Specified by:
        `match` in interface `PatternMatcher<RegexPatternMatcherExpression>`
      Parameters:
        `map` - The map to store matched values
        `data` - The string to match
        `expr` - The compiled wildcard expression
      Returns:
        True if a match

Copyright © 2000–2022 Apache Software Foundation. All rights reserved.