Class JsonParser
- java.lang.Object
-
- io.vertx.mutiny.core.parsetools.JsonParser
-
- All Implemented Interfaces:
io.vertx.core.Handler<Buffer>
,ReadStream<JsonEvent>
,StreamBase
,Consumer<Buffer>
public class JsonParser extends Object implements ReadStream<JsonEvent>, io.vertx.core.Handler<Buffer>, Consumer<Buffer>
A parser class which allows to incrementally parse json elements and emit json parse events instead of parsing a json element fully. This parser is convenient for parsing large json structures. The parser also parses concatenated json streams or line delimited json streams. The parser can also parse entire object or array when it is convenient, for instance a very large array of small objects can be parsed efficiently by handling array start/end and object events. Whenever the parser fails to parse or process the stream, theexceptionHandler(java.util.function.Consumer<java.lang.Throwable>)
is called with the cause of the failure and the current handling stops. After such event, the parser should not handle data anymore. NOTE: This class has been automatically generated from theoriginal
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<JsonParser>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description JsonParser(io.vertx.core.parsetools.JsonParser delegate)
JsonParser(Object delegate)
-
Method Summary
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<JsonParser> __TYPE_ARG
-
-
Constructor Detail
-
JsonParser
public JsonParser(io.vertx.core.parsetools.JsonParser delegate)
-
JsonParser
public JsonParser(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.core.parsetools.JsonParser getDelegate()
- Specified by:
getDelegate
in interfaceReadStream<JsonEvent>
- Specified by:
getDelegate
in interfaceStreamBase
-
handle
public void handle(Buffer event)
- Specified by:
handle
in interfaceio.vertx.core.Handler<Buffer>
- Parameters:
event
- the event to handle
-
pipe
public Pipe<JsonEvent> pipe()
- Specified by:
pipe
in interfaceReadStream<JsonEvent>
- Returns:
- a pipe
-
pipeTo
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<JsonEvent> dst)
Pipe thisReadStream
to theWriteStream
.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the
handler
will be called with the result.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
pipeTo
in interfaceReadStream<JsonEvent>
- Parameters:
dst
- the destination write stream- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
public Void pipeToAndAwait(WriteStream<JsonEvent> dst)
Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
pipeToAndAwait
in interfaceReadStream<JsonEvent>
- Parameters:
dst
- the destination write stream- Returns:
- the Void instance produced by the operation.
-
pipeToAndForget
public void pipeToAndForget(WriteStream<JsonEvent> dst)
Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.This method subscribes on the result of
ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
but you don't need to compose it with other operations.- Specified by:
pipeToAndForget
in interfaceReadStream<JsonEvent>
- Parameters:
dst
- the destination write stream
-
newParser
public static JsonParser newParser()
- Returns:
-
newParser
public static JsonParser newParser(ReadStream<Buffer> stream)
- Parameters:
stream
-- Returns:
-
newParser
public static JsonParser newParser(org.reactivestreams.Publisher<Buffer> stream)
- Parameters:
stream
-- Returns:
-
write
public JsonParser write(Buffer buffer)
- Parameters:
buffer
-- Returns:
- a reference to this, so the API can be used fluently
-
end
public void end()
-
objectEventMode
public JsonParser objectEventMode()
- Returns:
- a reference to this, so the API can be used fluently
-
objectValueMode
public JsonParser objectValueMode()
- Returns:
- a reference to this, so the API can be used fluently
-
arrayEventMode
public JsonParser arrayEventMode()
- Returns:
- a reference to this, so the API can be used fluently
-
arrayValueMode
public JsonParser arrayValueMode()
- Returns:
- a reference to this, so the API can be used fluently
-
pause
public JsonParser pause()
- Specified by:
pause
in interfaceReadStream<JsonEvent>
- Returns:
- a reference to this, so the API can be used fluently
-
resume
public JsonParser resume()
- Specified by:
resume
in interfaceReadStream<JsonEvent>
- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public JsonParser fetch(long amount)
- Specified by:
fetch
in interfaceReadStream<JsonEvent>
- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public JsonParser endHandler(Runnable endHandler)
- Specified by:
endHandler
in interfaceReadStream<JsonEvent>
- Returns:
-
handler
public JsonParser handler(Consumer<JsonEvent> handler)
- Specified by:
handler
in interfaceReadStream<JsonEvent>
- Returns:
-
exceptionHandler
public JsonParser exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandler
in interfaceReadStream<JsonEvent>
- Specified by:
exceptionHandler
in interfaceStreamBase
- Parameters:
handler
- the exception handler- Returns:
-
toMulti
@CheckReturnValue public io.smallrye.mutiny.Multi<JsonEvent> toMulti()
- Specified by:
toMulti
in interfaceReadStream<JsonEvent>
-
newInstance
public static JsonParser newInstance(io.vertx.core.parsetools.JsonParser arg)
-
-