java.lang.Object
java.io.Writer
com.aoapps.io.buffer.BufferWriter
com.aoapps.io.buffer.LoggingWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Logs all write calls in a way that can be put into Java source code.
This is used to capture real-world scenarios for unit testing.
This class is not thread safe.
- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) voidclose()voidflush()longgetId()longGets the number of characters in this buffer.Gets the result from this buffer.toString()Gets a short message (like type and length).voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) voidvoidMethods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
LoggingWriter
- Throws:
IOException
-
-
Method Details
-
getId
public long getId() -
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
-
getLength
Description copied from class:BufferWriterGets the number of characters in this buffer. Once closed, this length will not be modified.- Specified by:
getLengthin classBufferWriter- Throws:
IOException
-
toString
Description copied from class:BufferWriterGets a short message (like type and length).- Specified by:
toStringin classBufferWriter- See Also:
-
getResult
Description copied from class:BufferWriterGets the result from this buffer. The buffer must be closed.Note: Although the
BufferWriterare generally not thread-safe, theBufferResultis thread-safe. It is expected to commonly create a buffer on one thread, but the be able to safely share the result among many threads.- Specified by:
getResultin classBufferWriter- Throws:
IllegalStateException- if not closedIOException
-
