public class IndentHandler extends java.lang.Object implements Indentable
The 0 indent level is equivalent to no indents. For each
positive indent level, the number of space characters written will be
equivalent to the indent level times the width of a single indent level
(which defaults to 3 spaces).
So at the 0 indent level, no spaces are written. At the
1 indent level, 3 spaces (by default) are written. At the
2 indent level, 6 spaces (by default) are written and so on.
By changing the width and indent level, the exact indent results can be
completely controlled.
This class is not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
private int |
indent
Current indent level (defaults to 0).
|
private java.lang.StringBuilder |
pad
Current pad inserted between newlines and subsequent bytes.
|
private int |
width
Width of each indent level (defaults to 3 space characters).
|
| Constructor and Description |
|---|
IndentHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
decrement()
Decrements the indent level by 1.
|
int |
getIndent()
Accesses the current indent level.
|
java.lang.String |
getPad()
Get the current pad.
|
int |
getWidth()
Accesses the number of spaces in a single indent level.
|
void |
increment()
Increments the indent level by 1.
|
private void |
pad(int sz)
Create a pad string containing
sz space characters. |
void |
setIndent(int indent)
Sets the current indent level.
|
void |
setPad(int indent,
int width)
Sets both the indent level and the number of spaces in a single indent
level.
|
void |
setWidth(int width)
Sets the number of spaces in a single indent level.
|
private int indent
private int width
private java.lang.StringBuilder pad
public int getIndent()
getIndent in interface Indentablepublic void setIndent(int indent)
setIndent in interface Indentableindent - New indent level.public void increment()
increment in interface Indentablepublic void decrement()
decrement in interface Indentablepublic int getWidth()
getWidth in interface Indentablepublic void setWidth(int width)
setWidth in interface Indentablewidth - New indent width.public void setPad(int indent,
int width)
setPad in interface Indentableindent - New indent level.width - New indent width.public java.lang.String getPad()
getPad in interface Indentableprivate void pad(int sz)
sz space characters.sz - The number of spaces to put into the pad string.