Class CmsSettingTranslator

java.lang.Object
org.opencms.ade.containerpage.CmsSettingTranslator

public class CmsSettingTranslator extends 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 Details

  • Method Details

    • parseSettingTranslationMap

      public static Map<String,String> parseSettingTranslationMap(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

      Translates the settings for the given formatter in the context of the current sitemap.
      Parameters:
      formatter - the formatter
      settings - the settings to translate
      Returns:
      the map of translated settings
    • getSettingsForFormatter

      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