java.io.FilterWriter that indents lines by processing some control characters in the character stream.
INDENT or UNINDENT may precede lines and indicate that the line and all following lines should
be (un)indented by one position.
TABULATORs may appear anywhere in lines and dictate that portions of all following lines should be
vertically aligned (see resolveTabs(List)).
| Modifier and Type | Field and Description |
|---|---|
| public static final char | CLEAR_TABULATORS
Special character at the beginning of a line that flushes a tabular layout. |
| public static final char | INDENT
Special character at the beginning of a line that indents the following text by one position. |
| private int | indentation
The current indentation level; incremented by a |
| private final StringBuilder | lineBuffer
Buffer for the "current line", including the trailing line break (CR, LF or CRLF). |
| public static final char | |
| private List | tabulatorBuffer
Iff non-null, then we are in "tab mode". |
| private int | tabulatorIndentation
The |
| public static final char | UNINDENT
Special character at the beginning of a line that unindents the following text by one position. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| public void | flush()
Overrides java. Implements java. |
| private void | |
| private void | |
| private static void | resolveTabs(List<StringBuilder> lineGroup)
Expands all Input: a @b @c\r\n aa @bb @cc\r\n aaa @bbb @ccc\r\n |
| private static String | |
| public void | write(char[]
Buffer of characters to be written cbuf, int Offset from which to start reading characters off, int Number of characters to be written len)Overrides java. |
| public void | write(String
String to be written str, int Offset from which to start reading characters off, int Number of characters to be written len)Overrides java. |
| public void | write(int
int specifying a character to be written c)Overrides java. |
| CLEAR_TABULATORS | back to summary |
|---|---|
| public static final char CLEAR_TABULATORS Special character at the beginning of a line that flushes a tabular layout. | |
| INDENT | back to summary |
|---|---|
| public static final char INDENT Special character at the beginning of a line that indents the following text by one position. | |
| indentation | back to summary |
|---|---|
| private int indentation The current indentation level; incremented by a | |
| lineBuffer | back to summary |
|---|---|
| private final StringBuilder lineBuffer Buffer for the "current line", including the trailing line break (CR, LF or CRLF). | |
| TABULATOR | back to summary |
|---|---|
| public static final char TABULATOR Special character indicating a tabular layout of all following lines until | |
| tabulatorBuffer | back to summary |
|---|---|
| private List<StringBuilder> tabulatorBuffer Iff non-null, then we are in "tab mode". While in tab mode, lines are not printed immediately, but stored in
this buffer. Tab mode starts when a line contains a
When tab mode ends, all buffered lines are vertically aligned at the | |
| tabulatorIndentation | back to summary |
|---|---|
| private int tabulatorIndentation The | |
| UNINDENT | back to summary |
|---|---|
| public static final char UNINDENT Special character at the beginning of a line that unindents the following text by one position. | |
| AutoIndentWriter | back to summary |
|---|---|
| public AutoIndentWriter(Writer out) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Overrides java. Implements java. Doc from java. Flushes the stream.
| |
| flushTabulatorBuffer | back to summary |
|---|---|
| private void flushTabulatorBuffer() throws IOException | |
| line | back to summary |
|---|---|
| private void line(String line) throws IOException | |
| resolveTabs | back to summary |
|---|---|
| private static void resolveTabs(List<StringBuilder> lineGroup) Expands all Input: a @b @c\r\n aa @bb @cc\r\n aaa @bbb @ccc\r\n Output: a b c\r\n aa bb cc\r\n aaa bbb ccc\r\n | |
| spaces | back to summary |
|---|---|
| private static String spaces(int n) | |
| write | back to summary |
|---|---|
| public void write(char[] cbuf, int off, int len) throws IOException Overrides java. Doc from java. Writes a portion of an array of characters.
| |
| write | back to summary |
|---|---|
| public void write(String str, int off, int len) throws IOException Overrides java. Doc from java. Writes a portion of a string.
| |
| write | back to summary |
|---|---|
| public void write(int c) throws IOException Overrides java. Doc from java. Writes a single character.
| |