Class 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 underlying JsonGenerator object. This is similar to ArrayComposer, but does not have parent composer (so no end() method), but does implement Closeable
    • 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
      • _finish

        protected java.lang.Object _finish()
                                    throws java.io.IOException
        Specified by:
        _finish in class ComposerBase
        Throws:
        java.io.IOException