Class CmsFormatterConfiguration


  • public final class CmsFormatterConfiguration
    extends java.lang.Object
    Represents a formatter configuration.

    A formatter configuration can be either defined in the XML schema XSD of a XML content, or in a special sitemap configuration file.

    Since:
    8.0.0
    • Method Detail

      • create

        public static CmsFormatterConfiguration create​(CmsObject cms,
                                                       java.util.List<I_CmsFormatterBean> formatters)
        Returns the formatter configuration for the current project based on the given list of formatters.

        Parameters:
        cms - the current users OpenCms context, required to know which project to read the JSP from
        formatters - the list of configured formatters
        Returns:
        the formatter configuration for the current project based on the given list of formatters
      • initialize

        public static void initialize​(CmsObject cms)
                               throws CmsException
        Initialize the formatter configuration.

        Parameters:
        cms - an initialized admin OpenCms user context
        Throws:
        CmsException - in case the initialization fails
      • matchFormatter

        public static boolean matchFormatter​(I_CmsFormatterBean formatter,
                                             java.util.Set<java.lang.String> types,
                                             int width)
        Checks whether the given formatter bean matches the container types, width and nested flag.

        Parameters:
        formatter - the formatter bean
        types - the container types
        width - the container width
        Returns:
        true in case the formatter matches
      • matchFormatter

        public static boolean matchFormatter​(I_CmsFormatterBean formatter,
                                             java.lang.String types,
                                             int width)
        Checks whether the given formatter bean matches the container types, width and nested flag.

        Parameters:
        formatter - the formatter bean
        types - the container types
        width - the container width
        Returns:
        true in case the formatter matches
      • getAllMatchingFormatters

        public java.util.List<I_CmsFormatterBeangetAllMatchingFormatters​(java.lang.String containerTypes,
                                                                           int containerWidth)
        Gets the formatters which are available for the given container type and width.

        Parameters:
        containerTypes - the container types (comma separated)
        containerWidth - the container width
        Returns:
        the list of available formatters
      • getDefaultFormatter

        public I_CmsFormatterBean getDefaultFormatter​(java.lang.String containerTypes,
                                                      int containerWidth)
        Selects the best matching formatter for the provided type and width from this configuration.

        This method first tries to find the formatter for the provided container type. If this fails, it returns the width based formatter that matched the container width.

        Parameters:
        containerTypes - the container types (comma separated)
        containerWidth - the container width
        Returns:
        the matching formatter, or null if none was found
      • getDefaultSchemaFormatter

        public I_CmsFormatterBean getDefaultSchemaFormatter​(java.lang.String containerTypes,
                                                            int containerWidth)
        Selects the best matching schema formatter for the provided type and width from this configuration.

        Parameters:
        containerTypes - the container types (comma separated)
        containerWidth - the container width
        Returns:
        the matching formatter, or null if none was found
      • getDetailFormatter

        public I_CmsFormatterBean getDetailFormatter​(java.lang.String types,
                                                     int containerWidth)
        Gets the detail formatter to use for the given type and container width.

        Parameters:
        types - the container types (comma separated)
        containerWidth - the container width
        Returns:
        the detail formatter to use
      • getFormatterSelection

        public java.util.Map<java.lang.String,​I_CmsFormatterBeangetFormatterSelection​(java.lang.String containerTypes,
                                                                                              int containerWidth)
        Returns the formatters available for selection for the given container type and width.

        Parameters:
        containerTypes - the container types (comma separated)
        containerWidth - the container width
        Returns:
        the list of available formatters
      • getFormattersForKey

        public java.util.List<I_CmsFormatterBeangetFormattersForKey​(java.lang.String key)
        Gets the list of formatters for the given key or id (also supports schema_formatter ids).
        Parameters:
        key - a formatter key or id
        Returns:
        the list of formatters for the given key
      • getPreviewFormatter

        public I_CmsFormatterBean getPreviewFormatter()
        Returns the formatter from this configuration that is to be used for the preview in the ADE gallery GUI, or null if there is no preview formatter configured.

        Returns:
        the formatter from this configuration that is to be used for the preview in the ADE gallery GUI, or null if there is no preview formatter configured
      • hasFormatter

        public boolean hasFormatter​(java.lang.String containerTypes,
                                    int containerWidth)
        Returns the provided true in case this configuration has a formatter for the given type / width parameters.

        Parameters:
        containerTypes - the container types (comma separated)
        containerWidth - the container width
        Returns:
        the provided true in case this configuration has a formatter for the given type / width parameters.
      • hasFormatters

        public boolean hasFormatters()
        Returns true in case there is at least one usable formatter configured in this configuration.

        Returns:
        true in case there is at least one usable formatter configured in this configuration
      • isSearchContent

        public boolean isSearchContent​(CmsUUID formatterStructureId)
        Returns true in case this configuration contains a formatter with the provided structure id that has been configured for including the formatted content in the online search.

        Parameters:
        formatterStructureId - the formatter structure id
        Returns:
        true in case this configuration contains a formatter with the provided structure id that has been configured for including the formatted content in the online search