Package org.cometd.common
Class BufferingJSONAsyncParser
- java.lang.Object
-
- org.cometd.common.BufferingJSONAsyncParser
-
- All Implemented Interfaces:
JSONContext.AsyncParser
public class BufferingJSONAsyncParser extends java.lang.Object implements JSONContext.AsyncParser
A
JSONContext.AsyncParserthat parses an array of Bayeux messages.This is not a generic parser that can parse any JSON.
This parser buffers all input bytes in memory, and performs blocking JSON parsing via
JSONContext.parse(String)only whencomplete()is called.
-
-
Constructor Summary
Constructors Constructor Description BufferingJSONAsyncParser(JSONContext<? extends Message.Mutable> jsonContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Rcomplete()Signals the end of the JSON string content to this parser and returns the parsed object.voidparse(byte[] bytes, int offset, int length)voidparse(java.nio.ByteBuffer byteBuffer)
-
-
-
Constructor Detail
-
BufferingJSONAsyncParser
public BufferingJSONAsyncParser(JSONContext<? extends Message.Mutable> jsonContext)
-
-
Method Detail
-
parse
public void parse(byte[] bytes, int offset, int length)- Specified by:
parsein interfaceJSONContext.AsyncParser- Parameters:
bytes- the bytes chunk to parseoffset- the offset to start parsing fromlength- the number of bytes to parse
-
parse
public void parse(java.nio.ByteBuffer byteBuffer)
- Specified by:
parsein interfaceJSONContext.AsyncParser- Parameters:
byteBuffer- the buffer chunk to parse
-
complete
public <R> R complete()
Description copied from interface:JSONContext.AsyncParserSignals the end of the JSON string content to this parser and returns the parsed object.
- Specified by:
completein interfaceJSONContext.AsyncParser- Type Parameters:
R- the type to cast the result to- Returns:
- the result of the JSON parsing
-
-