Package com.nomagic.text
Class TextUtils
java.lang.Object
com.nomagic.text.TextUtils
Utility class to check the text formats and convert text from one format to other.
Several text formats are supported:
Several text formats are supported:
- plain - text without any formatting
- html (or full html) - html text
- light html - restricted html flavor which supports only <a> tags and href with "mdel://" protocol
- rich - an extended version of plain text which support colored fragments (<font color=#> tags) and fragments with references (<a> tags and href with "mdel://" protocol)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isFullHtml
(String text) Checks if given text is html text, but not a "light" one.static boolean
Checks if given text is html text.static boolean
isLightHtml
(String text) Checks if given text is "light" html.static boolean
isPlainText
(String text) Checks if given text is rich text.static boolean
isRichText
(String text) Checks if given text is rich text.static String
toFullHtml
(String text) Converts given text to full html.static String
toLightHtml
(String text) Converts given text to light html.static String
toLightHtmlIfFullHtml
(String text) Converts given text to light html if text is full html, otherwise returns the same text.static String
toLightHtmlIfRichText
(String text) Converts given rich text to light html, otherwise returns the same text.static String
toPlainText
(String text) Converts given rich or html text to plain text.static String
toPlainTextIfFullHtml
(String text) Converts given full html text to plain text, otherwise returns the same textstatic String
toPlainTextIfHtml
(String text) Converts given html text to plain text, otherwise returns the same textstatic String
toPlainTextIfLightHtml
(String text) Converts given light html text to plain text, otherwise returns the same textstatic String
toRichText
(String text) Converts given html text to rich text, otherwise returns the same text.static String
toRichTextIfLightHtml
(String text) Converts given light html to rich text, otherwise returns the same text.
-
Constructor Details
-
TextUtils
public TextUtils()
-
-
Method Details
-
isHtml
Checks if given text is html text.- Parameters:
text
- text- Returns:
- true if text is html
-
isFullHtml
Checks if given text is html text, but not a "light" one.- Parameters:
text
- text- Returns:
- true if text is full html
-
isLightHtml
Checks if given text is "light" html.- Parameters:
text
- text- Returns:
- true if text is light html
-
isRichText
Checks if given text is rich text.- Parameters:
text
- text- Returns:
- true if text is rich one
-
isPlainText
Checks if given text is rich text.- Parameters:
text
- text- Returns:
- true if text is plain one
-
toFullHtml
Converts given text to full html.- Parameters:
text
- text- Returns:
- full html text
-
toLightHtmlIfFullHtml
Converts given text to light html if text is full html, otherwise returns the same text.- Parameters:
text
- text- Returns:
- light html text or same text
-
toLightHtml
Converts given text to light html. If text is full html converts to light html. If text is plain text converts to light html.- Parameters:
text
- text- Returns:
- light html text
-
toRichText
Converts given html text to rich text, otherwise returns the same text.- Parameters:
text
- text- Returns:
- rich text
-
toRichTextIfLightHtml
Converts given light html to rich text, otherwise returns the same text.- Parameters:
text
- text- Returns:
- rich text
-
toLightHtmlIfRichText
Converts given rich text to light html, otherwise returns the same text.- Parameters:
text
- text- Returns:
- light html or same text
-
toPlainText
Converts given rich or html text to plain text.- Parameters:
text
- text- Returns:
- plain text
-
toPlainTextIfLightHtml
Converts given light html text to plain text, otherwise returns the same text- Parameters:
text
- text- Returns:
- plain text or same text
-
toPlainTextIfHtml
Converts given html text to plain text, otherwise returns the same text- Parameters:
text
- text- Returns:
- plain text or same text
-
toPlainTextIfFullHtml
Converts given full html text to plain text, otherwise returns the same text- Parameters:
text
- text- Returns:
- plain text or same text
-