Package com.nomagic.text.builders
Class RawTextBuilder<T extends RawTextBuilder>
- java.lang.Object
-
- com.nomagic.text.builders.RawTextBuilder<T>
-
- All Implemented Interfaces:
TextBuilder<T>
@OpenApiAll public class RawTextBuilder<T extends RawTextBuilder> extends java.lang.Object implements TextBuilder<T>
Builds a text without any transformation - input text is appended to the output text. Builder does not support colored fragments directly - result text does not have colors. However colors are be supported ifappendTo(TextBuilder)
is used and proper builder is passed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RawTextBuilder.TextFragment
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Color
color
private java.util.List<RawTextBuilder.TextFragment>
text
-
Constructor Summary
Constructors Constructor Description RawTextBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
append(java.lang.CharSequence text)
Append given textvoid
appendTo(TextBuilder builder)
Appends text from this builder to the given one.boolean
isColorSupported()
boolean
isTextAdded()
T
prepend(java.lang.CharSequence text)
Add given text to the beginning.T
setColor(java.awt.Color color)
Set color of the text which will be added later.void
setText(java.lang.CharSequence text)
Replace current text with the given onejava.lang.String
toPlainText()
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.nomagic.text.builders.TextBuilder
append, appendWithNoWrap, compress, isPlainTextEmpty, prepend, prependWithNoWrap, setText
-
-
-
-
Field Detail
-
text
private final java.util.List<RawTextBuilder.TextFragment> text
-
color
@CheckForNull private java.awt.Color color
-
-
Method Detail
-
append
public T append(java.lang.CharSequence text)
Description copied from interface:TextBuilder
Append given text- Specified by:
append
in interfaceTextBuilder<T extends RawTextBuilder>
- Parameters:
text
- text to append- Returns:
- this builder
-
prepend
public T prepend(java.lang.CharSequence text)
Description copied from interface:TextBuilder
Add given text to the beginning.- Specified by:
prepend
in interfaceTextBuilder<T extends RawTextBuilder>
- Parameters:
text
- text to append- Returns:
- this builder
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceTextBuilder<T extends RawTextBuilder>
- Overrides:
toString
in classjava.lang.Object
- Returns:
- result string
-
setText
public void setText(java.lang.CharSequence text)
Description copied from interface:TextBuilder
Replace current text with the given one- Specified by:
setText
in interfaceTextBuilder<T extends RawTextBuilder>
- Parameters:
text
- text
-
toPlainText
public java.lang.String toPlainText()
- Specified by:
toPlainText
in interfaceTextBuilder<T extends RawTextBuilder>
- Returns:
- result string as plain text
-
setColor
public T setColor(@CheckForNull java.awt.Color color)
Description copied from interface:TextBuilder
Set color of the text which will be added later. Not every implementation supports that, so color can be ignored.- Specified by:
setColor
in interfaceTextBuilder<T extends RawTextBuilder>
- Parameters:
color
- color to set. Null is used to reset previously set color- Returns:
- this builder
-
isColorSupported
public boolean isColorSupported()
- Specified by:
isColorSupported
in interfaceTextBuilder<T extends RawTextBuilder>
- Returns:
- true if builder supports color
-
appendTo
public void appendTo(TextBuilder builder)
Appends text from this builder to the given one.- Parameters:
builder
- given builder
-
isTextAdded
public boolean isTextAdded()
- Specified by:
isTextAdded
in interfaceTextBuilder<T extends RawTextBuilder>
- Returns:
- true if at least one text fragment was added (even if fragment is empty)
-
-