public abstract class AbstractBookmarkableMapper extends AbstractComponentMapper
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractBookmarkableMapper.MountPathSegment |
protected static class |
AbstractBookmarkableMapper.UrlInfo
Represents information stored in URL.
|
Modifier and Type | Field and Description |
---|---|
protected String[] |
mountSegments |
protected IPageParametersEncoder |
pageParametersEncoder |
protected List<AbstractBookmarkableMapper.MountPathSegment> |
pathSegments |
Constructor and Description |
---|
AbstractBookmarkableMapper()
Construct.
|
AbstractBookmarkableMapper(String mountPath,
IPageParametersEncoder pageParametersEncoder) |
Modifier and Type | Method and Description |
---|---|
protected abstract Url |
buildUrl(AbstractBookmarkableMapper.UrlInfo info)
Builds URL for the given
AbstractBookmarkableMapper.UrlInfo instance. |
protected boolean |
checkPageClass(Class<? extends IRequestablePage> pageClass) |
protected boolean |
checkPageInstance(IRequestablePage page) |
protected PageParameters |
extractPageParameters(Request request,
Url url)
Extracts the PageParameters from URL if there are any
|
int |
getCompatibilityScore(Request request)
Returns the score representing how compatible this request mapper is to processing the given
request.
|
protected int[] |
getMatchedSegmentSizes(Url url) |
protected PageInfo |
getPageInfo(IPageRequestHandler handler) |
protected List<AbstractBookmarkableMapper.MountPathSegment> |
getPathSegments(String[] segments) |
protected boolean |
isCaseSensitiveMatch() |
protected boolean |
isFixedSegment(String segment) |
Url |
mapHandler(IRequestHandler requestHandler)
|
IRequestHandler |
mapRequest(Request request)
|
protected PageParameters |
newPageParameters() |
protected abstract boolean |
pageMustHaveBeenCreatedBookmarkable()
Indicates whether hybrid
RenderPageRequestHandler URL for page will be generated only
if page has been created with bookmarkable URL. |
protected abstract AbstractBookmarkableMapper.UrlInfo |
parseRequest(Request request)
Parse the given request to an
AbstractBookmarkableMapper.UrlInfo instance. |
protected IRequestHandler |
processBookmarkable(Class<? extends IRequestablePage> pageClass,
PageParameters pageParameters)
Creates a
IRequestHandler that processes a bookmarkable request. |
protected IRequestHandler |
processHybrid(PageInfo pageInfo,
Class<? extends IRequestablePage> pageClass,
PageParameters pageParameters,
Integer renderCount)
Creates a
IRequestHandler that processes a hybrid request. |
protected IRequestHandler |
processListener(PageComponentInfo pageComponentInfo,
Class<? extends IRequestablePage> pageClass,
PageParameters pageParameters)
Creates a
IRequestHandler that notifies an IRequestListener . |
protected Locale |
resolveUserLocale()
Override
AbstractMapper.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 |
protected boolean |
segmentsMatch(String mountedSegment,
String urlSegment)
Decides whether a segment from the mounted path matches with a segment
from the requested url.
|
AbstractBookmarkableMapper |
setCaseSensitiveMatch(boolean isCaseSensitive)
Sets whether the matching of mounted segments against request's url ones should be
case sensitive or not.
|
protected boolean |
setPlaceholders(PageParameters parameters,
Url url)
Replaces mandatory and optional parameters with their values.
|
protected boolean |
urlStartsWithMountedSegments(Url url) |
cleanClassName, encodePageComponentInfo, getContext, getPageClass, getPageComponentInfo, removeMetaParameter
encodePageParameters, extractPageParameters, getMountSegments, getOptionalPlaceholder, getPlaceholder, getPlaceholder, resolveLocale, safeSegmentGetter, urlStartsWith
protected final List<AbstractBookmarkableMapper.MountPathSegment> pathSegments
protected final String[] mountSegments
protected final IPageParametersEncoder pageParametersEncoder
public AbstractBookmarkableMapper()
public AbstractBookmarkableMapper(String mountPath, IPageParametersEncoder pageParametersEncoder)
protected abstract AbstractBookmarkableMapper.UrlInfo parseRequest(Request request)
AbstractBookmarkableMapper.UrlInfo
instance.request
- null
if this encoder can not handle the requestprotected abstract Url buildUrl(AbstractBookmarkableMapper.UrlInfo info)
AbstractBookmarkableMapper.UrlInfo
instance. The URL this method produces must be
parseable by the parseRequest(Request)
method.info
- protected abstract boolean pageMustHaveBeenCreatedBookmarkable()
RenderPageRequestHandler
URL 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 return false
true
if hybrid URL requires page created bookmarkable,
false
otherwise.public int getCompatibilityScore(Request request)
IRequestMapper
A good criteria for calculating the score is the number of matched url segments. For example
when there are two mappers for a mounted page, one mapped to /foo
another to
/foo/bar
and the incoming request URL is /foo/bar/baz, the mapping
to /foo/bar
should probably handle the request first as it has matching segments
count of 2 while the first one has only matching segments count of 1.
Note that the method can return value greater then zero even if the mapper does not recognize the request.
protected IRequestHandler processBookmarkable(Class<? extends IRequestablePage> pageClass, PageParameters pageParameters)
IRequestHandler
that processes a bookmarkable request.pageClass
- pageParameters
- IRequestHandler
capable of processing the bookmarkable request.protected IRequestHandler processHybrid(PageInfo pageInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters, Integer renderCount)
IRequestHandler
that processes a hybrid request. When the page identified
by pageInfo
was not available, the request should be treated as a bookmarkable
request.pageInfo
- pageClass
- pageParameters
- renderCount
- IRequestHandler
capable of processing the hybrid request.protected IRequestHandler processListener(PageComponentInfo pageComponentInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters)
IRequestHandler
that notifies an IRequestListener
.pageComponentInfo
- pageClass
- pageParameters
- IRequestHandler
that notifies an IRequestListener
.public IRequestHandler mapRequest(Request request)
IRequestMapper
request
- provides access to request data (i.e. Url and Parameters)null
protected boolean checkPageInstance(IRequestablePage page)
protected boolean checkPageClass(Class<? extends IRequestablePage> pageClass)
public Url mapHandler(IRequestHandler requestHandler)
IRequestMapper
null
.protected final PageInfo getPageInfo(IPageRequestHandler handler)
protected PageParameters newPageParameters()
PageParameters
that will be passed to the page/resourceprotected Locale resolveUserLocale()
AbstractMapper.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 List<AbstractBookmarkableMapper.MountPathSegment> getPathSegments(String[] segments)
protected boolean isFixedSegment(String segment)
protected PageParameters extractPageParameters(Request request, Url url)
protected int[] getMatchedSegmentSizes(Url url)
protected boolean segmentsMatch(String mountedSegment, String urlSegment)
mountedSegment
- the segment from the mounted pathurlSegment
- the segment from the request urltrue
if the segments matchprotected boolean isCaseSensitiveMatch()
public AbstractBookmarkableMapper setCaseSensitiveMatch(boolean isCaseSensitive)
isCaseSensitive
- a flag indicating whether the matching of mounted segments against request's
url ones should be case sensitive or notprotected boolean setPlaceholders(PageParameters parameters, Url url)
false
indicating that there is a problem.
Optional parameters with missing values are just dropped.parameters
- The parameters with the valuesurl
- The url with the placeholderstrue
if all mandatory parameters are properly substituted,
false
- otherwiseprotected boolean urlStartsWithMountedSegments(Url url)
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.