Class BufferingJsonNodeProcessor

  • All Implemented Interfaces:
    org.reactivestreams.Processor<byte[],​io.micronaut.json.tree.JsonNode>, org.reactivestreams.Publisher<io.micronaut.json.tree.JsonNode>, org.reactivestreams.Subscriber<byte[]>

    @Internal
    public abstract class BufferingJsonNodeProcessor
    extends java.lang.Object
    Utility class for buffering and parsing JSON to support JsonMapper.createReactiveParser(java.util.function.Consumer, boolean).
    Since:
    1.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferingJsonNodeProcessor​(java.util.function.Consumer<org.reactivestreams.Processor<byte[],​io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void complete​(java.util.Collection<io.micronaut.json.tree.JsonNode> out)  
      void onComplete()  
      void onError​(java.lang.Throwable t)  
      void onNext​(T t)  
      void onSubscribe​(org.reactivestreams.Subscription s)  
      protected io.micronaut.json.tree.JsonNode parseOne​(byte[] remaining)
      Parse a single node from the given stream.
      protected abstract io.micronaut.json.tree.JsonNode parseOne​(java.io.InputStream is)
      Parse a single node from the given stream.
      protected void spread​(byte[] bytes, java.util.Collection<io.micronaut.json.tree.JsonNode> out)  
      void subscribe​(org.reactivestreams.Subscriber<? super io.micronaut.json.tree.JsonNode> s)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BufferingJsonNodeProcessor

        public BufferingJsonNodeProcessor​(java.util.function.Consumer<org.reactivestreams.Processor<byte[],​io.micronaut.json.tree.JsonNode>> onSubscribe,
                                          boolean streamArray)
        Default constructor.
        Parameters:
        onSubscribe - The onSubscribe callback.
        streamArray - Whether to stream an array.
    • Method Detail

      • subscribe

        public void subscribe​(org.reactivestreams.Subscriber<? super io.micronaut.json.tree.JsonNode> s)
        Specified by:
        subscribe in interface org.reactivestreams.Publisher<io.micronaut.json.tree.JsonNode>
      • spread

        protected void spread​(byte[] bytes,
                              java.util.Collection<io.micronaut.json.tree.JsonNode> out)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • complete

        protected void complete​(java.util.Collection<io.micronaut.json.tree.JsonNode> out)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • parseOne

        @NonNull
        protected abstract io.micronaut.json.tree.JsonNode parseOne​(@NonNull
                                                                    java.io.InputStream is)
                                                             throws java.io.IOException
        Parse a single node from the given stream.
        Parameters:
        is - The input stream
        Returns:
        The node
        Throws:
        java.io.IOException - if an error occurs
      • parseOne

        @NonNull
        protected io.micronaut.json.tree.JsonNode parseOne​(@NonNull
                                                           byte[] remaining)
                                                    throws java.io.IOException
        Parse a single node from the given stream.
        Parameters:
        remaining - The bytes
        Returns:
        The node
        Throws:
        java.io.IOException - if an error occurs
      • onSubscribe

        public final void onSubscribe​(org.reactivestreams.Subscription s)
        Specified by:
        onSubscribe in interface org.reactivestreams.Subscriber<T>
      • onNext

        public final void onNext​(T t)
        Specified by:
        onNext in interface org.reactivestreams.Subscriber<T>
      • onError

        public final void onError​(java.lang.Throwable t)
        Specified by:
        onError in interface org.reactivestreams.Subscriber<T>
      • onComplete

        public final void onComplete()
        Specified by:
        onComplete in interface org.reactivestreams.Subscriber<T>