Package com.fasterxml.jackson.core.io
Class SegmentedStringWriter
java.lang.Object
java.io.Writer
com.fasterxml.jackson.core.io.SegmentedStringWriter
- All Implemented Interfaces:
BufferRecycler.Gettable,Closeable,Flushable,Appendable,AutoCloseable
Efficient alternative to
StringWriter, 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 -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) voidclose()voidflush()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) voidvoidMethods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
SegmentedStringWriter
-
-
Method Details
-
bufferRecycler
- Specified by:
bufferRecyclerin interfaceBufferRecycler.Gettable- Returns:
- Buffer recycler instance object is configured with, if any;
whether this can be
nulldepends on type of object
-
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
-
close
public void close() -
flush
public void flush() -
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
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
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
- Throws:
IOException- if there are general I/O or parse issues, including if the text is too large, seeStreamReadConstraints.Builder.maxStringLength(int)
-