Package com.fasterxml.jackson.core.io
Class SegmentedStringWriter
- java.lang.Object
-
- java.io.Writer
-
- com.fasterxml.jackson.core.io.SegmentedStringWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public final class SegmentedStringWriter extends Writer
Efficient alternative toStringWriter, based on using segmented internal buffer. Initial input buffer is also recyclable.This class is most useful when serializing JSON content as a String: if so, instance of this class can be given as the writer to
JsonGenerator.
-
-
Constructor Summary
Constructors Constructor Description SegmentedStringWriter(BufferRecycler br)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Writerappend(char c)Writerappend(CharSequence csq)Writerappend(CharSequence csq, int start, int end)voidclose()voidflush()StringgetAndClear()Main access method that will construct a String that contains all the contents, release all internal buffers we may have, and return result String.voidwrite(char[] cbuf)voidwrite(char[] cbuf, int off, int len)voidwrite(int c)voidwrite(String str)voidwrite(String str, int off, int len)-
Methods inherited from class java.io.Writer
nullWriter
-
-
-
-
Constructor Detail
-
SegmentedStringWriter
public SegmentedStringWriter(BufferRecycler br)
-
-
Method Detail
-
append
public Writer append(char c)
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
public Writer append(CharSequence csq)
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
public Writer append(CharSequence csq, int start, int end)
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
close
public void close()
-
flush
public void flush()
-
getAndClear
public String getAndClear()
Main access method that will construct a String that contains all the contents, release all internal buffers we may have, and return result String. Note that the method is not idempotent -- if called second time, will just return an empty String.- Returns:
- String that contains all aggregated content
-
-