public class TextBuilder
extends java.lang.Object
TextStyleRegion
s while adding text.Modifier and Type | Class and Description |
---|---|
static class |
TextBuilder.TextBuilderRegion
Inner class for storing the partial region styles.
|
Constructor and Description |
---|
TextBuilder() |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String text)
Add text to the builder.
|
void |
finishRegion(java.lang.String name)
Finish a region.
|
void |
forgetRegion(java.lang.String name)
Drop a region that was created but not yet finished.
|
int |
getLength()
Get current length of the collected text.
|
TextBuilder.TextBuilderRegion |
getRegion(java.lang.String name)
Get a previously created and not yet finished region.
|
java.util.List<TextStyleRegion> |
getRegions()
Get the regions created and finished for the text.
|
boolean |
isEmpty()
Is any text added yet?
|
TextBuilder.TextBuilderRegion |
startRegion(java.lang.String name)
Start a new region in the text.
|
java.lang.String |
toString()
Get the collected text.
|
public void add(java.lang.String text)
text
- Text to append.public int getLength()
public boolean isEmpty()
true
if no text added yet, else false
.public java.lang.String toString()
toString
in class java.lang.Object
add(java.lang.String)
.public java.util.List<TextStyleRegion> getRegions()
public TextBuilder.TextBuilderRegion startRegion(java.lang.String name)
name
- Name of the region.public TextBuilder.TextBuilderRegion getRegion(java.lang.String name)
name
- Name of the region to retrieve.null
.public void finishRegion(java.lang.String name)
name
- Name of the region to finish.public void forgetRegion(java.lang.String name)
name
- Name of the region to forget.