Class TargetedUrlByFolderStrategy
- java.lang.Object
-
- org.craftercms.engine.targeting.impl.AbstractTargetedUrlStrategy
-
- org.craftercms.engine.targeting.impl.TargetedUrlByFolderStrategy
-
- All Implemented Interfaces:
TargetedUrlStrategy
public class TargetedUrlByFolderStrategy extends AbstractTargetedUrlStrategy
TargetedUrlStrategy
implementation that recognizes the target ID in the first folder of the URL name (e.g. /en/products/index.xml).- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description static int
SUFFIX_GROUP
static int
TARGET_ID_GROUP
static String
TARGETED_URL_REGEX_FORMAT
-
Fields inherited from class org.craftercms.engine.targeting.impl.AbstractTargetedUrlStrategy
targetIdManager
-
-
Constructor Summary
Constructors Constructor Description TargetedUrlByFolderStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
buildTargetedUrl(String prefix, String targetId, String suffix)
Builds the targeted URL with the specified prefix, target ID and suffix.protected String
doToTargetedUrl(String url, String currentTargetId)
protected String
getPrefix(Matcher matcher)
protected String
getSuffix(Matcher matcher)
protected Pattern
getTargetedUrlPattern()
protected String
getTargetId(Matcher matcher)
boolean
isFileNameBasedStrategy()
Returns true if the strategy is based on the name of the file.-
Methods inherited from class org.craftercms.engine.targeting.impl.AbstractTargetedUrlStrategy
getTargetedUrlComponents, matchUrl, parseTargetedUrl, setTargetIdManager, toTargetedUrl
-
-
-
-
Field Detail
-
TARGETED_URL_REGEX_FORMAT
public static final String TARGETED_URL_REGEX_FORMAT
- See Also:
- Constant Field Values
-
TARGET_ID_GROUP
public static final int TARGET_ID_GROUP
- See Also:
- Constant Field Values
-
SUFFIX_GROUP
public static final int SUFFIX_GROUP
- See Also:
- Constant Field Values
-
-
Method Detail
-
isFileNameBasedStrategy
public boolean isFileNameBasedStrategy()
Description copied from interface:TargetedUrlStrategy
Returns true if the strategy is based on the name of the file.
-
buildTargetedUrl
public String buildTargetedUrl(String prefix, String targetId, String suffix)
Description copied from interface:TargetedUrlStrategy
Builds 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:
buildTargetedUrl
in interfaceTargetedUrlStrategy
- Overrides:
buildTargetedUrl
in classAbstractTargetedUrlStrategy
- Parameters:
prefix
- the URL prefixtargetId
- the target IDsuffix
- the URL suffix- Returns:
- the built targeted URL
-
getPrefix
protected String getPrefix(Matcher matcher)
- Specified by:
getPrefix
in classAbstractTargetedUrlStrategy
-
getTargetId
protected String getTargetId(Matcher matcher)
- Specified by:
getTargetId
in classAbstractTargetedUrlStrategy
-
getSuffix
protected String getSuffix(Matcher matcher)
- Specified by:
getSuffix
in classAbstractTargetedUrlStrategy
-
getTargetedUrlPattern
protected Pattern getTargetedUrlPattern()
- Specified by:
getTargetedUrlPattern
in classAbstractTargetedUrlStrategy
-
doToTargetedUrl
protected String doToTargetedUrl(String url, String currentTargetId)
- Specified by:
doToTargetedUrl
in classAbstractTargetedUrlStrategy
-
-