Package org.codehaus.janino.util
Class AutoIndentWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.codehaus.janino.util.AutoIndentWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
A
FilterWriter
that automatically indents lines by looking at trailing opening braces ('{') and
leading closing braces ('}').-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
Special character indicating to clear all tabluar layout that was configured throughTABULATOR
.static final char
Special character that inserts a line break and indents the following text by one position.private int
private final StringBuilder
static final char
Special character indicating a tabular layout of the following text.private List<StringBuilder>
private int
static final char
Special character that inserts a line break and unindents the following text by one position.Fields inherited from class java.io.FilterWriter
out
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
private void
private void
private static void
resolveTabs
(List<StringBuilder> lineGroup) Expands allTABULATOR
s in the givenList
ofStringBuilder
s with spaces, so that the characters immediately following theTABULATOR
s are vertically aligned, like this:private static String
spaces
(int n) void
write
(char[] cbuf, int off, int len) void
write
(int c) void
-
Field Details
-
TABULATOR
public static final char TABULATORSpecial character indicating a tabular layout of the following text.- See Also:
-
CLEAR_TABULATORS
public static final char CLEAR_TABULATORSSpecial character indicating to clear all tabluar layout that was configured throughTABULATOR
.- See Also:
-
INDENT
public static final char INDENTSpecial character that inserts a line break and indents the following text by one position.- See Also:
-
UNINDENT
public static final char UNINDENTSpecial character that inserts a line break and unindents the following text by one position.- See Also:
-
lineBuffer
-
indentation
private int indentation -
tabulatorBuffer
-
tabulatorIndentation
private int tabulatorIndentation
-
-
Constructor Details
-
AutoIndentWriter
-
-
Method Details
-
write
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
line
- Throws:
IOException
-
flushTabulatorBuffer
- Throws:
IOException
-
resolveTabs
Expands allTABULATOR
s in the givenList
ofStringBuilder
s with spaces, so that the characters immediately following theTABULATOR
s are vertically aligned, like this: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
- Returns:
- a
String
ofn
spaces
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterWriter
- Throws:
IOException
-