public class SequenceWriter extends java.lang.Object implements Versioned, java.io.Closeable, java.io.Flushable
ObjectWriter, except that it can be used
for writing sequences of values, not just a single value.
The main use case is in writing very long sequences, or sequences where
values are incrementally produced; cases where it would be impractical
or at least inconvenient to construct a wrapper container around values
(or where no JSON array is desired around values).
Differences from ObjectWriter include:
SequenceWriter are stateful, and not thread-safe:
if sharing, external synchronization must be used.
close() is needed after all values have been written
(ObjectWriter can auto-close after individual value writes)
| Constructor and Description |
|---|
SequenceWriter(DefaultSerializerProvider prov,
JsonGenerator gen,
boolean closeGenerator,
ObjectWriter.Prefetch prefetch) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
SequenceWriter |
init(boolean wrapInArray)
Internal method called by
ObjectWriter: should not be called by code
outside jackson-databind classes. |
Version |
version()
Method that will return version information stored in and read from jar
that contains this class.
|
SequenceWriter |
write(java.lang.Object value)
Method for writing given value into output, as part of sequence
to write.
|
SequenceWriter |
write(java.lang.Object value,
JavaType type)
Method for writing given value into output, as part of sequence
to write; further, full type (often generic, like
Map
is passed in case a new
JsonSerializer needs to be fetched to handle type
If root type was specified for ObjectWriter,
value must be of compatible type (same or subtype). |
<C extends java.util.Collection<?>> |
writeAll(C container) |
SequenceWriter |
writeAll(java.lang.Iterable<?> iterable) |
SequenceWriter |
writeAll(java.lang.Object[] value) |
public SequenceWriter(DefaultSerializerProvider prov, JsonGenerator gen, boolean closeGenerator, ObjectWriter.Prefetch prefetch) throws java.io.IOException
java.io.IOExceptionpublic SequenceWriter init(boolean wrapInArray) throws java.io.IOException
ObjectWriter: should not be called by code
outside jackson-databind classes.java.io.IOExceptionpublic Version version()
public SequenceWriter write(java.lang.Object value) throws java.io.IOException
ObjectWriter,
value must be of compatible type (same or subtype).java.io.IOExceptionpublic SequenceWriter write(java.lang.Object value, JavaType type) throws java.io.IOException
Map
is passed in case a new
JsonSerializer needs to be fetched to handle type
If root type was specified for ObjectWriter,
value must be of compatible type (same or subtype).java.io.IOExceptionpublic SequenceWriter writeAll(java.lang.Object[] value) throws java.io.IOException
java.io.IOExceptionpublic <C extends java.util.Collection<?>> SequenceWriter writeAll(C container) throws java.io.IOException
java.io.IOExceptionpublic SequenceWriter writeAll(java.lang.Iterable<?> iterable) throws java.io.IOException
java.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushablejava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionCopyright © 2010 - 2023 Adobe. All Rights Reserved