Class LastTwoLinesBufferingWriter
- java.lang.Object
-
- java.io.Writer
-
- org.apache.maven.doxia.module.markdown.LastTwoLinesBufferingWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.Appendable,java.lang.AutoCloseable
public class LastTwoLinesBufferingWriter extends java.io.WriterDecorates an existing writer to additionally temporarily buffer the last two lines written. Useful to collapse subsequent new lines or blank lines by evaluatingisWriterAfterBlankLine()andisWriterAfterBlankLine(). The buffering does not affect or defer delegation to the underlying writer, though.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringBuildercurrentLineprivate java.lang.StringlineSeparatorprivate java.io.Writeroutprivate java.lang.StringpreviousLine
-
Constructor Summary
Constructors Constructor Description LastTwoLinesBufferingWriter(java.io.Writer out)LastTwoLinesBufferingWriter(java.io.Writer out, java.lang.String lineSeparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()private voidflushLine(char[] cbuf, int off, int len)booleanisWriterAfterBlankLine()booleanisWriterAtStartOfNewLine()voidwrite(char[] cbuf, int off, int len)
-
-
-
Method Detail
-
isWriterAtStartOfNewLine
public boolean isWriterAtStartOfNewLine()
-
isWriterAfterBlankLine
public boolean isWriterAfterBlankLine()
-
write
public void write(char[] cbuf, int off, int len) throws java.io.IOException- Specified by:
writein classjava.io.Writer- Throws:
java.io.IOException
-
flushLine
private void flushLine(char[] cbuf, int off, int len)
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Specified by:
flushin classjava.io.Writer- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Writer- Throws:
java.io.IOException
-
-