Class ContentTypesDisplayMapper

  • All Implemented Interfaces:
    DisplayMapper

    public class ContentTypesDisplayMapper
    extends Object
    implements DisplayMapper
    Map Confluence content types to display information such as a CSS type or an Icon URL. When possible, use ContentUiSupport instead. This returns CSS classes of the form "content-type-page" etc. which are not sprite based, where ContentUiSupport would return icon-page, which are sprite based and are the preferred CSS styling of icons in Confluence.
    • Method Detail

      • getClassName

        public String getClassName​(SearchResult result)
        Get the CSS class name for the supplied SearchResult. If the class cannot be determined from the result then the default class will be returned.
        Parameters:
        result - the SearchResult that a CSS class is required for.
        Returns:
        the CSS class name for the given SearchResult.
      • getClassName

        public String getClassName​(SearchResult result)
        Get the CSS class name for the supplied SearchResult. If the class cannot be determined from the result then the default class will be returned.
        Specified by:
        getClassName in interface DisplayMapper
        Parameters:
        result - the SearchResult that a CSS class is required for.
        Returns:
        the CSS class name for the given SearchResult.
      • getIconForAttachment

        public static String getIconForAttachment​(String contentType,
                                                  String fileName)
        Decide the icon for an attachment based firstly on it's contentType. If it has no content type then the extension of it's filename will be used.
        Parameters:
        contentType -
        fileName -
        Returns:
        the icon to be used for the attachment or the default icon if there is no specific one
      • getIconUrlForUsername

        @Deprecated
        public String getIconUrlForUsername​(String username)
        Parameters:
        username - the username to find an icon for.
        Returns:
        the URL (relative to the application's base URI excluding context path) for the icon for this username. If the user has no avatar then the URL of a default will be returned.
      • getIconUriReferenceForUsername

        public String getIconUriReferenceForUsername​(String username)
        Parameters:
        username - the username to find an icon for.
        Returns:
        a "URI reference" (a URL that is either relative to the application's base URI including context path or an absolute URL) for the icon for this username. If the user has no avatar then the URL of a default will be returned.