Class WysiwygContent

  • All Implemented Interfaces:
    Serializable, ContributionContent<String>

    public class WysiwygContent
    extends Object
    implements ContributionContent<String>
    A WYSIWYG content is a rich text (text with styles with graphics and images) that is produced by an editor in a form closely resembling its appearance when printed or displayed.

    Usually a WYSIWYG content doesn't require to be compiled or transpiled into another form dedicated to the rendering. The WYSIWYG content is enough by itself as it contains all the information to be displayed.

    Author:
    mmoquillon
    See Also:
    Serialized Form
    • Constructor Detail

      • WysiwygContent

        public WysiwygContent​(LocalizedContribution contribution,
                              String richText)
        Constructs a new WYSIWYG content for the specified contribution with the given rich text.
        Parameters:
        contribution - the contribution related by the content.
        richText - the data of the content. If null then an empty text is set.
      • WysiwygContent

        public WysiwygContent​(LocalizedContribution contribution)
        Constructs an empty WYSIWYG content for the specified contribution.
        Parameters:
        contribution - the contribution related by the content.
      • WysiwygContent

        public WysiwygContent​(WysiwygContent content)
        Constructs a copy of the specified other content.
        Parameters:
        content - the WYSIWYG content to copy.
    • Method Detail

      • getContent

        public static WysiwygContent getContent​(LocalizedContribution contribution)
        Gets the WYSIWYG content of the specified contribution.
        Parameters:
        contribution - a localized contribution.
        Returns:
        the WYSIWYG content of the contribution or null if no such content exists.
      • deleteAllContents

        public static void deleteAllContents​(Contribution contribution)
        Deletes all the WYSIWYG contents of the specified contribution. If the given contribution is an I18n one (a multi-localized contribution) then all of its WYSIWYG contents, one per localization, will be deleted. In the case of a single one localized contribution, only this single WYSIWYG content will be deleted. If the contribution has no WYSIWYG contents, nothing is done.
        Parameters:
        contribution - the contribution for which the WYSIWYG contents have to be deleted.
      • authoredBy

        public WysiwygContent authoredBy​(User author)
        Sets a user as the current author of this content.
        Parameters:
        author - the user to set.
        Returns:
        itself.
      • setData

        public void setData​(String richTest)
        Modifies the text of this content. The content is effectively modified only if the specified text is different to the actual one; in such a case, the content is marked as modified and is then elective for the next storage update.
        Parameters:
        richTest - the new text to set. If null then an empty text is set.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: ContributionContent
        Does the content is empty?
        Specified by:
        isEmpty in interface ContributionContent<String>
        Returns:
        true if this content doesn't contain any data, false otherwise.
      • isModified

        public boolean isModified()
        Is this content was modified since its getting.
        Returns:
        true if this content is modified, false otherwise.
      • getAuthor

        public User getAuthor()
        Gets the user that has authored this content. If no specific user was set as author then returns the user behind the current request if any.
        Returns:
        the author of this content. He can be either the creator of this content or a modifier.
      • save

        public void save()
        Saves this content.
      • delete

        public void delete()
        Deletes this content.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object