Package com.nomagic.text.builders
Interface TextBuilder<T extends TextBuilder>
-
- All Known Implementing Classes:
AbstractTextBuilder
,ColoredHtmlTextBuilder
,ColoredRichTextBuilder
,HtmlTextBuilder
,PlainOrFullHtmlTextBuilder
,PlainOrLightHtmlTextBuilder
,PlainTextBuilder
,RawTextBuilder
,RichTextBuilder
@OpenApiAll public interface TextBuilder<T extends TextBuilder>
An utility used for building plain or rich texts with possibly colored fragments.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default T
append(TextBuilder builder)
Append text from given builderT
append(java.lang.CharSequence text)
Append given textdefault T
appendWithNoWrap(java.lang.CharSequence text)
Append text from the given builder.default void
compress(int textLength)
Compress current text to the given length.default boolean
isColorSupported()
default boolean
isPlainTextEmpty()
boolean
isTextAdded()
default T
prepend(TextBuilder builder)
Add text to the beginning from the given builder.T
prepend(java.lang.CharSequence text)
Add given text to the beginning.default T
prependWithNoWrap(java.lang.CharSequence text)
Add text to the beginning.default T
setColor(java.awt.Color color)
Set color of the text which will be added later.default T
setText(TextBuilder builder)
Replaces current text with the one from the given buildervoid
setText(java.lang.CharSequence text)
Replace current text with the given onejava.lang.String
toPlainText()
java.lang.String
toString()
-
-
-
Method Detail
-
append
default T append(TextBuilder builder)
Append text from given builder- Parameters:
builder
- builder- Returns:
- this builder
-
prepend
default T prepend(TextBuilder builder)
Add text to the beginning from the given builder.- Parameters:
builder
- builder- Returns:
- this builder
-
prependWithNoWrap
default T prependWithNoWrap(java.lang.CharSequence text)
Add text to the beginning. Added text will not be wrapped if builder supports that.- Parameters:
text
- text to prepend- Returns:
- this builder
-
appendWithNoWrap
default T appendWithNoWrap(java.lang.CharSequence text)
Append text from the given builder. Added text will not be wrapped if builder supports that.- Parameters:
text
- text to prepend- Returns:
- this builder
-
setText
default T setText(TextBuilder builder)
Replaces current text with the one from the given builder- Parameters:
builder
- builder- Returns:
- this builder
-
append
T append(java.lang.CharSequence text)
Append given text- Parameters:
text
- text to append- Returns:
- this builder
-
prepend
T prepend(java.lang.CharSequence text)
Add given text to the beginning.- Parameters:
text
- text to append- Returns:
- this builder
-
setColor
default T setColor(@CheckForNull java.awt.Color color)
Set color of the text which will be added later. Not every implementation supports that, so color can be ignored.- Parameters:
color
- color to set. Null is used to reset previously set color- Returns:
- this builder
-
toString
java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- result string
-
toPlainText
java.lang.String toPlainText()
- Returns:
- result string as plain text
-
isPlainTextEmpty
default boolean isPlainTextEmpty()
- Returns:
- true if text converted to a plain is empty in this builder
-
setText
void setText(java.lang.CharSequence text)
Replace current text with the given one- Parameters:
text
- text
-
compress
default void compress(int textLength)
Compress current text to the given length. This function is not supported in every implementation, so it can be ignored.- Parameters:
textLength
- text length
-
isTextAdded
boolean isTextAdded()
- Returns:
- true if at least one text fragment was added (even if fragment is empty)
-
isColorSupported
default boolean isColorSupported()
- Returns:
- true if builder supports color
-
-