Class JsonStreamParser
- java.lang.Object
-
- com.couchbase.client.core.json.stream.JsonStreamParser
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class JsonStreamParser extends Object implements Closeable
Create an instance withbuilder()
. 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
Nested Classes Modifier and Type Class Description static class
JsonStreamParser.Builder
Builder instances are reusable provided that ALL configuration of the instance occurs before any call toJsonStreamParser.Builder.build()
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonStreamParser.Builder
builder()
Construct new parser instances using the builder returned by this method.void
close()
Releases resources managed by the parser.void
endOfInput()
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 Detail
-
builder
public static JsonStreamParser.Builder 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
-
-