Package org.opencms.xml.containerpage
Class CmsFormatterConfiguration
- java.lang.Object
-
- org.opencms.xml.containerpage.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsFormatterConfiguration.FormatterComparator
This class is used to sort lists of formatter beans in order of importance.static class
CmsFormatterConfiguration.IsDetail
Predicate which checks whether the given formatter is a detail formatter.static class
CmsFormatterConfiguration.IsDisplay
Predicate which checks whether the given formatter is a display formatter.static class
CmsFormatterConfiguration.IsSchemaFormatter
Predicate to check whether the formatter is from a schema.
-
Field Summary
Fields Modifier and Type Field Description static CmsFormatterConfiguration
EMPTY_CONFIGURATION
The empty formatter configuration.static org.apache.commons.logging.Log
LOG
The log instance for this class.static int
MATCH_ALL_CONTAINER_WIDTH
The container width to match all width configured formatters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.util.List<I_CmsFormatterBean>
getAllFormatters()
Gets a list of all defined formatters.java.util.List<I_CmsFormatterBean>
getAllMatchingFormatters(java.lang.String containerTypes, int containerWidth)
Gets the formatters which are available for the given container type and width.I_CmsFormatterBean
getDefaultFormatter(java.lang.String containerTypes, int containerWidth)
Selects the best matching formatter for the provided type and width from this configuration.I_CmsFormatterBean
getDefaultSchemaFormatter(java.lang.String containerTypes, int containerWidth)
Selects the best matching schema formatter for the provided type and width from this configuration.I_CmsFormatterBean
getDetailFormatter(java.lang.String types, int containerWidth)
Gets the detail formatter to use for the given type and container width.java.util.Collection<I_CmsFormatterBean>
getDetailFormatters()
Gets all detail formatters.I_CmsFormatterBean
getDisplayFormatter()
Returns the display formatter for this type.java.util.List<I_CmsFormatterBean>
getDisplayFormatters()
Returns the available display formatters.java.util.Map<java.lang.String,I_CmsFormatterBean>
getFormatterSelection(java.lang.String containerTypes, int containerWidth)
Returns the formatters available for selection for the given container type and width.java.util.Map<java.lang.String,I_CmsFormatterBean>
getFormatterSelectionByKeyOrId(java.lang.String containerTypes, int containerWidth)
java.util.List<I_CmsFormatterBean>
getFormattersForKey(java.lang.String key)
Gets the list of formatters for the given key or id (also supports schema_formatter ids).I_CmsFormatterBean
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.boolean
hasFormatter(java.lang.String containerTypes, int containerWidth)
Returns the providedtrue
in case this configuration has a formatter for the given type / width parameters.boolean
hasFormatters()
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, java.lang.String types, int width)
Checks whether the given formatter bean matches the container types, width and nested flag.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.
-
-
-
Field Detail
-
EMPTY_CONFIGURATION
public static final CmsFormatterConfiguration EMPTY_CONFIGURATION
The empty formatter configuration.
-
LOG
public static final org.apache.commons.logging.Log LOG
The log instance for this class.
-
MATCH_ALL_CONTAINER_WIDTH
public static final int MATCH_ALL_CONTAINER_WIDTH
The container width to match all width configured formatters.- See Also:
- Constant Field Values
-
-
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 fromformatters
- 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 beantypes
- the container typeswidth
- 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 beantypes
- the container typeswidth
- the container width- Returns:
true
in case the formatter matches
-
getAllFormatters
public java.util.List<I_CmsFormatterBean> getAllFormatters()
Gets a list of all defined formatters.- Returns:
- the list of all formatters
-
getAllMatchingFormatters
public java.util.List<I_CmsFormatterBean> getAllMatchingFormatters(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
-
getDetailFormatters
public java.util.Collection<I_CmsFormatterBean> getDetailFormatters()
Gets all detail formatters.- Returns:
- the detail formatters
-
getDisplayFormatter
public I_CmsFormatterBean getDisplayFormatter()
Returns the display formatter for this type.- Returns:
- the display formatter
-
getDisplayFormatters
public java.util.List<I_CmsFormatterBean> getDisplayFormatters()
Returns the available display formatters.- Returns:
- the display formatters
-
getFormatterSelection
public java.util.Map<java.lang.String,I_CmsFormatterBean> getFormatterSelection(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
-
getFormatterSelectionByKeyOrId
public java.util.Map<java.lang.String,I_CmsFormatterBean> getFormatterSelectionByKeyOrId(java.lang.String containerTypes, int containerWidth)
-
getFormattersForKey
public java.util.List<I_CmsFormatterBean> getFormattersForKey(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, 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
public boolean hasFormatter(java.lang.String containerTypes, int containerWidth)
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
public boolean 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
public 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.- 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
-
-