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
Modifier and TypeMethodDescriptiondefault Tappend(TextBuilder builder) Append text from given builderappend(CharSequence text) Append given textdefault TappendWithNoWrap(CharSequence text) Append text from the given builder.default TappendWithSpace(TextBuilder builder) Append given text.default TappendWithSpace(CharSequence text) Append given text.default voidcompress(int textLength) Compress current text to the given length.default booleandefault booleanbooleandefault Tprepend(TextBuilder builder) Add text to the beginning from the given builder.prepend(CharSequence text) Add given text to the beginning.default TAdd text to the beginning.default TSet color of the text which will be added later.default TsetText(TextBuilder builder) Replaces current text with the one from the given buildervoidsetText(CharSequence text) Replace current text with the given onetoString()
-
Method Details
-
append
Append text from given builder- Parameters:
builder- builder- Returns:
- this builder
-
prepend
Add text to the beginning from the given builder.- Parameters:
builder- builder- Returns:
- this builder
-
prependWithNoWrap
Add text to the beginning. Added text will not be wrapped if builder supports that.- Parameters:
text- text to prepend- Returns:
- this builder
-
appendWithNoWrap
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
Replaces current text with the one from the given builder- Parameters:
builder- builder- Returns:
- this builder
-
append
Append given text- Parameters:
text- text to append- Returns:
- this builder
-
appendWithSpace
Append given text. Prepend space before given text if build has text added already.- Parameters:
text- text to append- Returns:
- this builder
-
appendWithSpace
Append given text. Prepend space before given text if build has text added already.- Parameters:
builder- text to append- Returns:
- this builder
-
prepend
Add given text to the beginning.- Parameters:
text- text to append- Returns:
- this builder
-
setColor
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
String toString() -
toPlainText
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
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
-