Package co.arago.util.json.streaming
Class AccumulatingJsonStreamParser
- java.lang.Object
-
- co.arago.util.json.AbstractJsonParser
-
- co.arago.util.json.streaming.AbstractJsonStreamParser
-
- co.arago.util.json.streaming.AccumulatingJsonStreamParser
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class AccumulatingJsonStreamParser extends AbstractJsonStreamParser implements java.lang.AutoCloseable
A json reader that receives chunks of json data and accumulates them in a non-blocking-parser until a chunk of json data defined by jsonPath is ready to be processed. Calls the callback with the chunk of JSON data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAccumulatingJsonStreamParser.Builderstatic classAccumulatingJsonStreamParser.Conf<T extends AccumulatingJsonStreamParser.Conf<T>>-
Nested classes/interfaces inherited from class co.arago.util.json.streaming.AbstractJsonStreamParser
AbstractJsonStreamParser.CallbackJsonPathListener
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.charset.Charsetcharsetprotected org.jsfr.json.NonBlockingParserparserReference to the parser that is used here-
Fields inherited from class co.arago.util.json.streaming.AbstractJsonStreamParser
callback
-
Fields inherited from class co.arago.util.json.AbstractJsonParser
jsonCuts, jsonSurferTool
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAccumulatingJsonStreamParser(AccumulatingJsonStreamParser.Conf<?> builder)Protected constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Tell the parser that all data for it has ended.voidfeed(byte[] data)Add data to the parser.voidfeed(java.lang.String data)Add data to the parser.static AccumulatingJsonStreamParser.Conf<?>newBuilder(JsonStreamCallback callback)Get Builder-
Methods inherited from class co.arago.util.json.streaming.AbstractJsonStreamParser
createSurfingConfiguration
-
-
-
-
Constructor Detail
-
AccumulatingJsonStreamParser
protected AccumulatingJsonStreamParser(AccumulatingJsonStreamParser.Conf<?> builder)
Protected constructor- Parameters:
builder- The builder for this class.
-
-
Method Detail
-
newBuilder
public static AccumulatingJsonStreamParser.Conf<?> newBuilder(JsonStreamCallback callback)
Get Builder- Parameters:
callback- Callback for the matching keys (JsonPath) ofAbstractJsonParser.jsonCuts.- Returns:
- New instance of
AccumulatingJsonStreamParser.Builder
-
feed
public void feed(java.lang.String data)
Add data to the parser.- Parameters:
data- Incoming data for the parser.
-
feed
public void feed(byte[] data)
Add data to the parser.- Parameters:
data- Incoming data for the parser as byte[]. Ignores the charset.
-
close
public void close() throws java.lang.ExceptionTell the parser that all data for it has ended.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.lang.Exception
-
-