Class CmsFormatterIndex

java.lang.Object
org.opencms.ade.configuration.formatters.CmsFormatterIndex

public class CmsFormatterIndex extends Object
Helper class for keeping track of which keys map to which formatters, and which formatters are active, when evaluating the sitemap configuration.

Formatters can now have multiple keys, which makes overriding them in more specific sitemap/master configurations more complex. Let X and Y be active sitemap/master configurations for the currently requested page, with Y being more specific than X. If X adds a formatter F1 with keys A, B, C and Y adds a different formatter F2 with an overlapping set of keys C, D, E, then as a result, formatter F1 should be disabled and formatter F2 should be used for the keys A, B, C, D, E (even though it does not have A and B as configured keys).

You use an instance of this class by adding/removing formatters in the order these operations are defined by the sitemap configuration and finally calling the getFormattersWithAdditionalKeys() method at the end, which augments the formatters it returns by adding the appropriate keys.

  • Constructor Details

  • Method Details

    • addFormatter

      public void addFormatter(I_CmsFormatterBean formatter)
      Adds the given formatter.

      If there are any direct or indirect overlaps with the keys of already added formatters, these formatters will be removed and their keys mapped to the new formatter.

      Parameters:
      formatter - the formatter to add
    • getFormattersWithAdditionalKeys

      Gets the final map of active formatters, with their formatter keys replaced by the total set of keys under which they should be available.
      Returns:
      the map of formatters by id
    • remove

      public void remove(CmsUUID id)
      Removes the formatter with the given id.
      Parameters:
      id - the formatter id
    • removeIf

      public void removeIf(Predicate<I_CmsFormatterBean> condition)
      Removes all formatters matching the given predicate
      Parameters:
      condition - the condition to use for checking which formatters should be removed