Class LastTwoLinesBufferingWriter
java.lang.Object
java.io.Writer
org.apache.maven.doxia.module.markdown.LastTwoLinesBufferingWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Decorates an existing writer to additionally temporarily buffer the last two lines written.
Useful to collapse subsequent new lines or blank lines by evaluating
isWriterAfterBlankLine()
and isWriterAfterBlankLine()
.
The buffering does not affect or defer delegation to the underlying writer, though.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringBuilder
private final String
private final Writer
private String
-
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
out
-
previousLine
-
currentLine
-
lineSeparator
-
-
Constructor Details
-
LastTwoLinesBufferingWriter
-
LastTwoLinesBufferingWriter
-
-
Method Details
-
isWriterAtStartOfNewLine
public boolean isWriterAtStartOfNewLine() -
isWriterAfterBlankLine
public boolean isWriterAfterBlankLine() -
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
flushLine
private void flushLine(char[] cbuf, int off, int len) -
flush
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-