Class BufferingJsonNodeProcessor

java.lang.Object
io.micronaut.serde.support.util.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 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(Consumer<org.reactivestreams.Processor<byte[],io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray)
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    complete(Collection<io.micronaut.json.tree.JsonNode> out)
     
    final void
     
    final void
     
    final void
    onNext(byte[] t)
     
    final void
    onSubscribe(org.reactivestreams.Subscription s)
     
    protected @NonNull io.micronaut.json.tree.JsonNode
    parseOne(@io.micronaut.core.annotation.NonNull byte[] remaining)
    Parse a single node from the given stream.
    protected abstract @NonNull io.micronaut.json.tree.JsonNode
    parseOne(@NonNull InputStream is)
    Parse a single node from the given stream.
    protected void
    spread(byte[] bytes, 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 Details

    • BufferingJsonNodeProcessor

      public BufferingJsonNodeProcessor(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 Details

    • 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, Collection<io.micronaut.json.tree.JsonNode> out) throws IOException
      Throws:
      IOException
    • complete

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

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

      @NonNull protected @NonNull io.micronaut.json.tree.JsonNode parseOne(@NonNull @io.micronaut.core.annotation.NonNull byte[] remaining) throws IOException
      Parse a single node from the given stream.
      Parameters:
      remaining - The bytes
      Returns:
      The node
      Throws:
      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(byte[] t)
      Specified by:
      onNext in interface org.reactivestreams.Subscriber<T>
    • onError

      public final void onError(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>