Package org.apache.wicket.request.mapper
Class AbstractMapper
- java.lang.Object
-
- org.apache.wicket.request.mapper.AbstractMapper
-
- All Implemented Interfaces:
IRequestMapper
public abstract class AbstractMapper extends Object implements IRequestMapper
-
-
Constructor Summary
Constructors Constructor Description AbstractMapper()Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected UrlencodePageParameters(Url url, PageParameters pageParameters, IPageParametersEncoder encoder)Encodes the givenPageParametersto the URL using the givenIPageParametersEncoder.protected PageParametersextractPageParameters(Request request, int segmentsToSkip, IPageParametersEncoder encoder)ExtractsPageParametersfrom the URL using the givenIPageParametersEncoder.protected String[]getMountSegments(String mountPath)Convenience method for representing mountPath as array of segmentsprotected StringgetOptionalPlaceholder(String s)If the string is in an optional parameter placeholder format #{key} this method returns the key.protected StringgetPlaceholder(String s)If the string is in a placeholder format ${key} this method returns the key.protected StringgetPlaceholder(String s, char startChar)If the string is in a placeholder format x{key}, where 'x' can be specified, this method returns the key.protected voidremoveMetaParameter(Url urlCopy)The newIRequestMappers use the first query parameter to hold meta information about the request like page version, component version, locale, ...protected LocaleresolveLocale()protected StringsafeSegmentGetter(List<String> segments, int index, String defaultValue)Utility method to safely get an element from a list of String.protected booleanurlStartsWith(Url url, String... segments)Returns true if the given url starts with specified segments.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.request.IRequestMapper
getCompatibilityScore, mapHandler, mapRequest
-
-
-
-
Constructor Detail
-
AbstractMapper
public AbstractMapper()
Construct.
-
-
Method Detail
-
getPlaceholder
protected String getPlaceholder(String s)
If the string is in a placeholder format ${key} this method returns the key.- Parameters:
s-- Returns:
- placeholder key or
nullif string is not in right format
-
getOptionalPlaceholder
protected String getOptionalPlaceholder(String s)
If the string is in an optional parameter placeholder format #{key} this method returns the key.- Parameters:
s-- Returns:
- placeholder key or
nullif string is not in right format
-
getPlaceholder
protected String getPlaceholder(String s, char startChar)
If the string is in a placeholder format x{key}, where 'x' can be specified, this method returns the key.- Parameters:
s-startChar- the character used to indicate the start of the placeholder- Returns:
- placeholder key or
nullif string is not in right format
-
urlStartsWith
protected boolean urlStartsWith(Url url, String... segments)
Returns true if the given url starts with specified segments.- Parameters:
url-segments-- Returns:
trueif the URL starts with the specified segments,falseotherwise
-
safeSegmentGetter
protected String safeSegmentGetter(List<String> segments, int index, String defaultValue)
Utility method to safely get an element from a list of String. If the specified index is bigger than the size of the list the default value is returned.- Parameters:
segments-index-defaultValue-- Returns:
- the element at the specified position or the default value if the list size is smaller.
-
extractPageParameters
protected PageParameters extractPageParameters(Request request, int segmentsToSkip, IPageParametersEncoder encoder)
ExtractsPageParametersfrom the URL using the givenIPageParametersEncoder.- Parameters:
request-segmentsToSkip- how many URL segments should be skipped because they "belong" to theIRequestMapperencoder-- Returns:
- PageParameters instance
-
removeMetaParameter
protected void removeMetaParameter(Url urlCopy)
The newIRequestMappers use the first query parameter to hold meta information about the request like page version, component version, locale, ... The actualIRequestMapperimplementation can decide whether the this parameter should be removed before creatingPageParametersfrom the currentquery parameters- Parameters:
urlCopy- theUrlthat first query parameter has no value
-
encodePageParameters
protected Url encodePageParameters(Url url, PageParameters pageParameters, IPageParametersEncoder encoder)
Encodes the givenPageParametersto the URL using the givenIPageParametersEncoder. The original URL object is unchanged.- Parameters:
url-pageParameters-encoder-- Returns:
- URL with encoded parameters
-
getMountSegments
protected String[] getMountSegments(String mountPath)
Convenience method for representing mountPath as array of segments- Parameters:
mountPath-- Returns:
- array of path segments
-
resolveLocale
protected Locale resolveLocale()
- Returns:
- the locale to use for parsing any numbers in the request parameters
-
-