public abstract class AbstractTargetedUrlStrategy extends Object implements TargetedUrlStrategy
TargetedUrlStrategy
base class, that provides basic implementations of parseTargetedUrl(String)
and buildTargetedUrl(String, String, String)
.Modifier and Type | Field and Description |
---|---|
protected TargetIdManager |
targetIdManager |
Constructor and Description |
---|
AbstractTargetedUrlStrategy() |
Modifier and Type | Method and Description |
---|---|
String |
buildTargetedUrl(String prefix,
String targetId,
String suffix)
Builds the targeted URL with the specified prefix, target ID and suffix.
|
protected abstract String |
doToTargetedUrl(String url,
String currentTargetId) |
protected abstract String |
getPrefix(Matcher matcher) |
protected abstract String |
getSuffix(Matcher matcher) |
protected TargetedUrlComponents |
getTargetedUrlComponents(Matcher matcher) |
protected abstract Pattern |
getTargetedUrlPattern() |
protected abstract String |
getTargetId(Matcher matcher) |
protected Matcher |
matchUrl(String url) |
TargetedUrlComponents |
parseTargetedUrl(String targetedUrl)
Parses the specified targeted URL, extracting it's components.
|
void |
setTargetIdManager(TargetIdManager targetIdManager) |
String |
toTargetedUrl(String url,
boolean forceCurrentTargetId)
Returns the specified URL as a targeted URL (if it's not already a targeted URL) using the current target ID.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isFileNameBasedStrategy
protected TargetIdManager targetIdManager
public void setTargetIdManager(TargetIdManager targetIdManager)
public String toTargetedUrl(String url, boolean forceCurrentTargetId)
TargetedUrlStrategy
WARNING: The URLs strategies should receive should be relative, without the root folder, since most targeted URLs are handled using a regex.
toTargetedUrl
in interface TargetedUrlStrategy
url
- the URL to transform to a targeted URLforceCurrentTargetId
- true if the URL should be forced to contain the current target ID (e.g the URL
is /products/index_fr.xml but the current target ID is en, then the URL will be
transformed to /products/index_en.xml)public TargetedUrlComponents parseTargetedUrl(String targetedUrl)
TargetedUrlStrategy
parseTargetedUrl
in interface TargetedUrlStrategy
targetedUrl
- the targeted URL to parsepublic String buildTargetedUrl(String prefix, String targetId, String suffix)
TargetedUrlStrategy
buildTargetedUrl
in interface TargetedUrlStrategy
prefix
- the URL prefixtargetId
- the target IDsuffix
- the URL suffixprotected TargetedUrlComponents getTargetedUrlComponents(Matcher matcher)
protected abstract Pattern getTargetedUrlPattern()
Copyright © 2020 CrafterCMS. All rights reserved.