Package org.opencms.jsp.util
Class CmsKeyDummyMacroResolver
java.lang.Object
org.opencms.util.CmsMacroResolver
org.opencms.jsp.util.CmsKeyDummyMacroResolver
- All Implemented Interfaces:
I_CmsMacroResolver
Macro resolver used to temporarily replace localization message macros with random UUIDs and then replace the UUIDs
with the original key after all other macro processing has happened.
We need this because we want to preserve the message key, but evaluate macros they may be nested in.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternPattern to match message key macros.static final PatternPattern to match message key macros.Fields inherited from class org.opencms.util.CmsMacroResolver
KEY_ATTRIBUTE, KEY_CONTEXT_PATH, KEY_CURRENT_ORGUNIT_DESCRIPTION, KEY_CURRENT_ORGUNIT_FQN, KEY_CURRENT_TIME, KEY_CURRENT_USER_CITY, KEY_CURRENT_USER_COUNTRY, KEY_CURRENT_USER_DISPLAYNAME, KEY_CURRENT_USER_EMAIL, KEY_CURRENT_USER_FIRSTNAME, KEY_CURRENT_USER_FULLNAME, KEY_CURRENT_USER_INSTITUTION, KEY_CURRENT_USER_LASTLOGIN, KEY_CURRENT_USER_LASTNAME, KEY_CURRENT_USER_NAME, KEY_CURRENT_USER_STREET, KEY_CURRENT_USER_ZIP, KEY_LOCALIZED_PREFIX, KEY_OPENCMS, KEY_PAGE_CONTEXT, KEY_PARAM, KEY_PROJECT_ID, KEY_PROPERTY, KEY_PROPERTY_ELEMENT, KEY_RANDOM_ID, KEY_REQUEST_ENCODING, KEY_REQUEST_FOLDER, KEY_REQUEST_LOCALE, KEY_REQUEST_PARAM, KEY_REQUEST_SITEROOT, KEY_REQUEST_URI, KEY_SITEMAP_ATTRIBUTE, KEY_VALIDATION_PATH, KEY_VALIDATION_REGEX, KEY_VALIDATION_VALUE, m_additionalMacros, m_cms, m_jspPageContext, m_keepEmptyMacros, m_messages, m_parameterMap, m_resourceName, VALUE_NAMESFields 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic StringExtracts the message from a string of the form %(key.{message}), or returns null if the input string does not have this form.static StringgetKey(String s, CmsMacroResolver delegate) Gets the localization key name of a (potentially nested) key macro in a base string.getKeys(String s, CmsMacroResolver delegate) Gets the localization keys from a string consisting solely of localization key macros (only whitespace is allowed between them).getMacroValue(String macro) Resolves a single macro to the macro value, returnsnullif the macro could not be resolved.Parses a string that is a sequence of %(key....) macros and extracts the corresponding keys.resolveMacros(String input) Resolves the macros in the given input.Methods inherited from class org.opencms.util.CmsMacroResolver
addDynamicMacro, addMacro, copyAndResolveMacro, copyAndResolveMacro, copyAndResolveMacro, formatMacro, getBundleMapFromResources, isKeepEmptyMacros, isMacro, isMacro, localizedKeyMacro, newInstance, newWorkplaceLocaleResolver, resolveMacros, resolveMacros, setAdditionalMacros, setCmsObject, setJspPageContext, setKeepEmptyMacros, setMessages, setParameterMap, setResourceName, stripMacro, toFunction
-
Field Details
-
PATTERN_MESSAGE
Pattern to match message key macros. -
PATTERN_MESSAGE_UNANCHORED
Pattern to match message key macros.
-
-
Constructor Details
-
CmsKeyDummyMacroResolver
Creates a new instance- Parameters:
delegate- the macro resolver to delegate to
-
-
Method Details
-
getKey
Extracts the message from a string of the form %(key.{message}), or returns null if the input string does not have this form.- Parameters:
s- the input string- Returns:
- the key the extracted message key
-
getKey
Gets the localization key name of a (potentially nested) key macro in a base string.- Parameters:
s- the base stringdelegate- the macro resolver used to resolve macros which the key macro may be nested in- Returns:
- the localization key
-
getKeys
Gets the localization keys from a string consisting solely of localization key macros (only whitespace is allowed between them).- Parameters:
s- the string to extract the localization keys fromdelegate- the macro resolver to use for non-localization macros
-
parseKeys
Parses a string that is a sequence of %(key....) macros and extracts the corresponding keys.There may be additional whitespace before or after the macros, but nothing else. If anything else is found, null will be returned.
- Parameters:
s- the input string- Returns:
- the sequence of extracted keys
-
getMacroValue
Description copied from interface:I_CmsMacroResolverResolves a single macro to the macro value, returnsnullif the macro could not be resolved.- Specified by:
getMacroValuein interfaceI_CmsMacroResolver- Overrides:
getMacroValuein classCmsMacroResolver- Parameters:
macro- the macro to resolve- Returns:
- the resolved macro or
nullif the macro could not be resolved - See Also:
-
resolveMacros
Description copied from class:CmsMacroResolverResolves 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.CmsMacroResolver.resolveMacros(String)- Specified by:
resolveMacrosin interfaceI_CmsMacroResolver- Overrides:
resolveMacrosin classCmsMacroResolver- Parameters:
input- the input to resolve the macros in- Returns:
- the input with all macros resolved
- See Also:
-