com.fasterxml.jackson.jr.ob
Class JSONComposer<T>

java.lang.Object
  extended by com.fasterxml.jackson.jr.ob.comp.ComposerBase
      extended by com.fasterxml.jackson.jr.ob.comp.SequenceComposer<JSONComposer<T>>
          extended by com.fasterxml.jackson.jr.ob.JSONComposer<T>
Type Parameters:
T - Type of result being composed.
All Implemented Interfaces:
Flushable

public class JSONComposer<T>
extends SequenceComposer<JSONComposer<T>>

Root-level composer object that acts as streaming "builder" object, using an underlying JsonGenerator object. This is similar to ArrayComposer, but does not have parent composer (so no end() method), but does implement Closeable


Field Summary
protected  ByteArrayBuilder _byteWriter
           
protected  boolean _closeGenerator
           
protected  int _features
           
protected  T _result
           
protected  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
  JSONComposer(int features, JsonGenerator gen, boolean closeGenerator)
           
protected JSONComposer(int features, JsonGenerator gen, ByteArrayBuilder w)
           
protected JSONComposer(int features, JsonGenerator gen, SegmentedStringWriter w)
           
protected JSONComposer(int features, T result)
           
 
Method Summary
protected  Object _finish()
           
protected  JSONComposer<T> _start()
           
static JSONComposer<byte[]> bytesComposer(int features, JsonGenerator gen, ByteArrayBuilder w)
           
static
<T extends Collection<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<Map<String,Object>> mapComposer(int features, Map<String,Object> map)
           
static
<RESULT> JSONComposer<RESULT>
streamComposer(int features, JsonGenerator gen, boolean closeGenerator)
           
static JSONComposer<String> stringComposer(int features, JsonGenerator gen, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_features

protected final int _features

_closeGenerator

protected final boolean _closeGenerator

_result

protected T _result

_stringWriter

protected SegmentedStringWriter _stringWriter

_byteWriter

protected ByteArrayBuilder _byteWriter
Constructor Detail

JSONComposer

public JSONComposer(int features,
                    JsonGenerator gen,
                    boolean closeGenerator)

JSONComposer

protected JSONComposer(int features,
                       JsonGenerator gen,
                       SegmentedStringWriter w)

JSONComposer

protected JSONComposer(int features,
                       JsonGenerator gen,
                       ByteArrayBuilder w)

JSONComposer

protected JSONComposer(int features,
                       T result)
Method Detail

streamComposer

public static <RESULT> JSONComposer<RESULT> streamComposer(int features,
                                                           JsonGenerator gen,
                                                           boolean closeGenerator)

stringComposer

public static JSONComposer<String> stringComposer(int features,
                                                  JsonGenerator gen,
                                                  SegmentedStringWriter w)

bytesComposer

public static JSONComposer<byte[]> bytesComposer(int features,
                                                 JsonGenerator gen,
                                                 ByteArrayBuilder w)

collectionComposer

public static <T extends Collection<Object>> JSONComposer<T> collectionComposer(int features,
                                                                                T coll)

mapComposer

public static JSONComposer<Map<String,Object>> mapComposer(int features,
                                                           Map<String,Object> map)

finish

public T finish()
         throws IOException,
                JsonProcessingException
Method to call to complete composition, flush any pending content, and return instance of specified result type.

Throws:
IOException
JsonProcessingException

_start

protected JSONComposer<T> _start()
                          throws IOException,
                                 JsonProcessingException
Specified by:
_start in class ComposerBase
Throws:
IOException
JsonProcessingException

_finish

protected Object _finish()
                  throws IOException,
                         JsonProcessingException
Specified by:
_finish in class ComposerBase
Throws:
IOException
JsonProcessingException


Copyright © 2016 FasterXML. All rights reserved.