Package org.opencms.xml.containerpage
Class CmsFormatterConfiguration
java.lang.Object
org.opencms.xml.containerpage.CmsFormatterConfiguration
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class is used to sort lists of formatter beans in order of importance.static class
Predicate which checks whether the given formatter is a detail formatter.static class
Predicate which checks whether the given formatter is a display formatter.static class
Predicate to check whether the formatter is from a schema. -
Field Summary
Modifier and TypeFieldDescriptionstatic final CmsFormatterConfiguration
The empty formatter configuration.static final org.apache.commons.logging.Log
The log instance for this class.static final int
The container width to match all width configured formatters. -
Method Summary
Modifier and TypeMethodDescriptionstatic CmsFormatterConfiguration
create
(CmsObject cms, List<I_CmsFormatterBean> formatters) Returns the formatter configuration for the current project based on the given list of formatters.Gets a list of all defined formatters.getAllMatchingFormatters
(String containerTypes, int containerWidth) Gets the formatters which are available for the given container type and width.getDefaultFormatter
(String containerTypes, int containerWidth) Selects the best matching formatter for the provided type and width from this configuration.getDefaultSchemaFormatter
(String containerTypes, int containerWidth) Selects the best matching schema formatter for the provided type and width from this configuration.getDetailFormatter
(String types, int containerWidth) Gets the detail formatter to use for the given type and container width.Gets all detail formatters.Returns the display formatter for this type.Returns the available display formatters.getFormatterSelection
(String containerTypes, int containerWidth) Returns the formatters available for selection for the given container type and width.getFormatterSelectionByKeyOrId
(String containerTypes, int containerWidth) Gets the list of formatters for the given key or id (also supports schema_formatter ids).Returns the formatter from this configuration that is to be used for the preview in the ADE gallery GUI, ornull
if there is no preview formatter configured.boolean
hasFormatter
(String containerTypes, int containerWidth) Returns the providedtrue
in case this configuration has a formatter for the given type / width parameters.boolean
Returnstrue
in case there is at least one usable formatter configured in this configuration.static void
initialize
(CmsObject cms) Initialize the formatter configuration.boolean
isSearchContent
(CmsUUID formatterStructureId) Returnstrue
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.static boolean
matchFormatter
(I_CmsFormatterBean formatter, String types, int width) Checks whether the given formatter bean matches the container types, width and nested flag.static boolean
matchFormatter
(I_CmsFormatterBean formatter, Set<String> types, int width) Checks whether the given formatter bean matches the container types, width and nested flag.
-
Field Details
-
EMPTY_CONFIGURATION
The empty formatter configuration. -
LOG
The log instance for this class. -
MATCH_ALL_CONTAINER_WIDTH
The container width to match all width configured formatters.- See Also:
-
-
Method Details
-
create
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 fromformatters
- the list of configured formatters- Returns:
- the formatter configuration for the current project based on the given list of formatters
-
initialize
Initialize the formatter configuration.- Parameters:
cms
- an initialized admin OpenCms user context- Throws:
CmsException
- in case the initialization fails
-
matchFormatter
Checks whether the given formatter bean matches the container types, width and nested flag.- Parameters:
formatter
- the formatter beantypes
- the container typeswidth
- the container width- Returns:
true
in case the formatter matches
-
matchFormatter
Checks whether the given formatter bean matches the container types, width and nested flag.- Parameters:
formatter
- the formatter beantypes
- the container typeswidth
- the container width- Returns:
true
in case the formatter matches
-
getAllFormatters
Gets a list of all defined formatters.- Returns:
- the list of all formatters
-
getAllMatchingFormatters
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
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
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
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
-
getDetailFormatters
Gets all detail formatters.- Returns:
- the detail formatters
-
getDisplayFormatter
Returns the display formatter for this type.- Returns:
- the display formatter
-
getDisplayFormatters
Returns the available display formatters.- Returns:
- the display formatters
-
getFormatterSelection
public Map<String,I_CmsFormatterBean> getFormatterSelection(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
-
getFormatterSelectionByKeyOrId
public Map<String,I_CmsFormatterBean> getFormatterSelectionByKeyOrId(String containerTypes, int containerWidth) -
getFormattersForKey
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
Returns the formatter from this configuration that is to be used for the preview in the ADE gallery GUI, ornull
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
Returns the providedtrue
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
Returnstrue
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
Returnstrue
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
-