Class AbstractBookmarkableMapper
- java.lang.Object
-
- org.apache.wicket.request.mapper.AbstractMapper
-
- org.apache.wicket.core.request.mapper.AbstractComponentMapper
-
- org.apache.wicket.core.request.mapper.AbstractBookmarkableMapper
-
- All Implemented Interfaces:
org.apache.wicket.request.IRequestMapper
- Direct Known Subclasses:
BookmarkableMapper,MountedMapper,PackageMapper,ResourceMapper
public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
Abstract encoder for Bookmarkable, Hybrid and BookmarkableListener URLs.- Author:
- Matej Knopp
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractBookmarkableMapper.MountPathSegmentprotected static classAbstractBookmarkableMapper.UrlInfoRepresents information stored in URL.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String[]mountSegmentsprotected org.apache.wicket.request.mapper.parameter.IPageParametersEncoderpageParametersEncoderprotected java.util.List<AbstractBookmarkableMapper.MountPathSegment>pathSegments
-
Constructor Summary
Constructors Constructor Description AbstractBookmarkableMapper()Construct.AbstractBookmarkableMapper(java.lang.String mountPath, org.apache.wicket.request.mapper.parameter.IPageParametersEncoder pageParametersEncoder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract org.apache.wicket.request.UrlbuildUrl(AbstractBookmarkableMapper.UrlInfo info)Builds URL for the givenAbstractBookmarkableMapper.UrlInfoinstance.protected booleancheckPageClass(java.lang.Class<? extends IRequestablePage> pageClass)protected booleancheckPageInstance(IRequestablePage page)protected org.apache.wicket.request.mapper.parameter.PageParametersextractPageParameters(org.apache.wicket.request.Request request, org.apache.wicket.request.Url url)Extracts the PageParameters from URL if there are anyintgetCompatibilityScore(org.apache.wicket.request.Request request)protected int[]getMatchedSegmentSizes(org.apache.wicket.request.Url url)protected org.apache.wicket.request.mapper.info.PageInfogetPageInfo(IPageRequestHandler handler)protected java.util.List<AbstractBookmarkableMapper.MountPathSegment>getPathSegments(java.lang.String[] segments)protected booleanisCaseSensitiveMatch()protected booleanisFixedSegment(java.lang.String segment)org.apache.wicket.request.UrlmapHandler(org.apache.wicket.request.IRequestHandler requestHandler)org.apache.wicket.request.IRequestHandlermapRequest(org.apache.wicket.request.Request request)protected org.apache.wicket.request.mapper.parameter.PageParametersnewPageParameters()protected abstract booleanpageMustHaveBeenCreatedBookmarkable()Indicates whether hybridRenderPageRequestHandlerURL for page will be generated only if page has been created with bookmarkable URL.protected abstract AbstractBookmarkableMapper.UrlInfoparseRequest(org.apache.wicket.request.Request request)Parse the given request to anAbstractBookmarkableMapper.UrlInfoinstance.protected org.apache.wicket.request.IRequestHandlerprocessBookmarkable(java.lang.Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)Creates aIRequestHandlerthat processes a bookmarkable request.protected org.apache.wicket.request.IRequestHandlerprocessHybrid(org.apache.wicket.request.mapper.info.PageInfo pageInfo, java.lang.Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.Integer renderCount)Creates aIRequestHandlerthat processes a hybrid request.protected org.apache.wicket.request.IRequestHandlerprocessListener(org.apache.wicket.request.mapper.info.PageComponentInfo pageComponentInfo, java.lang.Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)Creates aIRequestHandlerthat notifies anIRequestListener.protected java.util.LocaleresolveUserLocale()OverrideAbstractMapper.resolveLocale()to return the result of this method if you want to use the user's session or request locale for parsing numbers from the page parametersprotected booleansegmentsMatch(java.lang.String mountedSegment, java.lang.String urlSegment)Decides whether a segment from the mounted path matches with a segment from the requested url.AbstractBookmarkableMappersetCaseSensitiveMatch(boolean isCaseSensitive)Sets whether the matching of mounted segments against request's url ones should be case sensitive or not.protected booleansetPlaceholders(org.apache.wicket.request.mapper.parameter.PageParameters parameters, org.apache.wicket.request.Url url)Replaces mandatory and optional parameters with their values.protected booleanurlStartsWithMountedSegments(org.apache.wicket.request.Url url)-
Methods inherited from class org.apache.wicket.core.request.mapper.AbstractComponentMapper
cleanClassName, encodePageComponentInfo, getContext, getPageClass, getPageComponentInfo, removeMetaParameter
-
-
-
-
Field Detail
-
pathSegments
protected final java.util.List<AbstractBookmarkableMapper.MountPathSegment> pathSegments
-
mountSegments
protected final java.lang.String[] mountSegments
-
pageParametersEncoder
protected final org.apache.wicket.request.mapper.parameter.IPageParametersEncoder pageParametersEncoder
-
-
Method Detail
-
parseRequest
protected abstract AbstractBookmarkableMapper.UrlInfo parseRequest(org.apache.wicket.request.Request request)
Parse the given request to anAbstractBookmarkableMapper.UrlInfoinstance.- Parameters:
request-- Returns:
- UrlInfo instance or
nullif this encoder can not handle the request
-
buildUrl
protected abstract org.apache.wicket.request.Url buildUrl(AbstractBookmarkableMapper.UrlInfo info)
Builds URL for the givenAbstractBookmarkableMapper.UrlInfoinstance. The URL this method produces must be parseable by theparseRequest(Request)method.- Parameters:
info-- Returns:
- Url result URL
-
pageMustHaveBeenCreatedBookmarkable
protected abstract boolean pageMustHaveBeenCreatedBookmarkable()
Indicates whether hybridRenderPageRequestHandlerURL for page will be generated only if page has been created with bookmarkable URL.For generic bookmarkable encoders this method should return
true. For explicit (mounted) encoders this method should returnfalse- Returns:
trueif hybrid URL requires page created bookmarkable,falseotherwise.
-
getCompatibilityScore
public int getCompatibilityScore(org.apache.wicket.request.Request request)
-
processBookmarkable
protected org.apache.wicket.request.IRequestHandler processBookmarkable(java.lang.Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)
Creates aIRequestHandlerthat processes a bookmarkable request.- Parameters:
pageClass-pageParameters-- Returns:
- a
IRequestHandlercapable of processing the bookmarkable request.
-
processHybrid
protected org.apache.wicket.request.IRequestHandler processHybrid(org.apache.wicket.request.mapper.info.PageInfo pageInfo, java.lang.Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters, java.lang.Integer renderCount)Creates aIRequestHandlerthat processes a hybrid request. When the page identified bypageInfowas not available, the request should be treated as a bookmarkable request.- Parameters:
pageInfo-pageClass-pageParameters-renderCount-- Returns:
- a
IRequestHandlercapable of processing the hybrid request.
-
processListener
protected org.apache.wicket.request.IRequestHandler processListener(org.apache.wicket.request.mapper.info.PageComponentInfo pageComponentInfo, java.lang.Class<? extends IRequestablePage> pageClass, org.apache.wicket.request.mapper.parameter.PageParameters pageParameters)Creates aIRequestHandlerthat notifies anIRequestListener.- Parameters:
pageComponentInfo-pageClass-pageParameters-- Returns:
- a
IRequestHandlerthat notifies anIRequestListener.
-
mapRequest
public org.apache.wicket.request.IRequestHandler mapRequest(org.apache.wicket.request.Request request)
-
checkPageInstance
protected boolean checkPageInstance(IRequestablePage page)
-
checkPageClass
protected boolean checkPageClass(java.lang.Class<? extends IRequestablePage> pageClass)
-
mapHandler
public org.apache.wicket.request.Url mapHandler(org.apache.wicket.request.IRequestHandler requestHandler)
-
getPageInfo
protected final org.apache.wicket.request.mapper.info.PageInfo getPageInfo(IPageRequestHandler handler)
-
newPageParameters
protected org.apache.wicket.request.mapper.parameter.PageParameters newPageParameters()
- Returns:
- a new instance of
PageParametersthat will be passed to the page/resource
-
resolveUserLocale
protected java.util.Locale resolveUserLocale()
OverrideAbstractMapper.resolveLocale()to return the result of this method if you want to use the user's session or request locale for parsing numbers from the page parameters- Returns:
- the Session or Request's locale to use for parsing any numbers in the request parameters
-
getPathSegments
protected java.util.List<AbstractBookmarkableMapper.MountPathSegment> getPathSegments(java.lang.String[] segments)
-
isFixedSegment
protected boolean isFixedSegment(java.lang.String segment)
-
extractPageParameters
protected org.apache.wicket.request.mapper.parameter.PageParameters extractPageParameters(org.apache.wicket.request.Request request, org.apache.wicket.request.Url url)Extracts the PageParameters from URL if there are any
-
getMatchedSegmentSizes
protected int[] getMatchedSegmentSizes(org.apache.wicket.request.Url url)
-
segmentsMatch
protected boolean segmentsMatch(java.lang.String mountedSegment, java.lang.String urlSegment)Decides whether a segment from the mounted path matches with a segment from the requested url. A custom implementation of this class may use more complex logic to handle spelling errors- Parameters:
mountedSegment- the segment from the mounted pathurlSegment- the segment from the request url- Returns:
trueif the segments match
-
isCaseSensitiveMatch
protected boolean isCaseSensitiveMatch()
- Returns:
- whether the matching of mounted segments against request's url ones should be case sensitive or not
-
setCaseSensitiveMatch
public AbstractBookmarkableMapper setCaseSensitiveMatch(boolean isCaseSensitive)
Sets whether the matching of mounted segments against request's url ones should be case sensitive or not.- Parameters:
isCaseSensitive- a flag indicating whether the matching of mounted segments against request's url ones should be case sensitive or not- Returns:
- this instance, for chaining
-
setPlaceholders
protected boolean setPlaceholders(org.apache.wicket.request.mapper.parameter.PageParameters parameters, org.apache.wicket.request.Url url)Replaces mandatory and optional parameters with their values. If a mandatory parameter is not provided then the method returnsfalseindicating that there is a problem. Optional parameters with missing values are just dropped.- Parameters:
parameters- The parameters with the valuesurl- The url with the placeholders- Returns:
trueif all mandatory parameters are properly substituted,false- otherwise
-
urlStartsWithMountedSegments
protected boolean urlStartsWithMountedSegments(org.apache.wicket.request.Url url)
-
-