Class RichTextUtil

java.lang.Object
io.wcm.handler.richtext.util.RichTextUtil

@ProviderType public final class RichTextUtil extends Object
Utility methods for handling XHTML rich text fragments i.e. used for FCKEditor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addParsedText(@NotNull org.jdom2.Element parent, @NotNull String text)
    Parses XHTML text string, and adds to parsed content to the given parent element.
    static void
    addParsedText(@NotNull org.jdom2.Element parent, @NotNull String text, boolean xhtmlEntities)
    Parses XHTML text string, and adds to parsed content to the given parent element.
    static boolean
    isEmpty(@Nullable String text)
    Check if the given formatted text block is empty.
    static boolean
    isEmpty(@Nullable String text, int treshold)
    Check if the given formatted text block is empty.
    static @NotNull org.jdom2.Element
    parseText(@NotNull String text)
    Parses XHTML text string.
    static @NotNull org.jdom2.Element
    parseText(@NotNull String text, boolean xhtmlEntities)
    Parses XHTML text string.
    static void
    rewriteContent(@NotNull org.jdom2.Element parent, @NotNull RewriteContentHandler rewriteContentHandler)
    Rewrites all children/sub-tree of the given parent element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isEmpty

      public static boolean isEmpty(@Nullable @Nullable String text)
      Check if the given formatted text block is empty. A text block containing only one paragraph element and whitespaces is considered as empty. A text block with more than 20 characters (raw data) is never considered as empty.
      Parameters:
      text - XHTML text string (root element not needed)
      Returns:
      true if text block is empty
    • isEmpty

      public static boolean isEmpty(@Nullable @Nullable String text, int treshold)
      Check if the given formatted text block is empty. A text block containing only one paragraph element and whitespaces is considered as empty. A text block with more than pTreshold characters (raw data) is never considered as empty.
      Parameters:
      text - XHTML text string (root element not needed)
      treshold - Treshold value - only strings with less than this number of characters are checked.
      Returns:
      true if text block is empty
    • addParsedText

      public static void addParsedText(@NotNull @NotNull org.jdom2.Element parent, @NotNull @NotNull String text) throws org.jdom2.JDOMException
      Parses XHTML text string, and adds to parsed content to the given parent element.
      Parameters:
      parent - Parent element to add parsed content to
      text - XHTML text string (root element not needed)
      Throws:
      org.jdom2.JDOMException - Is thrown if the text could not be parsed as XHTML
    • addParsedText

      public static void addParsedText(@NotNull @NotNull org.jdom2.Element parent, @NotNull @NotNull String text, boolean xhtmlEntities) throws org.jdom2.JDOMException
      Parses XHTML text string, and adds to parsed content to the given parent element.
      Parameters:
      parent - Parent element to add parsed content to
      text - XHTML text string (root element not needed)
      xhtmlEntities - If set to true, Resolving of XHtml entities in XHtml fragment is supported.
      Throws:
      org.jdom2.JDOMException - Is thrown if the text could not be parsed as XHTML
    • parseText

      @NotNull public static @NotNull org.jdom2.Element parseText(@NotNull @NotNull String text) throws org.jdom2.JDOMException
      Parses XHTML text string. Adds a wrapping "root" element before parsing and returns this root element.
      Parameters:
      text - XHTML text string (root element not needed)
      Returns:
      Root element with parsed xhtml content
      Throws:
      org.jdom2.JDOMException - Is thrown if the text could not be parsed as XHTML
    • parseText

      @NotNull public static @NotNull org.jdom2.Element parseText(@NotNull @NotNull String text, boolean xhtmlEntities) throws org.jdom2.JDOMException
      Parses XHTML text string. Adds a wrapping "root" element before parsing and returns this root element.
      Parameters:
      text - XHTML text string (root element not needed)
      xhtmlEntities - If set to true, Resolving of XHtml entities in XHtml fragment is supported.
      Returns:
      Root element with parsed xhtml content
      Throws:
      org.jdom2.JDOMException - Is thrown if the text could not be parsed as XHTML
    • rewriteContent

      public static void rewriteContent(@NotNull @NotNull org.jdom2.Element parent, @NotNull @NotNull RewriteContentHandler rewriteContentHandler)
      Rewrites all children/sub-tree of the given parent element. For rewrite operations the given rewrite content handler is called.
      Parameters:
      parent - Parent element
      rewriteContentHandler - Rewrite content handler