Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.web.mapping
Class RegexUrlMapping

    java.lang.Object
      org.codehaus.groovy.grails.web.mapping.AbstractUrlMapping
          org.codehaus.groovy.grails.web.mapping.RegexUrlMapping

All Implemented Interfaces:
  Comparable, UrlCreator, UrlMapping

    public class RegexUrlMapping

extends AbstractUrlMapping
implements UrlMapping

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

Since:
  0.5

  Created: Feb 28, 2007 Time: 6:12:52 PM
Author:
  Graeme Rocher
See Also:
  `AntPathMatcher`

Field Summary

Fields inherited from class org.codehaus.groovy.grails.web.mapping.AbstractUrlMapping
`actionName, constraints, controllerName, parameterValues, viewName`

Fields inherited from interface org.codehaus.groovy.grails.web.mapping.UrlMapping
`ACTION, CONTROLLER`

Constructor Summary
`RegexUrlMapping(UrlMappingData data, Object controllerName, Object actionName, Object viewName, ConstrainedProperty[] constraints)` Constructs a new RegexUrlMapping for the given pattern, controller name, action name and constraints.

Method Summary
`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)` Converst a Grails URL provides via the UrlMappingData interface to a regular expression
`String` | `createRelativeURL(String controller, String action, Map parameterValues, String encoding)` Creates a URL for the given parameters values, controller and action names without the context path information
`String` | `createURL(Map parameterValues, String encoding)` Creates a URL for the given parameter values
`String` | `createURL(Map parameterValues, String encoding, String fragment)` Creates a URL for the given parameter values
`String` | `createURL(String controller, String action, Map parameterValues, String encoding)` Creates a URL for the given parameters values, controller and action names
`String` | `createURL(String controller, String action, Map parameterValues, String encoding, String fragment)` Creates a URL for the given parameters values, controller and action names
`String[]` | `getLogicalMappings()`
`UrlMappingData` | `getUrlData()` Retrieves the UrlMappingData instance that describes this UrlMapping
`UrlMappingInfo` | `match(String uri)` Matches the given URI and returns a DefaultUrlMappingInfo instance or null
`String` | `toString()`

Methods inherited from class org.codehaus.groovy.grails.web.mapping.AbstractUrlMapping
`getActionName, getConstraints, getControllerName, getViewName, setParameterValues`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.codehaus.groovy.grails.web.mapping.UrlMapping
`getActionName, getConstraints, getControllerName, getViewName, setParameterValues`

Constructor Detail

### RegexUrlMapping

    public RegexUrlMapping(UrlMappingData data,
                           Object controllerName,
                           Object actionName,
                           Object viewName,
                           ConstrainedProperty[] constraints)

  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
    `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
    `constraints` - A list of ConstrainedProperty instances that relate to tokens in the URL
  See Also:
    `ConstrainedProperty`

Method Detail

### convertToRegex

    protected Pattern convertToRegex(String url)

  Converst a Grails URL provides via the UrlMappingData interface to a regular expression

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

### match

    public UrlMappingInfo match(String uri)

  Matches the given URI and returns a DefaultUrlMappingInfo instance or null

  Specified by:
    `match` in interface `UrlMapping`
  Parameters:
    `uri` - The URI to match
  Returns:
    A UrlMappingInfo instance or null
  See Also:
    `UrlMappingInfo`

### createURL

    public String createURL(Map parameterValues,
                            String encoding)

  Description copied from interface: `UrlCreator`
  Creates a URL for the given parameter values

  Specified by:
    `createURL` in interface `UrlCreator`
  Parameters:
    `parameterValues` - The parameter values
    `encoding` - The encoding to use for parameters
  Returns:
    Returns the created URL for the given parameter values
  See Also:
    `UrlMapping`

### createURL

    public String createURL(Map parameterValues,
                            String encoding,
                            String fragment)

  Description copied from interface: `UrlCreator`
  Creates a URL for the given parameter values

  Specified by:
    `createURL` in interface `UrlCreator`
  Parameters:
    `parameterValues` - The parameter values
    `encoding` - The encoding to use for parameters
    `fragment` - The URL fragment to be appended to the URL following a #
  Returns:
    Returns the created URL for the given parameter values

### createURL

    public String createURL(String controller,
                            String action,
                            Map parameterValues,
                            String encoding)

  Description copied from interface: `UrlCreator`
  Creates a URL for the given parameters values, controller and action names

  Specified by:
    `createURL` in interface `UrlCreator`
  Parameters:
    `controller` - The controller name
    `action` - The action name
    `parameterValues` - The parameter values
    `encoding` - The encoding to use for parameters
  Returns:
    The created URL for the given arguments

### createRelativeURL

    public String createRelativeURL(String controller,
                                    String action,
                                    Map parameterValues,
                                    String encoding)

  Description copied from interface: `UrlCreator`
  Creates a URL for the given parameters values, controller and action names without the context path information

  Specified by:
    `createRelativeURL` in interface `UrlCreator`
  Parameters:
    `controller` - The controller name
    `action` - The action name
    `parameterValues` - The parameter values
    `encoding` - The encoding to use for parameters
  Returns:
    The created URL for the given arguments

### createURL

    public String createURL(String controller,
                            String action,
                            Map parameterValues,
                            String encoding,
                            String fragment)

  Description copied from interface: `UrlCreator`
  Creates a URL for the given parameters values, controller and action names

  Specified by:
    `createURL` in interface `UrlCreator`
  Parameters:
    `controller` - The controller name
    `action` - The action name
    `parameterValues` - The parameter values
    `encoding` - The encoding to use for parameters
    `fragment` - The URL fragment to be appended to the URL following a #
  Returns:
    The created URL for the given arguments

### getUrlData

    public UrlMappingData getUrlData()

  Description copied from interface: `UrlMapping`
  Retrieves the UrlMappingData instance that describes this UrlMapping

  Specified by:
    `getUrlData` in interface `UrlMapping`
  Returns:
    The UrlMappingData instance

### getLogicalMappings

    public String[] getLogicalMappings()

### compareTo

    public int compareTo(Object o)

  Compares this UrlMapping instance with the specified UrlMapping instance and deals with URL mapping precedence rules.

  Specified by:
    `compareTo` in interface `Comparable`
  Parameters:
    `o` - An instance of the UrlMapping interface
  Returns:
    1 if this UrlMapping should match before the specified UrlMapping. 0 if they are equal or -1 if this UrlMapping should match after the given UrlMapping

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2005-2006 The Grails project