Package grails.web.mapping
Interface UrlMapping
-
- All Superinterfaces:
java.lang.Comparable,UrlCreator
- All Known Implementing Classes:
AbstractUrlMapping,RegexUrlMapping,ResponseCodeUrlMapping
public interface UrlMapping extends java.lang.Comparable, UrlCreator
Defines a URL mapping. A URL mapping is a mapping between a URI such as /book/list and a controller, action and/or id.
A UrlMapping should implement Comparable so that UrlMapping instances can be ordered to allow for precendence rules. In other words the URL /book/list should be matched before /book/* as the wildcard is of lesser precedence. By implementing Comparable this can be allowed for.
- Since:
- 0.5
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACTIONThe action this mapping matchesstatic charAMPERSANDstatic java.lang.StringANY_HTTP_METHODConstant used to define a Url mapping that matches any HTTP methodstatic java.lang.StringANY_VERSIONConstant used to define a Url mapping that matches any HTTP methodstatic java.lang.StringCAPTURED_DOUBLE_WILDCARDstatic java.lang.StringCAPTURED_WILDCARDstatic java.lang.StringCONTROLLERThe controller this mapping matchesstatic java.lang.StringDOUBLE_WILDCARDstatic java.lang.StringEXCEPTIONstatic java.lang.StringEXCLUDESstatic java.lang.StringHTTP_METHODThe HTTP method this mapping matchesstatic java.lang.StringINCLUDESstatic java.util.Set<java.lang.String>KEYWORDSstatic java.lang.StringNAMESPACEThe namespace of the URL mappingstatic java.lang.StringOPTIONAL_EXTENSION_WILDCARDstatic java.lang.StringPERMANENTstatic java.lang.StringPLUGINThe plugin of the URL Mappingstatic charQUESTION_MARKstatic java.lang.StringREDIRECT_INFORedirect information for this url mapping.static java.lang.StringRESOURCESstatic java.lang.StringSLASHstatic java.lang.StringURIThe URI of the URL mappingstatic java.lang.StringVERSIONThe version of the URL mappingstatic java.lang.StringVIEWstatic java.lang.StringWILDCARD
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ObjectgetActionName()Retrieves the action name which is either a groovy.lang.Closure that evaluates the action name at runtime or a java.lang.String that represents the action namegrails.gorm.validation.Constrained[]getConstraints()The constraints the apply to this UrlMapping.java.lang.ObjectgetControllerName()Retrieves the controller name which is either a groovy.lang.Closure that evaluates the controller name at runtime or a java.lang.String that represents the controller namejava.lang.StringgetHttpMethod()The HTTP method this URL mapping applies to.java.lang.StringgetMappingName()The name of the mapping in case of named URL mappingjava.lang.ObjectgetNamespace()java.lang.IntegergetPluginIndex()java.lang.ObjectgetPluginName()The name of the plugin this URL mapping relates to, if anyjava.lang.ObjectgetRedirectInfo()The redirect information should be a String or a Map.UrlMappingDatagetUrlData()Retrieves the UrlMappingData instance that describes this UrlMappingjava.lang.StringgetVersion()java.lang.ObjectgetViewName()Returns the name of the view to map tobooleanhasRuntimeVariable(java.lang.String name)Whether the mapping has a runtime variable with the given name such as "/$foo"booleanisDefinedInPlugin()UrlMappingInfomatch(java.lang.String uri)Matches the given URI and returns an instance of the UrlMappingInfo interface or null if a match couldn't be establishedvoidsetMappingName(java.lang.String name)Sets the name of the URL mappingvoidsetParameterValues(java.util.Map parameterValues)Sets any parameter values that should be populated into the requestvoidsetParseRequest(boolean shouldParse)Sets whether this UrlMapping should parse the requestvoidsetPluginIndex(int pluginIndex)Sets whether or not the mapping is defined in a plugin.-
Methods inherited from interface grails.web.mapping.UrlCreator
createRelativeURL, createRelativeURL, createRelativeURL, createRelativeURL, createRelativeURL, createURL, createURL, createURL, createURL, createURL, createURL, createURL
-
-
-
-
Field Detail
-
WILDCARD
static final java.lang.String WILDCARD
- See Also:
- Constant Field Values
-
CAPTURED_WILDCARD
static final java.lang.String CAPTURED_WILDCARD
- See Also:
- Constant Field Values
-
OPTIONAL_EXTENSION_WILDCARD
static final java.lang.String OPTIONAL_EXTENSION_WILDCARD
- See Also:
- Constant Field Values
-
SLASH
static final java.lang.String SLASH
- See Also:
- Constant Field Values
-
QUESTION_MARK
static final char QUESTION_MARK
- See Also:
- Constant Field Values
-
AMPERSAND
static final char AMPERSAND
- See Also:
- Constant Field Values
-
DOUBLE_WILDCARD
static final java.lang.String DOUBLE_WILDCARD
- See Also:
- Constant Field Values
-
CAPTURED_DOUBLE_WILDCARD
static final java.lang.String CAPTURED_DOUBLE_WILDCARD
- See Also:
- Constant Field Values
-
CONTROLLER
static final java.lang.String CONTROLLER
The controller this mapping matches- See Also:
- Constant Field Values
-
ACTION
static final java.lang.String ACTION
The action this mapping matches- See Also:
- Constant Field Values
-
HTTP_METHOD
static final java.lang.String HTTP_METHOD
The HTTP method this mapping matches- See Also:
- Constant Field Values
-
REDIRECT_INFO
static final java.lang.String REDIRECT_INFO
Redirect information for this url mapping.- See Also:
- Constant Field Values
-
ANY_HTTP_METHOD
static final java.lang.String ANY_HTTP_METHOD
Constant used to define a Url mapping that matches any HTTP method- See Also:
- Constant Field Values
-
VERSION
static final java.lang.String VERSION
The version of the URL mapping- See Also:
- Constant Field Values
-
ANY_VERSION
static final java.lang.String ANY_VERSION
Constant used to define a Url mapping that matches any HTTP method- See Also:
- Constant Field Values
-
URI
static final java.lang.String URI
The URI of the URL mapping- See Also:
- Constant Field Values
-
PLUGIN
static final java.lang.String PLUGIN
The plugin of the URL Mapping- See Also:
- Constant Field Values
-
NAMESPACE
static final java.lang.String NAMESPACE
The namespace of the URL mapping- See Also:
- Constant Field Values
-
VIEW
static final java.lang.String VIEW
- See Also:
- Constant Field Values
-
RESOURCES
static final java.lang.String RESOURCES
- See Also:
- Constant Field Values
-
EXCLUDES
static final java.lang.String EXCLUDES
- See Also:
- Constant Field Values
-
INCLUDES
static final java.lang.String INCLUDES
- See Also:
- Constant Field Values
-
PERMANENT
static final java.lang.String PERMANENT
- See Also:
- Constant Field Values
-
EXCEPTION
static final java.lang.String EXCEPTION
- See Also:
- Constant Field Values
-
KEYWORDS
static final java.util.Set<java.lang.String> KEYWORDS
-
-
Method Detail
-
match
UrlMappingInfo match(java.lang.String uri)
Matches the given URI and returns an instance of the UrlMappingInfo interface or null if a match couldn't be established- Parameters:
uri- The URI to match- Returns:
- An instance of UrlMappingInfo or null if the URI doesn't match
-
getUrlData
UrlMappingData getUrlData()
Retrieves the UrlMappingData instance that describes this UrlMapping- Returns:
- The UrlMappingData instance
-
getConstraints
grails.gorm.validation.Constrained[] getConstraints()
The constraints the apply to this UrlMapping. Each constraint maps to a GString token in a URL mapping in order. For example consider the URL:
/blog/$author/$title/$year?/$month?/$day?This results in 5 ConstrainedProperty instances called author, title, year, month and day
- Returns:
- An array containing the ConstrainedProperty objects of this URLMapping
-
getControllerName
java.lang.Object getControllerName()
Retrieves the controller name which is either a groovy.lang.Closure that evaluates the controller name at runtime or a java.lang.String that represents the controller name- Returns:
- The controller name as a
ClosureorString
-
getActionName
java.lang.Object getActionName()
Retrieves the action name which is either a groovy.lang.Closure that evaluates the action name at runtime or a java.lang.String that represents the action name- Returns:
- The action name as a
ClosureorString
-
getPluginName
java.lang.Object getPluginName()
The name of the plugin this URL mapping relates to, if any- Returns:
- The plugin name
-
getNamespace
java.lang.Object getNamespace()
- Returns:
- the name of the controller namespace
-
getViewName
java.lang.Object getViewName()
Returns the name of the view to map to- Returns:
- The view name
-
getHttpMethod
java.lang.String getHttpMethod()
The HTTP method this URL mapping applies to. Will be null for all HTTP methods- Returns:
- The HTTP method
-
getVersion
java.lang.String getVersion()
- Returns:
- The version of the URL mapping. Used for versioning of REST services
-
setParameterValues
void setParameterValues(java.util.Map parameterValues)
Sets any parameter values that should be populated into the request- Parameters:
parameterValues- The parameter values to set
-
setParseRequest
void setParseRequest(boolean shouldParse)
Sets whether this UrlMapping should parse the request- Parameters:
shouldParse- True if it should
-
getMappingName
java.lang.String getMappingName()
The name of the mapping in case of named URL mapping- Returns:
- The mapping name
-
setMappingName
void setMappingName(java.lang.String name)
Sets the name of the URL mapping- Parameters:
name- The name of the URL mapping
-
hasRuntimeVariable
boolean hasRuntimeVariable(java.lang.String name)
Whether the mapping has a runtime variable with the given name such as "/$foo"- Parameters:
name- The name of the variable- Returns:
- true if the mapping has the variable
-
getRedirectInfo
java.lang.Object getRedirectInfo()
The redirect information should be a String or a Map. If it is a String that string is the URI to redirect to. If it is a Map, that Map may contain any entries supported as arguments to the dynamic redirect(Map) method on a controller.- Returns:
- redirect information for this url mapping
-
setPluginIndex
void setPluginIndex(int pluginIndex)
Sets whether or not the mapping is defined in a plugin.- Parameters:
pluginIndex- The index of the plugin that defines this mapping
-
getPluginIndex
java.lang.Integer getPluginIndex()
- Returns:
- The plugin index or null
-
isDefinedInPlugin
boolean isDefinedInPlugin()
- Returns:
- True if the URL mapping comes from a plugin
-
-