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 charSpecial character indicating to clear all tabluar layout that was configured throughTABULATOR.static final charSpecial character that inserts a line break and indents the following text by one position.private intprivate final StringBuilderstatic final charSpecial character indicating a tabular layout of the following text.private List<StringBuilder>private intstatic final charSpecial 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 TypeMethodDescriptionvoidclose()voidflush()private voidprivate voidprivate static voidresolveTabs(List<StringBuilder> lineGroup) Expands allTABULATORs in the givenListofStringBuilders with spaces, so that the characters immediately following theTABULATORs are vertically aligned, like this:private static Stringspaces(int n) voidwrite(char[] cbuf, int off, int len) voidwrite(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:
writein classFilterWriter- Throws:
IOException
-
write
- Overrides:
writein classFilterWriter- Throws:
IOException
-
write
- Overrides:
writein classFilterWriter- Throws:
IOException
-
line
- Throws:
IOException
-
flushTabulatorBuffer
- Throws:
IOException
-
resolveTabs
Expands allTABULATORs in the givenListofStringBuilders with spaces, so that the characters immediately following theTABULATORs 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
Stringofnspaces
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterWriter- Throws:
IOException
-