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 Tappend(TextBuilder builder)Append text from given builderTappend(java.lang.CharSequence text)Append given textdefault TappendWithNoWrap(java.lang.CharSequence text)Append text from the given builder.default voidcompress(int textLength)Compress current text to the given length.default booleanisColorSupported()default booleanisPlainTextEmpty()booleanisTextAdded()default Tprepend(TextBuilder builder)Add text to the beginning from the given builder.Tprepend(java.lang.CharSequence text)Add given text to the beginning.default TprependWithNoWrap(java.lang.CharSequence text)Add text to the beginning.default TsetColor(java.awt.Color color)Set color of the text which will be added later.default TsetText(TextBuilder builder)Replaces current text with the one from the given buildervoidsetText(java.lang.CharSequence text)Replace current text with the given onejava.lang.StringtoPlainText()java.lang.StringtoString()
-
-
-
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:
toStringin 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
-
-