Top Description Fields Constructors Methods
com.fasterxml.jackson.databind

public Class SequenceWriter

extends Object
implements Versioned, Closeable, Flushable
Class Inheritance
All Implemented Interfaces
java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable, com.fasterxml.jackson.core.Versioned
Imports
java.io.Closeable, .IOException, java.util.Collection, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.ser.DefaultSerializerProvider, com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap, .TypeWrappedSerializer

Writer class similar to 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:

Since
2.5

Field Summary

Modifier and TypeField and Description
protected final boolean
protected final boolean
protected boolean
protected final boolean
protected final SerializationConfig
protected PropertySerializerMap
_dynamicSerializers

If _rootSerializer is not defined (no root type was used for constructing ObjectWriter), we will use simple scheme for keeping track of serializers needed.

protected final JsonGenerator
protected boolean
_openArray

State flag for keeping track of need to write matching END_ARRAY, if a START_ARRAY was written during initialization

protected final DefaultSerializerProvider
protected final JsonSerializer<Object>
protected final TypeSerializer

Constructor Summary

AccessConstructor and Description
public
SequenceWriter(DefaultSerializerProvider prov, JsonGenerator gen, boolean closeGenerator, ObjectWriter.Prefetch prefetch)

Method Summary

Modifier and TypeMethod and Description
private final JsonSerializer<Object>
private final JsonSerializer<Object>
protected SequenceWriter
protected SequenceWriter
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public void
flush()

Implements java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.
public SequenceWriter
init(boolean wrapInArray)

Internal method called by ObjectWriter: should not be called by code outside jackson-databind classes.

public Version
version()

Implements com.fasterxml.jackson.core.Versioned.version.

Method that will return version information stored in and read from jar that contains this class.
public SequenceWriter
write(Object value)

Method for writing given value into output, as part of sequence to write.

public SequenceWriter
write(Object value, JavaType type)

Method for writing given value into output, as part of sequence to write; further, full type (often generic, like java.util.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).

public SequenceWriter
writeAll(Object[] value)

public <C extends Collection<?>> SequenceWriter
writeAll(C container)

public SequenceWriter
writeAll(Iterable<?> iterable)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_cfgCloseCloseableback to summary
protected final boolean _cfgCloseCloseable
_cfgFlushback to summary
protected final boolean _cfgFlush
_closedback to summary
protected boolean _closed
_closeGeneratorback to summary
protected final boolean _closeGenerator
_configback to summary
protected final SerializationConfig _config
_dynamicSerializersback to summary
protected PropertySerializerMap _dynamicSerializers

If _rootSerializer is not defined (no root type was used for constructing ObjectWriter), we will use simple scheme for keeping track of serializers needed. Assumption is that

_generatorback to summary
protected final JsonGenerator _generator
_openArrayback to summary
protected boolean _openArray

State flag for keeping track of need to write matching END_ARRAY, if a START_ARRAY was written during initialization

_providerback to summary
protected final DefaultSerializerProvider _provider
_rootSerializerback to summary
protected final JsonSerializer<Object> _rootSerializer
_typeSerializerback to summary
protected final TypeSerializer _typeSerializer

Constructor Detail

SequenceWriterback to summary
public SequenceWriter(DefaultSerializerProvider prov, JsonGenerator gen, boolean closeGenerator, ObjectWriter.Prefetch prefetch) throws IOException

Method Detail

_findAndAddDynamicback to summary
private final JsonSerializer<Object> _findAndAddDynamic(Class<?> type) throws JsonMappingException
_findAndAddDynamicback to summary
private final JsonSerializer<Object> _findAndAddDynamic(JavaType type) throws JsonMappingException
_writeCloseableValueback to summary
protected SequenceWriter _writeCloseableValue(Object value) throws IOException
_writeCloseableValueback to summary
protected SequenceWriter _writeCloseableValue(Object value, JavaType type) throws IOException
closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements java.io.Flushable.flush.

Doc from java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
initback to summary
public SequenceWriter init(boolean wrapInArray) throws IOException

Internal method called by ObjectWriter: should not be called by code outside jackson-databind classes.

versionback to summary
public Version version()

Implements com.fasterxml.jackson.core.Versioned.version.

Method that will return version information stored in and read from jar that contains this class.

Returns:Version

Doc from com.fasterxml.jackson.core.Versioned.version.

Version of the component

Annotations
@Override
writeback to summary
public SequenceWriter write(Object value) throws IOException

Method for writing given value into output, as part of sequence to write. If root type was specified for ObjectWriter, value must be of compatible type (same or subtype).

writeback to summary
public SequenceWriter write(Object value, JavaType type) throws IOException

Method for writing given value into output, as part of sequence to write; further, full type (often generic, like java.util.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).

writeAllback to summary
public SequenceWriter writeAll(Object[] value) throws IOException
writeAllback to summary
public <C extends Collection<?>> SequenceWriter writeAll(C container) throws IOException
writeAllback to summary
public SequenceWriter writeAll(Iterable<?> iterable) throws IOException
Since
2.7