Class AbstractTargetedUrlStrategy
java.lang.Object
org.craftercms.engine.targeting.impl.AbstractTargetedUrlStrategy
- All Implemented Interfaces:
TargetedUrlStrategy
- Direct Known Subclasses:
TargetedUrlByFileStrategy,TargetedUrlByFolderStrategy
TargetedUrlStrategy base class, that provides basic implementations of parseTargetedUrl(String)
and buildTargetedUrl(String, String, String).- Author:
- avasquez
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildTargetedUrl(String prefix, String targetId, String suffix) Builds the targeted URL with the specified prefix, target ID and suffix.protected abstract StringdoToTargetedUrl(String url, String currentTargetId) protected abstract Stringprotected abstract Stringprotected TargetedUrlComponentsgetTargetedUrlComponents(Matcher matcher) protected abstract Patternprotected abstract StringgetTargetId(Matcher matcher) protected MatcherparseTargetedUrl(String targetedUrl) Parses the specified targeted URL, extracting it's components.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.craftercms.engine.targeting.TargetedUrlStrategy
isFileNameBasedStrategy
-
Field Details
-
targetIdManager
-
-
Constructor Details
-
AbstractTargetedUrlStrategy
-
-
Method Details
-
toTargetedUrl
Description copied from interface:TargetedUrlStrategyReturns the specified URL as a targeted URL (if it's not already a targeted URL) using the current target ID. For example, if the specified URL is /products/index.xml, the current target ID is "en_US", and the strategy handles targeted URLs by file name, then the resulting targeted URL is /products/index_en_US.xml.WARNING: The URLs strategies should receive should be relative, without the root folder, since most targeted URLs are handled using a regex.
- Specified by:
toTargetedUrlin interfaceTargetedUrlStrategy- Parameters:
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)- Returns:
- the targeted URL version of the URL.
-
parseTargetedUrl
Description copied from interface:TargetedUrlStrategyParses the specified targeted URL, extracting it's components. For example, if the specified URL is /products/index_en_US.xml, and the strategy handles targeted URLs by file name, then the URL will be split into the following:- Prefix: /products/index
- Target ID: en_US
- Suffix: .xml
- Specified by:
parseTargetedUrlin interfaceTargetedUrlStrategy- Parameters:
targetedUrl- the targeted URL to parse- Returns:
- the URL components
-
buildTargetedUrl
Description copied from interface:TargetedUrlStrategyBuilds the targeted URL with the specified prefix, target ID and suffix. For example, if the prefix is /products/index, the target ID en_US, the suffix .xml, and the strategy handles targeted URLs by file name, then the resulting URL will be /products/index_en_US.xml.- Specified by:
buildTargetedUrlin interfaceTargetedUrlStrategy- Parameters:
prefix- the URL prefixtargetId- the target IDsuffix- the URL suffix- Returns:
- the built targeted URL
-
matchUrl
-
getTargetedUrlComponents
-
getPrefix
-
getTargetId
-
getSuffix
-
getTargetedUrlPattern
-
doToTargetedUrl
-