Package io.micronaut.serde.support.util
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[]>
Utility class for buffering and parsing JSON to support
JsonMapper.createReactiveParser(java.util.function.Consumer, boolean).- Since:
- 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionBufferingJsonNodeProcessor(Consumer<org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcomplete(Collection<io.micronaut.json.tree.JsonNode> out) final voidfinal voidfinal voidonNext(byte[] t) final voidonSubscribe(org.reactivestreams.Subscription s) protected @NonNull io.micronaut.json.tree.JsonNodeparseOne(@io.micronaut.core.annotation.NonNull byte[] remaining) Parse a single node from the given stream.protected abstract @NonNull io.micronaut.json.tree.JsonNodeparseOne(@NonNull InputStream is) Parse a single node from the given stream.protected voidspread(byte[] bytes, Collection<io.micronaut.json.tree.JsonNode> out) voidsubscribe(org.reactivestreams.Subscriber<? super io.micronaut.json.tree.JsonNode> s)
-
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:
subscribein interfaceorg.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
- 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:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>
-
onNext
public final void onNext(byte[] t) - Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<T>
-
onError
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public final void onComplete()- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<T>
-