Class NonBlockingJsonParser
- java.lang.Object
-
- com.fasterxml.jackson.core.JsonParser
-
- com.fasterxml.jackson.core.base.ParserMinimalBase
-
- com.fasterxml.jackson.core.base.ParserBase
-
- com.fasterxml.jackson.core.json.async.NonBlockingJsonParserBase
-
- com.fasterxml.jackson.core.json.async.NonBlockingJsonParser
-
- All Implemented Interfaces:
ByteArrayFeeder
,NonBlockingInputFeeder
,Versioned
,java.io.Closeable
,java.lang.AutoCloseable
public class NonBlockingJsonParser extends NonBlockingJsonParserBase implements ByteArrayFeeder
Non-blocking parser implementation for JSON content.NOTE: only supports parsing of UTF-8 encoded content (and 7-bit US-ASCII since it is strict subset of UTF-8): other encodings are not supported.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonParser
JsonParser.Feature, JsonParser.NumberType
-
-
Constructor Summary
Constructors Constructor Description NonBlockingJsonParser(IOContext ctxt, int parserFeatures, ByteQuadsCanonicalizer sym)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endOfInput()
Method that should be called after last chunk of data to parse has been fed (withfeedInput
in sub-class); can be called regardless of whatNonBlockingInputFeeder.needMoreInput()
returns.void
feedInput(byte[] buf, int start, int end)
Method that can be called to feed more data, if (and only if)NonBlockingInputFeeder.needMoreInput()
returns true.ByteArrayFeeder
getNonBlockingInputFeeder()
Method that will either return a feeder instance (if parser uses non-blocking, aka asynchronous access); ornull
for parsers that use blocking I/O.boolean
needMoreInput()
Method called to check whether it is ok to feed more data: parser returns true if it has no more content to parse (and it is ok to feed more); otherwise false (and no data should yet be fed).JsonToken
nextToken()
Main iteration method, which will advance stream enough to determine type of the next token, if any.int
releaseBuffered(java.io.OutputStream out)
Method that can be called to push back any content that has been read but not consumed by the parser.-
Methods inherited from class com.fasterxml.jackson.core.json.async.NonBlockingJsonParserBase
canParseAsync, getBinaryValue, getCodec, getCurrentLocation, getEmbeddedObject, getInputSource, getReadCapabilities, getText, getText, getTextCharacters, getTextLength, getTextOffset, getTokenLocation, getValueAsString, getValueAsString, hasTextCharacters, readBinaryValue, setCodec
-
Methods inherited from class com.fasterxml.jackson.core.base.ParserBase
_getByteArrayBuilder, close, disable, enable, getBigIntegerValue, getCurrentName, getCurrentValue, getDecimalValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getNumberType, getNumberValue, getNumberValueExact, getParsingContext, getTokenCharacterOffset, getTokenColumnNr, getTokenLineNr, isClosed, isNaN, overrideCurrentName, overrideStdFeatures, setCurrentValue, setFeatureMask, version
-
Methods inherited from class com.fasterxml.jackson.core.base.ParserMinimalBase
clearCurrentToken, currentToken, currentTokenId, getCurrentToken, getCurrentTokenId, getLastClearedToken, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, hasCurrentToken, hasToken, hasTokenId, isExpectedNumberIntToken, isExpectedStartArrayToken, isExpectedStartObjectToken, nextValue, skipChildren
-
Methods inherited from class com.fasterxml.jackson.core.JsonParser
assignCurrentValue, canReadObjectId, canReadTypeId, canUseSchema, configure, currentLocation, currentName, currentTokenLocation, currentValue, finishToken, getBinaryValue, getBooleanValue, getByteValue, getFeatureMask, getFormatFeatures, getObjectId, getSchema, getShortValue, getTypeId, getValueAsBoolean, getValueAsDouble, isEnabled, isEnabled, nextBooleanValue, nextFieldName, nextFieldName, nextIntValue, nextLongValue, nextTextValue, overrideFormatFeatures, readBinaryValue, readValueAs, readValueAs, readValueAsTree, readValuesAs, readValuesAs, releaseBuffered, requiresCustomCodec, setRequestPayloadOnError, setRequestPayloadOnError, setRequestPayloadOnError, setSchema
-
-
-
-
Constructor Detail
-
NonBlockingJsonParser
public NonBlockingJsonParser(IOContext ctxt, int parserFeatures, ByteQuadsCanonicalizer sym)
-
-
Method Detail
-
getNonBlockingInputFeeder
public ByteArrayFeeder getNonBlockingInputFeeder()
Description copied from class:JsonParser
Method that will either return a feeder instance (if parser uses non-blocking, aka asynchronous access); ornull
for parsers that use blocking I/O.- Overrides:
getNonBlockingInputFeeder
in classJsonParser
- Returns:
- Input feeder to use with non-blocking (async) parsing
-
needMoreInput
public final boolean needMoreInput()
Description copied from interface:NonBlockingInputFeeder
Method called to check whether it is ok to feed more data: parser returns true if it has no more content to parse (and it is ok to feed more); otherwise false (and no data should yet be fed).- Specified by:
needMoreInput
in interfaceNonBlockingInputFeeder
- Returns:
True
if more input is needed (and can be fed);false
if there is still some input to decode
-
feedInput
public void feedInput(byte[] buf, int start, int end) throws java.io.IOException
Description copied from interface:ByteArrayFeeder
Method that can be called to feed more data, if (and only if)NonBlockingInputFeeder.needMoreInput()
returns true.- Specified by:
feedInput
in interfaceByteArrayFeeder
- Parameters:
buf
- Byte array that contains data to feed: caller must ensure data remains stable until it is fully processed (which is true whenNonBlockingInputFeeder.needMoreInput()
returns true)start
- Offset within array where input data to process startsend
- Offset after last byte contained in the input array- Throws:
java.io.IOException
- if the state is such that this method should not be called (has not yet consumed existing input data, or has been marked as closed)
-
endOfInput
public void endOfInput()
Description copied from interface:NonBlockingInputFeeder
Method that should be called after last chunk of data to parse has been fed (withfeedInput
in sub-class); can be called regardless of whatNonBlockingInputFeeder.needMoreInput()
returns. After calling this method, no more data can be fed; and parser assumes no more data will be available.- Specified by:
endOfInput
in interfaceNonBlockingInputFeeder
-
releaseBuffered
public int releaseBuffered(java.io.OutputStream out) throws java.io.IOException
Description copied from class:JsonParser
Method that can be called to push back any content that has been read but not consumed by the parser. This is usually done after reading all content of interest using parser. Content is released by writing it to given stream if possible; if underlying input is byte-based it can released, if not (char-based) it can not.- Specified by:
releaseBuffered
in classNonBlockingJsonParserBase
- Parameters:
out
- OutputStream to which buffered, undecoded content is written to- Returns:
- -1 if the underlying content source is not byte based
(that is, input can not be sent to
OutputStream
; otherwise number of bytes released (0 if there was nothing to release) - Throws:
java.io.IOException
- if write to stream threw exception
-
nextToken
public JsonToken nextToken() throws java.io.IOException
Description copied from class:JsonParser
Main iteration method, which will advance stream enough to determine type of the next token, if any. If none remaining (stream has no content other than possible white space before ending), null will be returned.- Specified by:
nextToken
in classParserMinimalBase
- Returns:
- Next token from the stream, if any found, or null to indicate end-of-input
- Throws:
java.io.IOException
- for low-level read issues, orJsonParseException
for decoding problems
-
-