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
ConstructorDescriptionBufferingJsonNodeProcessor
(Consumer<org.reactivestreams.Processor<byte[], io.micronaut.json.tree.JsonNode>> onSubscribe, boolean streamArray) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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)
-
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 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:
onSubscribe
in interfaceorg.reactivestreams.Subscriber<T>
-
onNext
public final void onNext(byte[] t) - Specified by:
onNext
in interfaceorg.reactivestreams.Subscriber<T>
-
onError
- Specified by:
onError
in interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public final void onComplete()- Specified by:
onComplete
in interfaceorg.reactivestreams.Subscriber<T>
-