@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
| Modifiers | Name | Description |
|---|---|---|
static Pattern |
DOUBLE_WILDCARD_PATTERN |
|
static String |
FORMAT_PARAMETER |
|
static Pattern |
OPTIONAL_EXTENSION_WILDCARD_PATTERN |
| Fields inherited from class | Fields |
|---|---|
class AbstractUrlMapping |
actionName, constraints, controllerName, forwardURI, grailsApplication, httpMethod, mappingName, namespace, parameterValues, parseRequest, pluginIndex, pluginName, redirectInfo, servletContext, version, viewName |
| Constructor and description |
|---|
RegexUrlMapping(UrlMappingData data, URI uri, ConstrainedProperty[] constraints, GrailsApplication grailsApplication)Constructs a new RegexUrlMapping for the given pattern that maps to the specified URI |
RegexUrlMapping(UrlMappingData data, Object controllerName, Object actionName, Object namespace, Object pluginName, Object viewName, String httpMethod, String version, ConstrainedProperty[] constraints, GrailsApplication grailsApplication) |
RegexUrlMapping(Object redirectInfo, UrlMappingData data, Object controllerName, Object actionName, Object namespace, Object pluginName, Object viewName, String httpMethod, String version, ConstrainedProperty[] constraints, GrailsApplication grailsApplication)Constructs a new RegexUrlMapping for the given pattern, controller name, action name and constraints. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Object |
call(Object objects) |
|
public int |
compareTo(Object o)Compares this UrlMapping instance with the specified UrlMapping instance and deals with URL mapping precedence rules. |
|
protected Pattern |
convertToRegex(String url)Converts a Grails URL provides via the UrlMappingData interface to a regular expression. |
|
public String |
createRelativeURL(String controller, String action, Map paramValues, String encoding) |
|
public String |
createRelativeURL(String controller, String action, String pluginName, Map paramValues, String encoding) |
|
public String |
createRelativeURL(String controller, String action, String namespace, String pluginName, Map paramValues, String encoding) |
|
public String |
createRelativeURL(String controller, String action, Map paramValues, String encoding, String fragment) |
|
public String |
createRelativeURL(String controller, String action, String namespace, String pluginName, Map paramValues, String encoding, String fragment) |
|
public String |
createURL(Map paramValues, String encoding)
|
|
public String |
createURL(Map paramValues, String encoding, String fragment) |
|
public String |
createURL(String controller, String action, Map paramValues, String encoding) |
|
public String |
createURL(String controller, String action, String pluginName, Map parameterValues, String encoding) |
|
public String |
createURL(String controller, String action, String namespace, String pluginName, Map paramValues, String encoding) |
|
public String |
createURL(String controller, String action, Map paramValues, String encoding, String fragment) |
|
public String |
createURL(String controller, String action, String namespace, String pluginName, Map paramValues, String encoding, String fragment) |
|
protected String |
encode(String s, String encoding) |
|
public String[] |
getLogicalMappings() |
|
public UrlMappingData |
getUrlData() |
|
public UrlMappingInfo |
match(String uri)Matches the given URI and returns a DefaultUrlMappingInfo instance or null |
|
public String |
toString() |
| Methods inherited from class | Name |
|---|---|
class AbstractUrlMapping |
getActionName, getConstraints, getControllerName, getHttpMethod, getMappingName, getNamespace, getPluginIndex, getPluginName, getRedirectInfo, getVersion, getViewName, hasRuntimeVariable, isDefinedInPlugin, setMappingName, setParameterValues, setParseRequest, setPluginIndex |
Constructs a new RegexUrlMapping for the given pattern that maps to the specified URI
data - The patternuri - The URIconstraints - Any constraints etc.grailsApplication - The GrailsApplication instanceConstructs a new RegexUrlMapping for the given pattern, controller name, action name and constraints.
data - An instance of the UrlMappingData class that holds necessary information of the URL mappingcontrollerName - The name of the controller the URL maps to (required)actionName - The name of the action the URL maps tonamespace - The controller namespacepluginName - The name of the plugin which provided the controllerviewName - 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 mappinghttpMethod - The http methodversion - The versionconstraints - A list of ConstrainedProperty instances that relate to tokens in the URLgrailsApplication - The Grails applicationCompares 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/(*)
o - An instance of the UrlMapping interfaceConverts a Grails URL provides via the UrlMappingData interface to a regular expression.
url - The URL to convert
Matches the given URI and returns a DefaultUrlMappingInfo instance or null
uri - The URI to match