RegexUrlMapping (Grails 6.0.0)

Package: org.grails.web.mapping

## [Java] Class RegexUrlMapping

- org.grails.web.mapping.RegexUrlMapping

-     @java.lang.SuppressWarnings("rawtypes")
      public class RegexUrlMapping
      extends AbstractUrlMapping

  A UrlMapping implementation that takes a Grails URL pattern and turns it into a regex matcher so that URLs can be matched and information captured from the match.

  A Grails URL pattern is not a regex, but is an extension to the form defined by Apache Ant and used by Spring AntPathMatcher. Unlike regular Ant paths Grails URL patterns allow for capturing groups in the form:

  `/blog/(*)/**`

  The parenthesis define a capturing group. This implementation transforms regular Ant paths into regular expressions that are able to use capturing groups

  Authors:
    Graeme Rocher
  See Also:
    org.springframework.util.AntPathMatcher
  Since:
    0.5

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static java.lang.String` | `DEFAULT_ENCODING` |
    `static java.util.regex.Pattern` | `DOUBLE_WILDCARD_PATTERN` |
    `static java.lang.String` | `FORMAT_PARAMETER` |
    `private static org.slf4j.Logger` | `LOG` |
    `static java.util.regex.Pattern` | `OPTIONAL_EXTENSION_WILDCARD_PATTERN` |
    `private java.util.Map<java.lang.Integer, java.util.List<java.util.regex.Pattern>>` | `patternByTokenCount` |
    `private java.util.regex.Pattern[]` | `patterns` |
    `private static long` | `serialVersionUID` |
    `private UrlMappingData` | `urlData` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class AbstractUrlMapping` | `actionName, constraints, controllerName, forwardURI, grailsApplication, httpMethod, mappingName, namespace, parameterValues, parseRequest, pluginIndex, pluginName, redirectInfo, servletContext, version, viewName`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `RegexUrlMapping (UrlMappingData data, java.net.URI uri, grails.gorm.validation.ConstrainedProperty[] constraints, GrailsApplication grailsApplication)` Constructs a new RegexUrlMapping for the given pattern that maps to the specified URI
    `RegexUrlMapping (UrlMappingData data, java.lang.Object controllerName, java.lang.Object actionName, java.lang.Object namespace, java.lang.Object pluginName, java.lang.Object viewName, java.lang.String httpMethod, java.lang.String version, grails.gorm.validation.ConstrainedProperty[] constraints, GrailsApplication grailsApplication)`
    `RegexUrlMapping (java.lang.Object redirectInfo, UrlMappingData data, java.lang.Object controllerName, java.lang.Object actionName, java.lang.Object namespace, java.lang.Object pluginName, java.lang.Object viewName, java.lang.String httpMethod, java.lang.String version, grails.gorm.validation.ConstrainedProperty[] constraints, GrailsApplication grailsApplication)` Constructs a new RegexUrlMapping for the given pattern, controller name, action name and constraints.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `private void` | `appendValueToURI(java.lang.String encoding, java.lang.StringBuilder uri, java.lang.String name, java.lang.Object value)`
    `` | `public java.lang.Object` | `call(java.lang.Object objects)`
    `` | `public int` | `compareTo(java.lang.Object o)` Compares this UrlMapping instance with the specified UrlMapping instance and deals with URL mapping precedence rules.
    `` | `protected java.util.regex.Pattern` | `convertToRegex(java.lang.String url)` Converts a Grails URL provides via the UrlMappingData interface to a regular expression.
    `` | `public java.lang.String` | `createRelativeURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding)`
    `` | `public java.lang.String` | `createRelativeURL(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding)`
    `` | `public java.lang.String` | `createRelativeURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding)`
    `` | `public java.lang.String` | `createRelativeURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)`
    `` | `public java.lang.String` | `createRelativeURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)`
    `` | `private java.lang.Object` | `createRuntimeConstraintEvaluator(java.lang.String name, grails.gorm.validation.ConstrainedProperty[] constraints)` This method will look for a constraint for the given name and return a closure that when executed will attempt to evaluate its value from the bound request parameters at runtime.
    `` | `public java.lang.String` | `createURL(java.util.Map paramValues, java.lang.String encoding)` See Also: UrlMapping
    `` | `public java.lang.String` | `createURL(java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)`
    `` | `public java.lang.String` | `createURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding)`
    `` | `public java.lang.String` | `createURL(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map parameterValues, java.lang.String encoding)`
    `` | `public java.lang.String` | `createURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding)`
    `` | `public java.lang.String` | `createURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)`
    `` | `public java.lang.String` | `createURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)`
    `` | `private java.lang.String` | `createURLInternal(java.util.Map paramValues, java.lang.String encoding, boolean includeContextPath)`
    `` | `private java.lang.String` | `createURLInternal(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding, boolean includeContextPath)`
    `` | `private UrlMappingInfo` | `createUrlMappingInfo(java.lang.String uri, Matcher m)`
    `` | `private java.lang.String` | `createUrlWithFragment(java.lang.String url, java.lang.String fragment, java.lang.String encoding)`
    `` | `protected java.lang.String` | `encode(java.lang.String s, java.lang.String encoding)`
    `` | `private int` | `evaluatePluginOrder(UrlMapping other)`
    `` | `private int` | `getAppliedConstraintsCount(UrlMapping mapping)`
    `` | `private int` | `getDoubleWildcardCount(UrlMapping mapping)`
    `` | `public java.lang.String[]` | `getLogicalMappings()`
    `` | `private int` | `getSingleWildcardCount(UrlMapping mapping)`
    `` | `private int` | `getStaticAndWildcardTokenCount(UrlMapping mapping)`
    `` | `private int` | `getStaticTokenCount(UrlMapping mapping)`
    `` | `public UrlMappingData` | `getUrlData()`
    `` | `private boolean` | `isDoubleWildcard(java.lang.String token)`
    `` | `private boolean` | `isSingleWildcard(java.lang.String token)`
    `` | `public UrlMappingInfo` | `match(java.lang.String uri)` Matches the given URI and returns a DefaultUrlMappingInfo instance or null
    `` | `private void` | `parse(UrlMappingData data, grails.gorm.validation.ConstrainedProperty[] constraints)`
    `` | `private void` | `populateParameterList(java.util.Map paramValues, java.lang.String encoding, java.lang.StringBuilder uri, java.util.Set usedParams)`
    `` | `private void` | `setNullable(grails.gorm.validation.ConstrainedProperty constraint)`
    `` | `public java.lang.String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractUrlMapping` | `getActionName, getConstraints, getControllerName, getHttpMethod, getMappingName, getNamespace, getPluginIndex, getPluginName, getRedirectInfo, getVersion, getViewName, hasRuntimeVariable, isDefinedInPlugin, setGrailsApplication, setMappingName, setParameterValues, setParseRequest, setPluginIndex`

- - ### Field Detail

    - #### private static final java.lang.String DEFAULT_ENCODING

    - #### public static final java.util.regex.Pattern DOUBLE_WILDCARD_PATTERN

    - #### public static final java.lang.String FORMAT_PARAMETER

    - #### private static final org.slf4j.Logger LOG

    - #### public static final java.util.regex.Pattern OPTIONAL_EXTENSION_WILDCARD_PATTERN

    - #### private java.util.Map<java.lang.Integer, java.util.List<java.util.regex.Pattern>> patternByTokenCount

    - #### private java.util.regex.Pattern[] patterns

    - #### private static final long serialVersionUID

    - #### private UrlMappingData urlData

  - ### Constructor Detail

    - #### public RegexUrlMapping(UrlMappingData data, java.net.URI uri, grails.gorm.validation.ConstrainedProperty[] constraints, GrailsApplication grailsApplication)

      Constructs a new RegexUrlMapping for the given pattern that maps to the specified URI

      Parameters:
        `data` - The pattern
        `uri` - The URI
        `constraints` - Any constraints etc.
        `grailsApplication` - The GrailsApplication instance

    - #### public RegexUrlMapping(UrlMappingData data, java.lang.Object controllerName, java.lang.Object actionName, java.lang.Object namespace, java.lang.Object pluginName, java.lang.Object viewName, java.lang.String httpMethod, java.lang.String version, grails.gorm.validation.ConstrainedProperty[] constraints, GrailsApplication grailsApplication)

    - #### public RegexUrlMapping(java.lang.Object redirectInfo, UrlMappingData data, java.lang.Object controllerName, java.lang.Object actionName, java.lang.Object namespace, java.lang.Object pluginName, java.lang.Object viewName, java.lang.String httpMethod, java.lang.String version, grails.gorm.validation.ConstrainedProperty[] constraints, GrailsApplication grailsApplication)

      Constructs a new RegexUrlMapping for the given pattern, controller name, action name and constraints.

      Parameters:
        `data` - An instance of the UrlMappingData class that holds necessary information of the URL mapping
        `controllerName` - The name of the controller the URL maps to (required)
        `actionName` - The name of the action the URL maps to
        `namespace` - The controller namespace
        `pluginName` - The name of the plugin which provided the controller
        `viewName` - The name of the view as an alternative to the name of the action. If the action is specified it takes precedence over the view name during mapping
        `httpMethod` - The http method
        `version` - The version
        `constraints` - A list of ConstrainedProperty instances that relate to tokens in the URL
        `grailsApplication` - The Grails application
      See Also:
        grails.gorm.validation.ConstrainedProperty

  - ### Method Detail

    - #### private void appendValueToURI(java.lang.String encoding, java.lang.StringBuilder uri, java.lang.String name, java.lang.Object value)

    - #### @java.lang.Override public java.lang.Object call(java.lang.Object objects)

    - #### public int compareTo(java.lang.Object o)

      Compares this UrlMapping instance with the specified UrlMapping instance and deals with URL mapping precedence rules. URL Mapping Precedence Order 1. Less wildcard tokens. /foo <- match /foo/(*) /foo/(*)/bar/ <- match /foo/(*)/(*) 2. More static tokens. /foo/(*)/bar <- match /foo/(*)

      Parameters:
        `o` - An instance of the UrlMapping interface
      Returns:
        greater than 0 if this UrlMapping should match before the specified UrlMapping. 0 if they are equal or less than 0 if this UrlMapping should match after the given UrlMapping

    - #### protected java.util.regex.Pattern convertToRegex(java.lang.String url)

      Converts a Grails URL provides via the UrlMappingData interface to a regular expression.

      Parameters:
        `url` - The URL to convert
      Returns:
        A regex Pattern objet

    - #### public java.lang.String createRelativeURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding)

    - #### public java.lang.String createRelativeURL(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding)

    - #### public java.lang.String createRelativeURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding)

    - #### public java.lang.String createRelativeURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)

    - #### public java.lang.String createRelativeURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)

    - #### private java.lang.Object createRuntimeConstraintEvaluator(java.lang.String name, grails.gorm.validation.ConstrainedProperty[] constraints)

      This method will look for a constraint for the given name and return a closure that when executed will attempt to evaluate its value from the bound request parameters at runtime.

      Parameters:
        `name` - The name of the constrained property
        `constraints` - The array of current ConstrainedProperty instances
      Returns:
        Either a Closure or null

    - #### public java.lang.String createURL(java.util.Map paramValues, java.lang.String encoding)

      See Also:
        UrlMapping

    - #### public java.lang.String createURL(java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)

    - #### public java.lang.String createURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding)

    - #### public java.lang.String createURL(java.lang.String controller, java.lang.String action, java.lang.String pluginName, java.util.Map parameterValues, java.lang.String encoding)

    - #### public java.lang.String createURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding)

    - #### public java.lang.String createURL(java.lang.String controller, java.lang.String action, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)

    - #### public java.lang.String createURL(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding, java.lang.String fragment)

    - #### @java.lang.SuppressWarnings({"unchecked"}) private java.lang.String createURLInternal(java.util.Map paramValues, java.lang.String encoding, boolean includeContextPath)

    - #### @java.lang.SuppressWarnings("unchecked") private java.lang.String createURLInternal(java.lang.String controller, java.lang.String action, java.lang.String namespace, java.lang.String pluginName, java.util.Map paramValues, java.lang.String encoding, boolean includeContextPath)

    - #### @java.lang.SuppressWarnings("unchecked") private UrlMappingInfo createUrlMappingInfo(java.lang.String uri, Matcher m)

    - #### private java.lang.String createUrlWithFragment(java.lang.String url, java.lang.String fragment, java.lang.String encoding)

    - #### protected java.lang.String encode(java.lang.String s, java.lang.String encoding)

    - #### private int evaluatePluginOrder(UrlMapping other)

    - #### private int getAppliedConstraintsCount(UrlMapping mapping)

    - #### private int getDoubleWildcardCount(UrlMapping mapping)

    - #### public java.lang.String[] getLogicalMappings()

    - #### private int getSingleWildcardCount(UrlMapping mapping)

    - #### private int getStaticAndWildcardTokenCount(UrlMapping mapping)

    - #### private int getStaticTokenCount(UrlMapping mapping)

    - #### public UrlMappingData getUrlData()

    - #### private boolean isDoubleWildcard(java.lang.String token)

    - #### private boolean isSingleWildcard(java.lang.String token)

    - #### public UrlMappingInfo match(java.lang.String uri)

      Matches the given URI and returns a DefaultUrlMappingInfo instance or null

      Parameters:
        `uri` - The URI to match
      Returns:
        A UrlMappingInfo instance or null
      See Also:
        UrlMappingInfo

    - #### private void parse(UrlMappingData data, grails.gorm.validation.ConstrainedProperty[] constraints)

    - #### @java.lang.SuppressWarnings("unchecked") private void populateParameterList(java.util.Map paramValues, java.lang.String encoding, java.lang.StringBuilder uri, java.util.Set usedParams)

    - #### private void setNullable(grails.gorm.validation.ConstrainedProperty constraint)

    - #### @java.lang.Override public java.lang.String toString()