Package org.codehaus.jackson.io
Class SegmentedStringWriter
java.lang.Object
java.io.Writer
org.codehaus.jackson.io.SegmentedStringWriter
- All Implemented Interfaces:
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.
- Since:
- 1.3
-
Field Summary
Fields -
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
-
Field Details
-
_buffer
-
-
Constructor Details
-
SegmentedStringWriter
-
-
Method Details
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
close
public void close() -
flush
public void flush() -
write
public void write(char[] cbuf) -
write
public void write(char[] cbuf, int off, int len) -
write
public void write(int c) -
write
-
write
-
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.
-