Package com.fasterxml.jackson.jr.ob
Class JSONComposer<T>
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.comp.ComposerBase
-
- com.fasterxml.jackson.jr.ob.comp.SequenceComposer<JSONComposer<T>>
-
- com.fasterxml.jackson.jr.ob.JSONComposer<T>
-
- Type Parameters:
T
- Type of result being composed.
- All Implemented Interfaces:
java.io.Flushable
public class JSONComposer<T> extends SequenceComposer<JSONComposer<T>>
Root-level composer object that acts as streaming "builder" object, using an underlyingJsonGenerator
object. This is similar toArrayComposer
, but does not have parent composer (so noend()
method), but does implementCloseable
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.core.util.ByteArrayBuilder
_byteWriter
protected boolean
_closeGenerator
protected int
_features
protected T
_result
protected com.fasterxml.jackson.core.io.SegmentedStringWriter
_stringWriter
-
Fields inherited from class com.fasterxml.jackson.jr.ob.comp.SequenceComposer
_generator
-
Fields inherited from class com.fasterxml.jackson.jr.ob.comp.ComposerBase
_child, _open
-
-
Constructor Summary
Constructors Modifier Constructor Description JSONComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, boolean closeGenerator)
protected
JSONComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.io.SegmentedStringWriter w)
protected
JSONComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.util.ByteArrayBuilder w)
protected
JSONComposer(int features, T result)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
_finish()
protected JSONComposer<T>
_start()
static JSONComposer<byte[]>
bytesComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.util.ByteArrayBuilder w)
static <T extends java.util.Collection<java.lang.Object>>
JSONComposer<T>collectionComposer(int features, T coll)
T
finish()
Method to call to complete composition, flush any pending content, and return instance of specified result type.static JSONComposer<java.util.Map<java.lang.String,java.lang.Object>>
mapComposer(int features, java.util.Map<java.lang.String,java.lang.Object> map)
static <RESULT> JSONComposer<RESULT>
streamComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, boolean closeGenerator)
static JSONComposer<java.lang.String>
stringComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.io.SegmentedStringWriter w)
-
Methods inherited from class com.fasterxml.jackson.jr.ob.comp.SequenceComposer
_closeChild, _this, add, add, add, add, add, add, addNull, addObject, flush, startArray, startObject
-
Methods inherited from class com.fasterxml.jackson.jr.ob.comp.ComposerBase
_childClosed, _illegalCall, _safeFinish, _startArray, _startCollection, _startMap, _startObject
-
-
-
-
Field Detail
-
_features
protected final int _features
-
_closeGenerator
protected final boolean _closeGenerator
-
_result
protected T _result
-
_stringWriter
protected com.fasterxml.jackson.core.io.SegmentedStringWriter _stringWriter
-
_byteWriter
protected com.fasterxml.jackson.core.util.ByteArrayBuilder _byteWriter
-
-
Constructor Detail
-
JSONComposer
public JSONComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, boolean closeGenerator)
-
JSONComposer
protected JSONComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.io.SegmentedStringWriter w)
-
JSONComposer
protected JSONComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.util.ByteArrayBuilder w)
-
JSONComposer
protected JSONComposer(int features, T result)
-
-
Method Detail
-
streamComposer
public static <RESULT> JSONComposer<RESULT> streamComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, boolean closeGenerator)
-
stringComposer
public static JSONComposer<java.lang.String> stringComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.io.SegmentedStringWriter w)
-
bytesComposer
public static JSONComposer<byte[]> bytesComposer(int features, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.core.util.ByteArrayBuilder w)
-
collectionComposer
public static <T extends java.util.Collection<java.lang.Object>> JSONComposer<T> collectionComposer(int features, T coll)
-
mapComposer
public static JSONComposer<java.util.Map<java.lang.String,java.lang.Object>> mapComposer(int features, java.util.Map<java.lang.String,java.lang.Object> map)
-
finish
public T finish() throws java.io.IOException
Method to call to complete composition, flush any pending content, and return instance of specified result type.- Throws:
java.io.IOException
-
_start
protected JSONComposer<T> _start() throws java.io.IOException
- Specified by:
_start
in classComposerBase
- Throws:
java.io.IOException
-
_finish
protected java.lang.Object _finish() throws java.io.IOException
- Specified by:
_finish
in classComposerBase
- Throws:
java.io.IOException
-
-