public class AutoIndentWriter
extends java.io.FilterWriter
FilterWriter
that automatically indents lines by looking at
trailing opening braces ('{') and leading closing braces ('}').Modifier and Type | Field and Description |
---|---|
static char |
CLEAR_TABULATORS
Special character indicating to clear all tabluar layout that was configured through
TABULATOR . |
static char |
INDENT
Special character that inserts a line break and indents the following text by one position.
|
private int |
indentation |
private java.lang.StringBuilder |
lineBuffer |
static char |
TABULATOR
Special character indicating a tabular layout of the following text.
|
private java.util.List<java.lang.StringBuilder> |
tabulatorBuffer |
private int |
tabulatorIndentation |
static char |
UNINDENT
Special character that inserts a line break and unindents the following text by one position.
|
Constructor and Description |
---|
AutoIndentWriter(java.io.Writer out) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
private void |
flushTabulatorBuffer() |
private void |
line(java.lang.String line) |
private static void |
resolveTabs(java.util.List<java.lang.StringBuilder> lineGroup)
|
private static java.lang.String |
spaces(int n) |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(java.lang.String str,
int off,
int len) |
public static final char TABULATOR
public static final char CLEAR_TABULATORS
TABULATOR
.public static final char INDENT
public static final char UNINDENT
private final java.lang.StringBuilder lineBuffer
private int indentation
private java.util.List<java.lang.StringBuilder> tabulatorBuffer
private int tabulatorIndentation
public void write(char[] cbuf, int off, int len) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
public void write(java.lang.String str, int off, int len) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
public void write(int c) throws java.io.IOException
write
in class java.io.FilterWriter
java.io.IOException
private void line(java.lang.String line) throws java.io.IOException
java.io.IOException
private void flushTabulatorBuffer() throws java.io.IOException
java.io.IOException
private static void resolveTabs(java.util.List<java.lang.StringBuilder> lineGroup)
private static java.lang.String spaces(int n)
String
of n
spacespublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterWriter
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.FilterWriter
java.io.IOException