java.lang.Object
java.io.Writer
org.apache.johnzon.core.Snippet.PassthroughWriter
org.apache.johnzon.core.Snippet.Buffer.SnippetWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable,Buffered
- Enclosing class:
- Snippet.Buffer
Specialized Writer with three internal states:
Writing, Completed, Truncated.
When there is still space left for more json, the
state will be Writing
If the last write brought is exactly to the end of
the max length, the state will be Completed.
If the last write brought us over the max length, the
state will be Truncated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classSignifies the last write was fully written, but there is no more space for future writes.(package private) classSignifies the last write was not completely written and there was no more space for this or future writes.(package private) class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteArrayOutputStreamprivate final intprivate Snippet.PassthroughWriter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintThe buffer size used by this stream while reading input or before writing output to the underlying stream.voidclose()voidflush()get()booleanbooleanCalling this method implies the need to continue writing and a question on if that is ok.voidwrite(char[] cbuf, int off, int len) Methods inherited from class org.apache.johnzon.core.Snippet.PassthroughWriter
append, append, append, write, write, writeMethods inherited from class java.io.Writer
nullWriter, write
-
Field Details
-
buffer
-
max
private final int max -
mode
-
-
Constructor Details
-
SnippetWriter
public SnippetWriter(int max)
-
-
Method Details
-
get
-
bufferSize
public int bufferSize()Description copied from interface:BufferedThe buffer size used by this stream while reading input or before writing output to the underlying stream.- Specified by:
bufferSizein interfaceBuffered- Returns:
- the size of the buffer
-
terminate
public boolean terminate()Calling this method implies the need to continue writing and a question on if that is ok. It impacts internal state in the same way as calling a write method.- Returns:
- true if no more writes are possible
-
isTruncated
public boolean isTruncated() -
write
- Specified by:
writein classWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classSnippet.PassthroughWriter- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSnippet.PassthroughWriter- Throws:
IOException
-