Package org.opencms.ade.containerpage
Class CmsSettingTranslator
- java.lang.Object
-
- org.opencms.ade.containerpage.CmsSettingTranslator
-
public class CmsSettingTranslator extends java.lang.Object
Helper class for transforming a map of element settings based on the aliases/replacement rules in the setting definitions for a given formatter.The translation method creates a new setting map according to the following rules:
- If the setting map contains an entry whose key is the alias of a setting definition, the key is changed to the current setting name.
- If the setting map contains an entry whose key has the form ${formatterKey}_${settingAlias}, where ${settingAlias} is an alias of a setting with name ${newSetting} for the formatter with key ${formatterKey}, the map key is replaced by ${formatterKey}_${newSetting} (these are nested settings used for list configuration elements)
- If the setting definition for an entry contains a value translation of the form 'newval_1:oldval_1|newval_2:oldval_2|....', and the value of the entry is one of the oldval_i values in that list, the value will be replaced by the corresponding newval_i value.
- If none of these are the case, the setting entry will be copied as-is.
A single setting translator instance is used for processing the element settings of a single container page while it is being unmarshalled.
-
-
Constructor Summary
Constructors Constructor Description CmsSettingTranslator(CmsADEConfigData config)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,CmsXmlContentProperty>
getSettingsForFormatter(java.lang.String formatterKey)
Helper method to get the map of settings for a given formatter key, where setting name aliases can also be used as keys.static java.util.Map<java.lang.String,java.lang.String>
parseSettingTranslationMap(java.lang.String translation)
Parses a setting value translation of the form newval1:oldval1|newval2:oldval2|....java.util.Map<java.lang.String,java.lang.String>
translateSettings(I_CmsFormatterBean formatter, java.util.Map<java.lang.String,java.lang.String> settings)
Translates the settings for the given formatter in the context of the current sitemap.
-
-
-
Constructor Detail
-
CmsSettingTranslator
public CmsSettingTranslator(CmsADEConfigData config)
Creates a new instance.- Parameters:
config
- the active sitemap configuration
-
-
Method Detail
-
parseSettingTranslationMap
public static java.util.Map<java.lang.String,java.lang.String> parseSettingTranslationMap(java.lang.String translation)
Parses a setting value translation of the form newval1:oldval1|newval2:oldval2|.... .- Parameters:
translation
- the setting value translation- Returns:
- the setting translation map, with the old values as keys and the corresponding new values as values
-
translateSettings
public java.util.Map<java.lang.String,java.lang.String> translateSettings(I_CmsFormatterBean formatter, java.util.Map<java.lang.String,java.lang.String> settings)
Translates the settings for the given formatter in the context of the current sitemap.- Parameters:
formatter
- the formattersettings
- the settings to translate- Returns:
- the map of translated settings
-
getSettingsForFormatter
protected java.util.Map<java.lang.String,CmsXmlContentProperty> getSettingsForFormatter(java.lang.String formatterKey)
Helper method to get the map of settings for a given formatter key, where setting name aliases can also be used as keys.- Parameters:
formatterKey
- the key of a formatter- Returns:
- the map of settings for the formatter key
-
-