Package com.polarion.core.util.types
Class Text
java.lang.Object
com.polarion.core.util.types.Text
- All Implemented Interfaces:
Serializable
A primitive text type to be used in the model objects.
- Author:
- dobisekm
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionConverts this Text to HTML text.Converts this Text to plain text.boolean
Internal, do not use.Internal, do not use.getType()
int
hashCode()
static Text
The convenience factory method for the creation of an html Text instance.boolean
Returns true, if a lossy format conversion was done on this Text.boolean
isHtml()
Shortcut forTYPE_HTML.equals(type);
boolean
isPlain()
Shortcut forTYPE_PLAIN.equals(type);
static Text
The convenience factory method for the creation of a plain Text instance.void
setTransformedContent
(String transformedContent) Internal, do not use.void
setTransformedContent2
(String transformedContent2) Internal, do not use.toString()
-
Field Details
-
TYPE_PLAIN
A plain (possibly multi-line) text.- See Also:
-
TYPE_HTML
An html text.- See Also:
-
KNOWN_TYPES
All known types (contains the values of all the type constants defined in this class).
-
-
Constructor Details
-
Text
The shortcut for callingnew Text(type, content, false)
. -
Text
Creates a Text with the given type, content, and lossy flag.- Parameters:
type
- The Text type. Must be one ofKNOWN_TYPES
.content
- The Text content in a format that is valid for the given type.lossy
- Whether the provided content has been through a lossy data conversion. (seeisContentLossy()
)
-
-
Method Details
-
plain
The convenience factory method for the creation of a plain Text instance.- Returns:
new Text(TYPE_PLAIN, content);
-
html
The convenience factory method for the creation of an html Text instance.- Returns:
new Text(TYPE_HTML, content);
-
getType
- Returns:
- This Text's type. (One of the type constants defined in this class.)
-
getContent
- Returns:
- The string content of this text in a format specific for the text's type.
-
isContentLossy
public boolean isContentLossy()Returns true, if a lossy format conversion was done on this Text. (seeconvertTo...
methods).Making modifications based on lossy text is not recommended.
-
isPlain
public boolean isPlain()Shortcut forTYPE_PLAIN.equals(type);
-
isHtml
public boolean isHtml()Shortcut forTYPE_HTML.equals(type);
-
convertToPlainText
Converts this Text to plain text. If it's already plain text, thenthis
is returned. Otherwise the content is converted to plain text (any html tags are removed), and a newText
instance is created.Note: This function is lossy, so the HTML tag information is lost forever. Recommendation: Never transform between HTML and plain text multiple times.
- Returns:
- New
Text
instance with typeTYPE_PLAIN
- See Also:
-
convertToHTML()
HTMLHelper.convertHTMLToPlain(String)
-
convertToHTML
Converts this Text to HTML text. If it's already HTML text, thenthis
is returned. Otherwise the content is converted to HTML by escaping characters, that have special meaning or that are ignored in HTML.Note: This function is lossy, so there is no guarantee that converting Note: This function is lossy, so there is no guarantee that converting the HTML back to plain text will generate the original text.
- Returns:
- New
Text
instance with type "text/html" - See Also:
-
convertToPlainText()
HTMLHelper.convertPlainToHTML(String)
-
toString
-
equals
-
hashCode
public int hashCode() -
getTransformedContent
Internal, do not use.- Since:
- 3.4.1
-
setTransformedContent
Internal, do not use.- Since:
- 3.4.1
-
getTransformedContent2
Internal, do not use.- Since:
- 3.5.0
-
setTransformedContent2
Internal, do not use.- Since:
- 3.5.0
-