Package io.wcm.handler.richtext.util
Class RichTextUtil
- java.lang.Object
-
- io.wcm.handler.richtext.util.RichTextUtil
-
@ProviderType public final class RichTextUtil extends java.lang.Object
Utility methods for handling XHTML rich text fragments i.e. used for FCKEditor.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addParsedText(@NotNull org.jdom2.Element parent, @NotNull java.lang.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 java.lang.String text, boolean xhtmlEntities)
Parses XHTML text string, and adds to parsed content to the given parent element.static boolean
isEmpty(@Nullable java.lang.String text)
Check if the given formatted text block is empty.static boolean
isEmpty(@Nullable java.lang.String text, int treshold)
Check if the given formatted text block is empty.static @NotNull org.jdom2.Element
parseText(@NotNull java.lang.String text)
Parses XHTML text string.static @NotNull org.jdom2.Element
parseText(@NotNull java.lang.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.
-
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(@Nullable @Nullable java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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
-
-