Package io.wcm.handler.richtext.util
Class RichTextUtil
java.lang.Object
io.wcm.handler.richtext.util.RichTextUtil
Utility methods for handling XHTML rich text fragments i.e. used for FCKEditor.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddParsedText(@NotNull org.jdom2.Element parent, @NotNull String text) Parses XHTML text string, and adds to parsed content to the given parent element.static voidaddParsedText(@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 booleanCheck if the given formatted text block is empty.static booleanCheck if the given formatted text block is empty.static @NotNull org.jdom2.ElementParses XHTML text string.static @NotNull org.jdom2.ElementParses XHTML text string.static voidrewriteContent(@NotNull org.jdom2.Element parent, @NotNull RewriteContentHandler rewriteContentHandler) Rewrites all children/sub-tree of the given parent element.
-
Method Details
-
isEmpty
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
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 totext- 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 totext- 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 elementrewriteContentHandler- Rewrite content handler
-