public class ModuleFilterMapping extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Constructor and Description |
---|
ModuleFilterMapping(Module module)
Default constructor, requires a Module
|
Modifier and Type | Method and Description |
---|---|
void |
addServletName(String servletName)
Adds a Servlet name to the List of those mapped to this filter
|
void |
addUrlPattern(String urlPattern)
Adds a Url pattern to the List of those mapped to this filter
|
static boolean |
filterMappingPasses(ModuleFilterMapping filterMapping,
String requestPath)
Return
true if the passed Filter passes one or more filter mappings otherwise,
return false . |
String |
getFilterName() |
Module |
getModule() |
List<String> |
getServletNames() |
List<String> |
getUrlPatterns() |
static Deque<ModuleFilterMapping> |
retrieveFilterMappings(Module module)
Static method to parse through a Module's configuration file and return a List of
ModuleFilterMapping objects for which there are configuration elements.
|
static boolean |
servletNameMatches(String patternToCheck,
String servletName)
Return
true if the specified servlet name matches the filterMapping otherwise
return false . |
void |
setFilterName(String filterName) |
void |
setModule(Module module) |
void |
setServletNames(List<String> servletNames) |
void |
setUrlPatterns(List<String> urlPatterns) |
static boolean |
urlPatternMatches(String patternToCheck,
String requestPath)
Return
true if the context-relative request path matches the patternToCheck
otherwise, return false . |
public static final long serialVersionUID
public ModuleFilterMapping(Module module)
module
- - the module to use to construct this ModuleFilterMappingpublic String getFilterName()
public void setFilterName(String filterName)
filterName
- the name of the Filterpublic List<String> getServletNames()
public void setServletNames(List<String> servletNames)
servletNames
- a List of all Servlet Names mapped to this filterpublic void addServletName(String servletName)
servletName
- - The servlet name to addpublic List<String> getUrlPatterns()
public void setUrlPatterns(List<String> urlPatterns)
urlPatterns
- a List of all Url Patterns mapped to this filterpublic void addUrlPattern(String urlPattern)
urlPattern
- - The urlPattern to addpublic static boolean filterMappingPasses(ModuleFilterMapping filterMapping, String requestPath)
true
if the passed Filter passes one or more filter mappings otherwise,
return false
.filterMapping
- - The ModuleFilterMapping
to check for matching servlets and url
patternsrequestPath
- - The URI of the request to check against the ModuleFilterMapping
,
with the context path already removed (since module filter mappings are relative to the
context path).ModuleFilterMapping
matches the passed requestPath For
example: Passing a ModuleFilterMapping containing a urlPattern of "*" would return
true for any requestPath Passing a ModuleFilterMapping containing a urlPattern of
"*.jsp" would return true for any requestPath ending in ".jsp"
Should return false if the requestPath is null
Should return true if the ModuleFilterMapping contains any matching urlPatterns for this
requestPath
Should return true if the ModuleFilterMapping contains any matching servletNames for this
requestPath
Should return false if no matches are found for this requestPathpublic static boolean urlPatternMatches(String patternToCheck, String requestPath)
true
if the context-relative request path matches the patternToCheck
otherwise, return false
.patternToCheck
- String pattern to checkrequestPath
- to check
Should return false if the patternToCheck is null
Should return true if the pattern is *
Should return true if the pattern is /*
Should return true if the pattern matches the requestPath exactly
Should return true if the pattern matches everything up to a suffix of /*
Should return true if the pattern matches by extension
Should return false if no pattern matchespublic static boolean servletNameMatches(String patternToCheck, String servletName)
true
if the specified servlet name matches the filterMapping otherwise
return false
.patternToCheck
- String pattern to checkservletName
- Servlet Name to check
Should return false if the patternToCheck is null
Should return true if the pattern is *
Should return true if the pattern matches the servlet name exactly
Should return false if no pattern matchespublic static Deque<ModuleFilterMapping> retrieveFilterMappings(Module module)
<filter-mapping> <filter-name>MyFilterName</filter-name> <url-pattern>The pattern of URLs to match</filter-class> </filter-mapping> or <filter-mapping> <filter-name>MyFilterName</filter-name> <servlet-name>The servlet name to match</servlet-name> </filter-mapping>
module
- - The Module
for which you want to retrieve the defined
ModuleFilterMapping
sDeque
of ModuleFilterMapping
s that are defined for the passed
Module
Copyright © 2024 OpenMRS Inc.. All rights reserved.