Class CmsMacroResolver
- java.lang.Object
-
- org.opencms.util.CmsMacroResolver
-
- All Implemented Interfaces:
I_CmsMacroResolver
- Direct Known Subclasses:
CmsGalleryNameMacroResolver
,CmsNotificationMacroResolver
,CmsVersionMacroResolver
public class CmsMacroResolver extends java.lang.Object implements I_CmsMacroResolver
Resolves macros in the form of%(key)
or${key}
in an input String.Starting with OpenCms 7.0, the preferred form of a macro is
%(key)
. This is to avoid conflicts / confusion with the JSP EL, which also uses the${key}
syntax.The macro names that can be resolved depend of the context objects provided to the resolver using the
set...
methods.- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_ATTRIBUTE
The prefix indicating that the key represents an OpenCms runtime attribute.static java.lang.String
KEY_CONTEXT_PATH
Key used to specify the context path as macro value.static java.lang.String
KEY_CURRENT_ORGUNIT_DESCRIPTION
Key used to specify the description of the current organizational unit as macro value.static java.lang.String
KEY_CURRENT_ORGUNIT_FQN
Key used to specify the full qualified name of the current organizational unit as macro value.static java.lang.String
KEY_CURRENT_TIME
Key used to specify the current time as macro value.static java.lang.String
KEY_CURRENT_USER_CITY
Key used to specify the city of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_COUNTRY
Key used to specify the country of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_DISPLAYNAME
Key used to specify the display name of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_EMAIL
Key used to specify the email address of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_FIRSTNAME
Key used to specify the first name of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_FULLNAME
Key used to specify the full name of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_INSTITUTION
Key used to specify the institution of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_LASTLOGIN
Key used to specify the last login date of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_LASTNAME
Key used to specify the last name of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_NAME
Key used to specify the user name of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_STREET
Key used to specify the street of the current user as macro value.static java.lang.String
KEY_CURRENT_USER_ZIP
Key used to specify the zip code of the current user as macro value.static java.lang.String
KEY_LOCALIZED_PREFIX
Key prefix used to specify the value of a localized key as macro value.static java.lang.String
KEY_OPENCMS
Identifier for "magic" parameter names.static java.lang.String
KEY_PAGE_CONTEXT
The prefix indicating that the key represents a page context object.static java.lang.String
KEY_PARAM
Prefix for getting parameters from the CmsParameterStore.static java.lang.String
KEY_PROJECT_ID
Key used to specify the project id as macro value.static java.lang.String
KEY_PROPERTY
The prefix indicating that the key represents a property to be read on the current request URI.static java.lang.String
KEY_PROPERTY_ELEMENT
The prefix indicating that the key represents a property to be read on the current element.static java.lang.String
KEY_RANDOM_ID
Key used to specify a random id as macro value.static java.lang.String
KEY_REQUEST_ENCODING
Key used to specify the request encoding as macro value.static java.lang.String
KEY_REQUEST_FOLDER
Key used to specify the folder of the request URI as macro value.static java.lang.String
KEY_REQUEST_LOCALE
Key user to specify the request locale as macro value.static java.lang.String
KEY_REQUEST_PARAM
The prefix indicating that the key represents a HTTP request parameter.static java.lang.String
KEY_REQUEST_SITEROOT
Key used to specify the request site root as macro value.static java.lang.String
KEY_REQUEST_URI
Key used to specify the request uri as macro value.static java.lang.String
KEY_SITEMAP_ATTRIBUTE
Key for accessing sitemap attributes.static java.lang.String
KEY_VALIDATION_PATH
Key used to specify the validation path as macro value.static java.lang.String
KEY_VALIDATION_REGEX
Key used to specify the validation regex as macro value.static java.lang.String
KEY_VALIDATION_VALUE
Key used to specify the validation value as macro value.protected java.util.Map<java.lang.String,java.lang.String>
m_additionalMacros
A map of additional values provided by the calling class.protected CmsObject
m_cms
The OpenCms user context to use for resolving macros.protected javax.servlet.jsp.PageContext
m_jspPageContext
The JSP's page context to use for resolving macros.protected boolean
m_keepEmptyMacros
Indicates if unresolved macros should be kept "as is" or replaced by an empty String.protected CmsMessages
m_messages
The messages resource bundle to resolve localized keys with.protected java.util.Map<java.lang.String,java.lang.String[]>
m_parameterMap
The request parameter map, used for better compatibility with multi part requests.protected java.lang.String
m_resourceName
The resource name to use for resolving macros.static java.util.List<java.lang.String>
VALUE_NAMES
The "magic" commands wrapped in a List.-
Fields inherited from interface org.opencms.util.I_CmsMacroResolver
MACRO_DELIMITER, MACRO_DELIMITER_OLD, MACRO_END, MACRO_END_OLD, MACRO_START, MACRO_START_OLD
-
-
Constructor Summary
Constructors Constructor Description CmsMacroResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDynamicMacro(java.lang.String name, org.apache.commons.collections.Factory factory)
Adds a macro whose value will be dynamically generated at macro resolution time.void
addMacro(java.lang.String key, java.lang.String value)
Adds a customized macro to this macro resolver.static void
copyAndResolveMacro(CmsObject cms, java.lang.String source, java.lang.String destination, java.util.Map<java.lang.String,java.lang.String> keyValue, boolean adjustLinks)
Copies resources, adjust internal links (if adjustLinks==true) and resolves macros (if keyValue map is set).static void
copyAndResolveMacro(CmsObject cms, java.lang.String source, java.lang.String destination, java.util.Map<java.lang.String,java.lang.String> keyValue, boolean adjustLinks, CmsResource.CmsResourceCopyMode copyMode)
Copies resources, adjust internal links (if adjustLinks==true) and resolves macros (if keyValue map is set).static void
copyAndResolveMacro(CmsObject cms, java.lang.String source, java.lang.String destination, java.util.Map<java.lang.String,java.lang.String> keyValue, boolean adjustLinks, CmsResource.CmsResourceCopyMode copyMode, I_CmsReport report)
Copies resources, adjust internal links (if adjustLinks==true) and resolves macros (if keyValue map is set).static java.lang.String
formatMacro(java.lang.String input)
Adds macro delimiters to the given input, for examplekey
becomes%(key)
.static java.util.Map<java.lang.String,java.lang.String[]>
getBundleMapFromResources(java.util.Properties resourceBundle, CmsResource descriptor, CmsObject clonedCms)
Reads a bundle (key, value, descriptor) from Descriptor Resource and property resource.java.lang.String
getMacroValue(java.lang.String macro)
Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.boolean
isKeepEmptyMacros()
Returnstrue
if macros that could not be resolved are kept "as is" in the input String,false
if they are replaced by an empty String.static boolean
isMacro(java.lang.String input)
Returnstrue
if the given input String if formatted like a macro, that is it starts with
and ends withI_CmsMacroResolver.MACRO_DELIMITER_OLD
+I_CmsMacroResolver.MACRO_START_OLD
.I_CmsMacroResolver.MACRO_END_OLD
static boolean
isMacro(java.lang.String input, java.lang.String macroName)
Returnstrue
if the given input String is a macro equal to the given macro name.static java.lang.String
localizedKeyMacro(java.lang.String keyName, java.lang.Object[] params)
Returns a macro for the given localization key with the given parameters.static CmsMacroResolver
newInstance()
Factory method to create a newCmsMacroResolver
instance.static I_CmsMacroResolver
newWorkplaceLocaleResolver(CmsObject cms)
Returns a new macro resolver that loads message keys from the workplace bundle in the user setting's language.java.lang.String
resolveMacros(java.lang.String input)
Resolves the macros in the given input.static java.lang.String
resolveMacros(java.lang.String input, CmsObject cms, CmsMessages messages)
Resolves the macros in the given input using the provided parameters.static java.lang.String
resolveMacros(java.lang.String input, I_CmsMacroResolver resolver)
Resolves macros in the provided input String using the given macro resolver.CmsMacroResolver
setAdditionalMacros(java.util.Map<java.lang.String,java.lang.String> additionalMacros)
Provides a set of additional macros to this macro resolver.CmsMacroResolver
setCmsObject(CmsObject cms)
Provides an OpenCms user context to this macro resolver, required to resolve certain macros.CmsMacroResolver
setJspPageContext(javax.servlet.jsp.PageContext jspPageContext)
Provides a JSP page context to this macro resolver, required to resolve certain macros.CmsMacroResolver
setKeepEmptyMacros(boolean keepEmptyMacros)
Controls of macros that can't be resolved are left unchanged in the input, or are replaced with an empty String.CmsMacroResolver
setMessages(CmsMessages messages)
Provides a set of
to this macro resolver, required to resolve localized macros.CmsMessages
void
setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> parameterMap)
Sets the parameter map.CmsMacroResolver
setResourceName(java.lang.String resourceName)
Provides a resource name to this macro resolver, required to resolve certain macros.static java.lang.String
stripMacro(java.lang.String input)
Strips the macro delimiters from the given input, for example%(key)
or${key}
becomeskey
.com.google.common.base.Function<java.lang.String,java.lang.String>
toFunction()
Returns a function which applies the macro substitution of this resolver to its argument.
-
-
-
Field Detail
-
KEY_ATTRIBUTE
public static final java.lang.String KEY_ATTRIBUTE
The prefix indicating that the key represents an OpenCms runtime attribute.- See Also:
- Constant Field Values
-
KEY_CONTEXT_PATH
public static final java.lang.String KEY_CONTEXT_PATH
Key used to specify the context path as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_ORGUNIT_DESCRIPTION
public static final java.lang.String KEY_CURRENT_ORGUNIT_DESCRIPTION
Key used to specify the description of the current organizational unit as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_ORGUNIT_FQN
public static final java.lang.String KEY_CURRENT_ORGUNIT_FQN
Key used to specify the full qualified name of the current organizational unit as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_TIME
public static final java.lang.String KEY_CURRENT_TIME
Key used to specify the current time as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_CITY
public static final java.lang.String KEY_CURRENT_USER_CITY
Key used to specify the city of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_COUNTRY
public static final java.lang.String KEY_CURRENT_USER_COUNTRY
Key used to specify the country of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_DISPLAYNAME
public static final java.lang.String KEY_CURRENT_USER_DISPLAYNAME
Key used to specify the display name of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_EMAIL
public static final java.lang.String KEY_CURRENT_USER_EMAIL
Key used to specify the email address of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_FIRSTNAME
public static final java.lang.String KEY_CURRENT_USER_FIRSTNAME
Key used to specify the first name of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_FULLNAME
public static final java.lang.String KEY_CURRENT_USER_FULLNAME
Key used to specify the full name of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_INSTITUTION
public static final java.lang.String KEY_CURRENT_USER_INSTITUTION
Key used to specify the institution of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_LASTLOGIN
public static final java.lang.String KEY_CURRENT_USER_LASTLOGIN
Key used to specify the last login date of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_LASTNAME
public static final java.lang.String KEY_CURRENT_USER_LASTNAME
Key used to specify the last name of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_NAME
public static final java.lang.String KEY_CURRENT_USER_NAME
Key used to specify the user name of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_STREET
public static final java.lang.String KEY_CURRENT_USER_STREET
Key used to specify the street of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_CURRENT_USER_ZIP
public static final java.lang.String KEY_CURRENT_USER_ZIP
Key used to specify the zip code of the current user as macro value.- See Also:
- Constant Field Values
-
KEY_LOCALIZED_PREFIX
public static final java.lang.String KEY_LOCALIZED_PREFIX
Key prefix used to specify the value of a localized key as macro value.- See Also:
- Constant Field Values
-
KEY_OPENCMS
public static final java.lang.String KEY_OPENCMS
Identifier for "magic" parameter names.- See Also:
- Constant Field Values
-
KEY_PAGE_CONTEXT
public static final java.lang.String KEY_PAGE_CONTEXT
The prefix indicating that the key represents a page context object.- See Also:
- Constant Field Values
-
KEY_PARAM
public static final java.lang.String KEY_PARAM
Prefix for getting parameters from the CmsParameterStore.- See Also:
- Constant Field Values
-
KEY_PROJECT_ID
public static final java.lang.String KEY_PROJECT_ID
Key used to specify the project id as macro value.- See Also:
- Constant Field Values
-
KEY_PROPERTY
public static final java.lang.String KEY_PROPERTY
The prefix indicating that the key represents a property to be read on the current request URI.- See Also:
- Constant Field Values
-
KEY_PROPERTY_ELEMENT
public static final java.lang.String KEY_PROPERTY_ELEMENT
The prefix indicating that the key represents a property to be read on the current element.- See Also:
- Constant Field Values
-
KEY_RANDOM_ID
public static final java.lang.String KEY_RANDOM_ID
Key used to specify a random id as macro value.- See Also:
- Constant Field Values
-
KEY_REQUEST_ENCODING
public static final java.lang.String KEY_REQUEST_ENCODING
Key used to specify the request encoding as macro value.- See Also:
- Constant Field Values
-
KEY_REQUEST_FOLDER
public static final java.lang.String KEY_REQUEST_FOLDER
Key used to specify the folder of the request URI as macro value.- See Also:
- Constant Field Values
-
KEY_REQUEST_LOCALE
public static final java.lang.String KEY_REQUEST_LOCALE
Key user to specify the request locale as macro value.- See Also:
- Constant Field Values
-
KEY_REQUEST_PARAM
public static final java.lang.String KEY_REQUEST_PARAM
The prefix indicating that the key represents a HTTP request parameter.- See Also:
- Constant Field Values
-
KEY_REQUEST_SITEROOT
public static final java.lang.String KEY_REQUEST_SITEROOT
Key used to specify the request site root as macro value.- See Also:
- Constant Field Values
-
KEY_REQUEST_URI
public static final java.lang.String KEY_REQUEST_URI
Key used to specify the request uri as macro value.- See Also:
- Constant Field Values
-
KEY_VALIDATION_PATH
public static final java.lang.String KEY_VALIDATION_PATH
Key used to specify the validation path as macro value.- See Also:
- Constant Field Values
-
KEY_VALIDATION_REGEX
public static final java.lang.String KEY_VALIDATION_REGEX
Key used to specify the validation regex as macro value.- See Also:
- Constant Field Values
-
KEY_VALIDATION_VALUE
public static final java.lang.String KEY_VALIDATION_VALUE
Key used to specify the validation value as macro value.- See Also:
- Constant Field Values
-
KEY_SITEMAP_ATTRIBUTE
public static final java.lang.String KEY_SITEMAP_ATTRIBUTE
Key for accessing sitemap attributes.- See Also:
- Constant Field Values
-
VALUE_NAMES
public static final java.util.List<java.lang.String> VALUE_NAMES
The "magic" commands wrapped in a List.
-
m_additionalMacros
protected java.util.Map<java.lang.String,java.lang.String> m_additionalMacros
A map of additional values provided by the calling class.
-
m_jspPageContext
protected javax.servlet.jsp.PageContext m_jspPageContext
The JSP's page context to use for resolving macros.
-
m_keepEmptyMacros
protected boolean m_keepEmptyMacros
Indicates if unresolved macros should be kept "as is" or replaced by an empty String.
-
m_messages
protected CmsMessages m_messages
The messages resource bundle to resolve localized keys with.
-
m_parameterMap
protected java.util.Map<java.lang.String,java.lang.String[]> m_parameterMap
The request parameter map, used for better compatibility with multi part requests.
-
m_resourceName
protected java.lang.String m_resourceName
The resource name to use for resolving macros.
-
-
Constructor Detail
-
CmsMacroResolver
public CmsMacroResolver()
-
-
Method Detail
-
copyAndResolveMacro
public static void copyAndResolveMacro(CmsObject cms, java.lang.String source, java.lang.String destination, java.util.Map<java.lang.String,java.lang.String> keyValue, boolean adjustLinks) throws CmsException
Copies resources, adjust internal links (if adjustLinks==true) and resolves macros (if keyValue map is set).- Parameters:
cms
- CmsObjectsource
- pathdestination
- pathkeyValue
- map to be used for macro resolveradjustLinks
- boolean, true means internal links get adjusted.- Throws:
CmsException
- exception
-
copyAndResolveMacro
public static void copyAndResolveMacro(CmsObject cms, java.lang.String source, java.lang.String destination, java.util.Map<java.lang.String,java.lang.String> keyValue, boolean adjustLinks, CmsResource.CmsResourceCopyMode copyMode) throws CmsException
Copies resources, adjust internal links (if adjustLinks==true) and resolves macros (if keyValue map is set).- Parameters:
cms
- CmsObjectsource
- pathdestination
- pathkeyValue
- map to be used for macro resolveradjustLinks
- boolean, true means internal links get adjusted.copyMode
- copyMode- Throws:
CmsException
- exception
-
copyAndResolveMacro
public static void copyAndResolveMacro(CmsObject cms, java.lang.String source, java.lang.String destination, java.util.Map<java.lang.String,java.lang.String> keyValue, boolean adjustLinks, CmsResource.CmsResourceCopyMode copyMode, I_CmsReport report) throws CmsException
Copies resources, adjust internal links (if adjustLinks==true) and resolves macros (if keyValue map is set).- Parameters:
cms
- CmsObjectsource
- pathdestination
- pathkeyValue
- map to be used for macro resolveradjustLinks
- boolean, true means internal links get adjusted.copyMode
- copy Modereport
- report to write logs to- Throws:
CmsException
- exception
-
formatMacro
public static java.lang.String formatMacro(java.lang.String input)
Adds macro delimiters to the given input, for examplekey
becomes%(key)
.- Parameters:
input
- the input to format as a macro- Returns:
- the input formatted as a macro
-
getBundleMapFromResources
public static java.util.Map<java.lang.String,java.lang.String[]> getBundleMapFromResources(java.util.Properties resourceBundle, CmsResource descriptor, CmsObject clonedCms) throws CmsXmlException, CmsException
Reads a bundle (key, value, descriptor) from Descriptor Resource and property resource.- Parameters:
resourceBundle
- property resourcedescriptor
- resourceclonedCms
- cms instance- Returns:
- Map
- Throws:
CmsXmlException
- exceptionCmsException
- exception
-
isMacro
public static boolean isMacro(java.lang.String input)
Returnstrue
if the given input String if formatted like a macro, that is it starts with
and ends withI_CmsMacroResolver.MACRO_DELIMITER_OLD
+I_CmsMacroResolver.MACRO_START_OLD
.I_CmsMacroResolver.MACRO_END_OLD
- Parameters:
input
- the input to check for a macro- Returns:
true
if the given input String if formatted like a macro
-
isMacro
public static boolean isMacro(java.lang.String input, java.lang.String macroName)
Returnstrue
if the given input String is a macro equal to the given macro name.- Parameters:
input
- the input to check for a macromacroName
- the macro name to check for- Returns:
true
if the given input String is a macro equal to the given macro name
-
localizedKeyMacro
public static java.lang.String localizedKeyMacro(java.lang.String keyName, java.lang.Object[] params)
Returns a macro for the given localization key with the given parameters.- Parameters:
keyName
- the name of the localized keyparams
- the optional parameter array- Returns:
- a macro for the given localization key with the given parameters
-
newInstance
public static CmsMacroResolver newInstance()
Factory method to create a newCmsMacroResolver
instance.- Returns:
- a new instance of a
CmsMacroResolver
-
newWorkplaceLocaleResolver
public static I_CmsMacroResolver newWorkplaceLocaleResolver(CmsObject cms)
Returns a new macro resolver that loads message keys from the workplace bundle in the user setting's language.- Parameters:
cms
- the CmsObject.- Returns:
- a new macro resolver with messages from the workplace bundle in the current users locale.
-
resolveMacros
public static java.lang.String resolveMacros(java.lang.String input, CmsObject cms, CmsMessages messages)
Resolves the macros in the given input using the provided parameters.A macro in the form
%(key)
or${key}
in the content is replaced with it's assigned value returned by the
method of the givenI_CmsMacroResolver.getMacroValue(String)
instance.I_CmsMacroResolver
If a macro is found that can not be mapped to a value by the given macro resolver, it is left untouched in the input.
- Parameters:
input
- the input in which to resolve the macroscms
- the OpenCms user context to use when resolving macrosmessages
- the message resource bundle to use when resolving macros- Returns:
- the input with the macros resolved
-
resolveMacros
public static java.lang.String resolveMacros(java.lang.String input, I_CmsMacroResolver resolver)
Resolves macros in the provided input String using the given macro resolver.A macro in the form
%(key)
or${key}
in the content is replaced with it's assigned value returned by the
method of the givenI_CmsMacroResolver.getMacroValue(String)
instance.I_CmsMacroResolver
If a macro is found that can not be mapped to a value by the given macro resolver,
controls if the macro is replaced by an empty String, or is left untouched in the input.I_CmsMacroResolver.isKeepEmptyMacros()
- Parameters:
input
- the input in which to resolve the macrosresolver
- the macro resolver to use- Returns:
- the input with all macros resolved
-
stripMacro
public static java.lang.String stripMacro(java.lang.String input)
Strips the macro delimiters from the given input, for example%(key)
or${key}
becomeskey
.In case the input is not a macro,
null
is returned.- Parameters:
input
- the input to strip- Returns:
- the macro stripped from the input, or
null
-
addDynamicMacro
public void addDynamicMacro(java.lang.String name, org.apache.commons.collections.Factory factory)
Adds a macro whose value will be dynamically generated at macro resolution time.The value will be generated for each occurence of the macro in a string.
- Parameters:
name
- the name of the macrofactory
- the macro value generator
-
addMacro
public void addMacro(java.lang.String key, java.lang.String value)
Adds a customized macro to this macro resolver.- Parameters:
key
- the macro to addvalue
- the value to return if the macro is encountered
-
getMacroValue
public java.lang.String getMacroValue(java.lang.String macro)
Description copied from interface:I_CmsMacroResolver
Resolves a single macro to the macro value, returnsnull
if the macro could not be resolved.- Specified by:
getMacroValue
in interfaceI_CmsMacroResolver
- Parameters:
macro
- the macro to resolve- Returns:
- the resolved macro or
null
if the macro could not be resolved - See Also:
I_CmsMacroResolver.getMacroValue(java.lang.String)
-
isKeepEmptyMacros
public boolean isKeepEmptyMacros()
Description copied from interface:I_CmsMacroResolver
Returnstrue
if macros that could not be resolved are kept "as is" in the input String,false
if they are replaced by an empty String.- Specified by:
isKeepEmptyMacros
in interfaceI_CmsMacroResolver
- Returns:
true
if macros that could not be resolved are kept "as is" in the input String,false
if they are replaced by an empty String- See Also:
I_CmsMacroResolver.isKeepEmptyMacros()
-
resolveMacros
public java.lang.String resolveMacros(java.lang.String input)
Resolves the macros in the given input.Calls
until no more macros can be resolved in the input. This way "nested" macros in the input are resolved as well.resolveMacros(String)
- Specified by:
resolveMacros
in interfaceI_CmsMacroResolver
- Parameters:
input
- the input to resolve the macros in- Returns:
- the input with all macros resolved
- See Also:
I_CmsMacroResolver.resolveMacros(java.lang.String)
-
setAdditionalMacros
public CmsMacroResolver setAdditionalMacros(java.util.Map<java.lang.String,java.lang.String> additionalMacros)
Provides a set of additional macros to this macro resolver.Macros added with
addMacro(String, String)
are added to the same set- Parameters:
additionalMacros
- the additional macros to add- Returns:
- this instance of the macro resolver
-
setCmsObject
public CmsMacroResolver setCmsObject(CmsObject cms)
Provides an OpenCms user context to this macro resolver, required to resolve certain macros.- Parameters:
cms
- the OpenCms user context- Returns:
- this instance of the macro resolver
-
setJspPageContext
public CmsMacroResolver setJspPageContext(javax.servlet.jsp.PageContext jspPageContext)
Provides a JSP page context to this macro resolver, required to resolve certain macros.- Parameters:
jspPageContext
- the JSP page context to use- Returns:
- this instance of the macro resolver
-
setKeepEmptyMacros
public CmsMacroResolver setKeepEmptyMacros(boolean keepEmptyMacros)
Controls of macros that can't be resolved are left unchanged in the input, or are replaced with an empty String.- Parameters:
keepEmptyMacros
- the replacement flag to use- Returns:
- this instance of the macro resolver
- See Also:
isKeepEmptyMacros()
-
setMessages
public CmsMacroResolver setMessages(CmsMessages messages)
Provides a set of
to this macro resolver, required to resolve localized macros.CmsMessages
- Parameters:
messages
- the message resource bundle to use- Returns:
- this instance of the macro resolver
-
setParameterMap
public void setParameterMap(java.util.Map<java.lang.String,java.lang.String[]> parameterMap)
Sets the parameter map.- Parameters:
parameterMap
- the parameter map to set
-
setResourceName
public CmsMacroResolver setResourceName(java.lang.String resourceName)
Provides a resource name to this macro resolver, required to resolve certain macros.- Parameters:
resourceName
- the resource name to use- Returns:
- this instance of the macro resolver
-
toFunction
public com.google.common.base.Function<java.lang.String,java.lang.String> toFunction()
Returns a function which applies the macro substitution of this resolver to its argument.- Returns:
- a function performing string substitution with this resolver
-
-