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

    java.lang.Object
      org.codehaus.groovy.grails.web.mapping.DefaultUrlMappingsHolder

All Implemented Interfaces:
  UrlMappingsHolder

    public class DefaultUrlMappingsHolder

extends Object
implements UrlMappingsHolder

The default implementation of the UrlMappingsHolder interface that takes a list of mappings and then sorts them according to their precdence rules as defined in the implementation of Comparable

Since:
  0.4

  Created: Mar 6, 2007 Time: 8:21:00 AM
Author:
  Graeme Rocher
See Also:
  `UrlMapping`, `Comparable`

Nested Class Summary
`(package private) class` `DefaultUrlMappingsHolder.UrlMappingKey` A class used as a key to lookup a UrlMapping based on controller, action and parameter names
`(package private) class` `DefaultUrlMappingsHolder.UrlMappingsList`
`(package private) class` `DefaultUrlMappingsHolder.UrlMappingsListKey` A class used as a key to lookup a all UrlMappings based on only controller and action.

Field Summary

Fields inherited from interface org.codehaus.groovy.grails.web.mapping.UrlMappingsHolder
`BEAN_ID`

Constructor Summary
`DefaultUrlMappingsHolder(List<UrlMapping> mappings)`
`DefaultUrlMappingsHolder(List<UrlMapping> mappings, List excludePatterns)`

Method Summary
`List` `getExcludePatterns()` Retrieves the held Exclude Pattern instances as a list, could be null if there is no exclude
`UrlCreator` `getReverseMapping(String controller, String action, Map params)` Retrieves the best guess of a URI for the given controller, action and parameters
`UrlMapping[]` `getUrlMappings()` Retrieves the held UrlMapping instances as an array
`protected UrlMapping` `lookupMapping(String controller, String action, Map params)` Performs a match uses reverse mappings to looks up a mapping from the controller, action and params.
`UrlMappingInfo` `match(String uri)` Match and return the first UrlMappingInfo instance possible
`UrlMappingInfo[]` `matchAll(String uri)` Matches all possible UrlMappingInfo instances to the given URI and returns them all
`UrlMappingInfo[]` `matchAll(String uri, String httpMethod)` Match all possible UrlMappingInfo instances to the given URI and HTTP method
`UrlMappingInfo` `matchStatusCode(int responseCode)` Match and return the first UrlMappingInfo instance possible
`UrlMappingInfo` `matchStatusCode(int responseCode, Throwable e)` Match and return for first UrlMappingInfo for the give response code and exception
`String` `toString()`

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

Constructor Detail

### DefaultUrlMappingsHolder

    public DefaultUrlMappingsHolder(List<UrlMapping> mappings)

### DefaultUrlMappingsHolder

    public DefaultUrlMappingsHolder(List<UrlMapping> mappings,
                                    List excludePatterns)

Method Detail

### getUrlMappings

    public UrlMapping[] getUrlMappings()

  Description copied from interface: `UrlMappingsHolder`
  Retrieves the held UrlMapping instances as an array

  Specified by:
    `getUrlMappings` in interface `UrlMappingsHolder`
  Returns:
    An array of UrlMapping instances

### getExcludePatterns

    public List getExcludePatterns()

  Description copied from interface: `UrlMappingsHolder`
  Retrieves the held Exclude Pattern instances as a list, could be null if there is no exclude

  Specified by:
    `getExcludePatterns` in interface `UrlMappingsHolder`
  Returns:
    An list of String

### getReverseMapping

    public UrlCreator getReverseMapping(String controller,
                                        String action,
                                        Map params)

  Description copied from interface: `UrlMappingsHolder`
  Retrieves the best guess of a URI for the given controller, action and parameters

  Specified by:
    `getReverseMapping` in interface `UrlMappingsHolder`
  Parameters:
    `controller` - The name of the controller
    `action` - The name of the action or null
    `params` - The parameters or null
  Returns:
    A URI for the given arguments
  See Also:
    `UrlMappingsHolder.getReverseMapping(String, String, java.util.Map)`

### lookupMapping

    protected UrlMapping lookupMapping(String controller,
                                       String action,
                                       Map params)

  Performs a match uses reverse mappings to looks up a mapping from the controller, action and params. This is refactored to use a list of mappings identified by only controller and action and then matches the mapping to select the mapping that best matches the params (most possible matches).

  Parameters:
    `controller` - The controller name
    `action` - The action name
    `params` - The params
  Returns:
    A UrlMapping instance or null

### match

    public UrlMappingInfo match(String uri)

  Description copied from interface: `UrlMappingsHolder`
  Match and return the first UrlMappingInfo instance possible

  Specified by:
    `match` in interface `UrlMappingsHolder`
  Parameters:
    `uri` - The URI to match
  Returns:
    A UrlMappingInfo or null
  See Also:
    `UrlMappingsHolder.match(String)`

### matchAll

    public UrlMappingInfo[] matchAll(String uri)

  Description copied from interface: `UrlMappingsHolder`
  Matches all possible UrlMappingInfo instances to the given URI and returns them all

  Specified by:
    `matchAll` in interface `UrlMappingsHolder`
  Parameters:
    `uri` - The URI to match
  Returns:
    An array of 0 or many UrlMappngInfo instances

### matchAll

    public UrlMappingInfo[] matchAll(String uri,
                                     String httpMethod)

  Description copied from interface: `UrlMappingsHolder`
  Match all possible UrlMappingInfo instances to the given URI and HTTP method

  Specified by:
    `matchAll` in interface `UrlMappingsHolder`
  Parameters:
    `uri` - The URI to match
    `httpMethod` - The HTTP method (GET,POST,PUT,DELETE etc.)
  Returns:
    An array of 0 or many UrlMappingInfo instances

### matchStatusCode

    public UrlMappingInfo matchStatusCode(int responseCode)

  Description copied from interface: `UrlMappingsHolder`
  Match and return the first UrlMappingInfo instance possible

  Specified by:
    `matchStatusCode` in interface `UrlMappingsHolder`
  Parameters:
    `responseCode` - The responseCode to match
  Returns:
    A UrlMappingInfo or null

### matchStatusCode

    public UrlMappingInfo matchStatusCode(int responseCode,
                                          Throwable e)

  Description copied from interface: `UrlMappingsHolder`
  Match and return for first UrlMappingInfo for the give response code and exception

  Specified by:
    `matchStatusCode` in interface `UrlMappingsHolder`
  Parameters:
    `responseCode` - The response code
    `e` - The exception
  Returns:
    The UrlMappingInfo instance

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Copyright (c) 2005-2009 The Grails project