Package org.apache.johnzon.core
Class Snippet.Buffer.SnippetWriter
- 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
 
 class Snippet.Buffer.SnippetWriter extends Snippet.PassthroughWriter implements Buffered 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 SummaryNested Classes Modifier and Type Class Description (package private) classSnippet.Buffer.SnippetWriter.CompletedSignifies the last write was fully written, but there is no more space for future writes.(package private) classSnippet.Buffer.SnippetWriter.TruncatedSignifies the last write was not completely written and there was no more space for this or future writes.(package private) classSnippet.Buffer.SnippetWriter.Writing
 - 
Field SummaryFields Modifier and Type Field Description private ByteArrayOutputStreambufferprivate intmaxprivate Snippet.PassthroughWritermode
 - 
Constructor SummaryConstructors Constructor Description SnippetWriter(int max)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intbufferSize()The buffer size used by this stream while reading input or before writing output to the underlying stream.voidclose()voidflush()Stringget()booleanisTruncated()booleanterminate()Calling 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.PassthroughWriterappend, append, append, write, write, write
 - 
Methods inherited from class java.io.WriternullWriter, write
 
- 
 
- 
- 
- 
Field Detail- 
bufferprivate final ByteArrayOutputStream buffer 
 - 
maxprivate final int max 
 - 
modeprivate Snippet.PassthroughWriter mode 
 
- 
 - 
Method Detail- 
getpublic String get() 
 - 
bufferSizepublic 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 interface- Buffered
- Returns:
- the size of the buffer
 
 - 
terminatepublic 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
 
 - 
isTruncatedpublic boolean isTruncated() 
 - 
writepublic void write(char[] cbuf, int off, int len) throws IOException- Specified by:
- writein class- Writer
- Throws:
- IOException
 
 - 
flushpublic void flush() throws IOException- Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- Snippet.PassthroughWriter
- Throws:
- IOException
 
 - 
closepublic void close() throws IOException- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- Snippet.PassthroughWriter
- Throws:
- IOException
 
 
- 
 
-