Package org.eclipse.graphiti.util
Class TextBuilder
- java.lang.Object
-
- org.eclipse.graphiti.util.TextBuilder
-
public class TextBuilder extends java.lang.ObjectClass to constructTextStyleRegions while adding text.- Since:
- 0.12
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTextBuilder.TextBuilderRegionInner class for storing the partial region styles.
-
Constructor Summary
Constructors Constructor Description TextBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.String text)Add text to the builder.voidfinishRegion(java.lang.String name)Finish a region.voidforgetRegion(java.lang.String name)Drop a region that was created but not yet finished.intgetLength()Get current length of the collected text.TextBuilder.TextBuilderRegiongetRegion(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.booleanisEmpty()Is any text added yet?TextBuilder.TextBuilderRegionstartRegion(java.lang.String name)Start a new region in the text.java.lang.StringtoString()Get the collected text.
-
-
-
Method Detail
-
add
public void add(java.lang.String text)
Add text to the builder.- Parameters:
text- Text to append.
-
getLength
public int getLength()
Get current length of the collected text.- Returns:
- Length of the text collected so far (number of code points).
-
isEmpty
public boolean isEmpty()
Is any text added yet?- Returns:
trueif no text added yet, elsefalse.
-
toString
public java.lang.String toString()
Get the collected text.- Overrides:
toStringin classjava.lang.Object- Returns:
- The concatenated strings previously given through
add(java.lang.String).
-
getRegions
public java.util.List<TextStyleRegion> getRegions()
Get the regions created and finished for the text.- Returns:
- Regions of the text.
-
startRegion
public TextBuilder.TextBuilderRegion startRegion(java.lang.String name)
Start a new region in the text. Returns the created region for setting the style of the new region.- Parameters:
name- Name of the region.- Returns:
- The created region.
-
getRegion
public TextBuilder.TextBuilderRegion getRegion(java.lang.String name)
Get a previously created and not yet finished region.- Parameters:
name- Name of the region to retrieve.- Returns:
- The queried region if it exists, else
null.
-
finishRegion
public void finishRegion(java.lang.String name)
Finish a region.- Parameters:
name- Name of the region to finish.
-
forgetRegion
public void forgetRegion(java.lang.String name)
Drop a region that was created but not yet finished.- Parameters:
name- Name of the region to forget.
-
-