Class JsonStreamParser
java.lang.Object
com.couchbase.client.core.json.stream.JsonStreamParser
- All Implemented Interfaces:
Closeable
,AutoCloseable
Create an instance with
builder()
. Use the builder to register
JSON pointers and associated callbacks.
Supply the input JSON by calling feed(ByteBuf)
repeatedly.
Close the parser after feeding the last of the data.
Not thread safe.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder instances are reusable provided that ALL configuration of the instance occurs before any call toJsonStreamParser.Builder.build()
. -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonStreamParser.Builder
builder()
Construct new parser instances using the builder returned by this method.void
close()
Releases resources managed by the parser.void
Should be called after last chunk of data to parse has been fed.void
feed
(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf input) Consumes all readable bytes from the given buffer.
-
Method Details
-
builder
Construct new parser instances using the builder returned by this method. -
feed
public void feed(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf input) throws DecodingFailureException Consumes all readable bytes from the given buffer. Searches for values matching the configured JSON pointers and invokes callbacks for any matches.Call this method repeatedly as more input becomes available.
- Throws:
DecodingFailureException
- if malformed JSON is detected in this chunk of input or if a value consumer throws an exception.
-
endOfInput
public void endOfInput()Should be called after last chunk of data to parse has been fed. After calling this method no more data can be fed and parser assumes no more data will be available.- Throws:
DecodingFailureException
- if malformed JSON is detected in this chunk of input.
-
close
public void close()Releases resources managed by the parser.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-