Package groovy.text.markup
Class DelegatingIndentWriter
java.lang.Object
java.io.Writer
groovy.text.markup.DelegatingIndentWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
A writer which delegates to another writer and supports an additional indenting level.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingIndentWriter(Writer delegate) Creates an indenting writer that usesSPACESfor each indentation level.DelegatingIndentWriter(Writer delegate, String indentString) Creates an indenting writer that delegates output to another writer. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) voidclose()voidflush()intnext()Increases the current indentation level.intprevious()Decreases the current indentation level.voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) voidvoidvoidWrites the current indentation prefix to the delegate writer.Methods inherited from class java.io.Writer
nullWriter
-
Field Details
-
SPACES
Four-space indentation unit.- See Also:
-
TAB
Tab indentation unit.- See Also:
-
-
Constructor Details
-
DelegatingIndentWriter
Creates an indenting writer that usesSPACESfor each indentation level.- Parameters:
delegate- writer that receives the rendered output
-
DelegatingIndentWriter
Creates an indenting writer that delegates output to another writer.- Parameters:
delegate- writer that receives the rendered outputindentString- indentation unit written for each nesting level
-
-
Method Details
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Specified by:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
next
public int next()Increases the current indentation level.- Returns:
- the new indentation level
-
previous
public int previous()Decreases the current indentation level.- Returns:
- the new indentation level
-
writeIndent
Writes the current indentation prefix to the delegate writer.- Throws:
IOException- if writing the indentation fails
-