Package com.pnfsoftware.jeb.util.format
Class TextBuilder
java.lang.Object
com.pnfsoftware.jeb.util.format.TextBuilder
- All Implemented Interfaces:
Appendable
- Direct Known Subclasses:
XmlBuilder
A text buffer builder supporting indentation. Can be seen as an alternative to
StringBuilder
to easily create structured documents.
This class may be sub-classed, in particular, refer to XmlBuilder
for XML documents.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a builder with a default indentation size of 4 characters and an initial capacity of 16 characters.TextBuilder
(int indentationSize) Create a builder with an initial capacity of 16 characters.TextBuilder
(int indentationSize, int initialCapacity) Create a builder. -
Method Summary
Modifier and TypeMethodDescriptionappend
(byte v) append
(char v) append
(double v) append
(float v) append
(int v) append
(long v) append
(short v) append
(CharSequence csq) append
(CharSequence csq, int start, int end) appendLine
(boolean noIndent) appendLine
(String format, Object... args) void
clear()
eol()
indent()
indent
(boolean followedByEol) int
length()
void
removeChar
(int pos) void
removeChars
(int start, int end) void
void
space()
toString()
unindent()
void
updateIndentation
(boolean doIndent)
-
Constructor Details
-
TextBuilder
public TextBuilder()Create a builder with a default indentation size of 4 characters and an initial capacity of 16 characters. -
TextBuilder
public TextBuilder(int indentationSize) Create a builder with an initial capacity of 16 characters. -
TextBuilder
public TextBuilder(int indentationSize, int initialCapacity) Create a builder.
-
-
Method Details
-
length
public int length() -
clear
public void clear() -
updateIndentation
public void updateIndentation(boolean doIndent) -
indent
-
indent
-
unindent
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
append
- Specified by:
append
in interfaceAppendable
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
append
-
appendLine
-
appendLine
-
appendLine
-
eol
-
space
-
removeChar
public void removeChar(int pos) -
removeChars
public void removeChars(int start, int end) -
removeLastChar
public void removeLastChar() -
removeLastLine
public void removeLastLine() -
toString
-