public abstract class IndentingStringBuilder
extends java.lang.Object
PrettyStringBuilder honor the spacing, which the PlainStringBuilder
ignore it, and all requests for whitespace (such as nextLine()), result in
just a single space begin appended to the String.
The IndentingStringBuilder interface has a fluent-style definition, allowing it to be
used repeatedly in expressions.| Modifier and Type | Field and Description |
|---|---|
protected java.lang.StringBuilder |
sb |
| Constructor and Description |
|---|
IndentingStringBuilder(java.lang.StringBuilder sb)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
abstract IndentingStringBuilder |
addComment(java.lang.String comment)
Add a c-style comment.
|
IndentingStringBuilder |
append(char v)
Append a char.
|
IndentingStringBuilder |
append(long v)
Append a long value, as text.
|
IndentingStringBuilder |
append(java.lang.String v)
Append a String.
|
int |
length()
Return the length of the String written so far.
|
abstract IndentingStringBuilder |
nextLine()
Emit a newline, along with any necessary indentation.
|
abstract IndentingStringBuilder |
popIndent()
Remove a level of indentation.
|
abstract IndentingStringBuilder |
pushIndent()
Add a new level of indentation.
|
java.lang.String |
toString() |
public IndentingStringBuilder(java.lang.StringBuilder sb)
sb - the StringBuilder to write topublic java.lang.String toString()
toString in class java.lang.Objectpublic int length()
public IndentingStringBuilder append(java.lang.String v)
v - the string to appendpublic IndentingStringBuilder append(char v)
v - the char to appendpublic IndentingStringBuilder append(long v)
v - the long to appendpublic abstract IndentingStringBuilder nextLine()
public abstract IndentingStringBuilder pushIndent()
nextLine().public abstract IndentingStringBuilder popIndent()
nextLine().
It is an error to unindent when there are no levels of indentation active;
this is indicated with a call to addComment(String) with a warning
that the caller has unindented too much.public abstract IndentingStringBuilder addComment(java.lang.String comment)
comment - the comment