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 Writer
append(char c)
Writer
append(CharSequence csq)
Writer
append(CharSequence csq, int start, int end)
void
close()
void
flush()
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.void
write(char[] cbuf)
void
write(char[] cbuf, int off, int len)
void
write(int c)
void
write(String str)
void
write(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:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
public Writer append(CharSequence csq)
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
public Writer append(CharSequence csq, int start, int end)
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in 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
-
-