Top Fields Constructors Methods
com.fasterxml.jackson.dataformat.smile.async

public Class NonBlockingByteArrayParser

extends NonBlockingParserBase
implements ByteArrayFeeder
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.async.ByteArrayFeeder, com.fasterxml.jackson.core.async.NonBlockingInputFeeder
Imports
java.io.IOException, .OutputStream, java.math.BigDecimal, .BigInteger, java.util.Arrays, com.fasterxml.jackson.core.JsonToken, com.fasterxml.jackson.core.async.ByteArrayFeeder, .NonBlockingInputFeeder, com.fasterxml.jackson.core.io.IOContext, com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer, com.fasterxml.jackson.core.util.VersionUtil, com.fasterxml.jackson.dataformat.smile.SmileConstants, .SmileParser, .SmileUtil

Field Summary

Modifier and TypeField and Description
protected byte[]
_inputBuffer

This buffer is actually provided via NonBlockingInputFeeder

protected int
_origBufferLen

In addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained.

Inherited from com.fasterxml.jackson.dataformat.smile.async.NonBlockingParserBase:
_byteArrayBuilder_endOfInput_inputCopy_inputCopyLen_majorState_majorStateAfterValue_minorState_pending32_pending64MAJOR_ARRAY_ELEMENTMAJOR_CLOSEDMAJOR_INITIALMAJOR_OBJECT_FIELDMAJOR_OBJECT_VALUEMAJOR_ROOTMINOR_FIELD_NAME_2BYTEMINOR_FIELD_NAME_LONGMINOR_FIELD_NAME_SHORT_ASCIIMINOR_FIELD_NAME_SHORT_UNICODEMINOR_HEADER_INITIALMINOR_HEADER_INLINEMINOR_VALUE_BINARY_7BIT_BODYMINOR_VALUE_BINARY_7BIT_LENMINOR_VALUE_BINARY_RAW_BODYMINOR_VALUE_BINARY_RAW_LENMINOR_VALUE_NUMBER_BIGDEC_BODYMINOR_VALUE_NUMBER_BIGDEC_LENMINOR_VALUE_NUMBER_BIGDEC_SCALEMINOR_VALUE_NUMBER_BIGINT_BODYMINOR_VALUE_NUMBER_BIGINT_LENMINOR_VALUE_NUMBER_DOUBLEMINOR_VALUE_NUMBER_FLOATMINOR_VALUE_NUMBER_INTMINOR_VALUE_NUMBER_LONGMINOR_VALUE_STRING_LONG_ASCIIMINOR_VALUE_STRING_LONG_UNICODEMINOR_VALUE_STRING_SHARED_2BYTEMINOR_VALUE_STRING_SHORT_ASCIIMINOR_VALUE_STRING_SHORT_UNICODE

Constructor Summary

AccessConstructor and Description
public
NonBlockingByteArrayParser(IOContext ctxt, int parserFeatures, int smileFeatures, ByteQuadsCanonicalizer sym)

Method Summary

Modifier and TypeMethod and Description
private final boolean
protected final boolean
_decode7BitEncodedTail(int bytesToDecode, int buffered)

private final String
_decodeASCIIText(byte[] inBuf, int inPtr, int len)

private final String
_decodeLongUnicodeName(byte[] inBuf, int inPtr, int len)

private final String
_decodeShortUnicodeText(byte[] inBuf, int inPtr, int
Length between 1 and 64
len
)

Helper method used to decode short Unicode string, length for which actual length (in bytes) is known

private final int
_decodeUTF8_2(int c, int d)

private final int
_decodeUTF8_3(int c, int d, int e)

private final int
_decodeUTF8_4(int c, int d, int e, int f)

private final int
private final JsonToken
private final JsonToken
_finish7BitBinaryLen(int value, int bytesRead)

private final JsonToken
private final JsonToken
_finishBigDecimalLen(int value, int bytesRead)

private final JsonToken
_finishBigDecimalScale(int value, int bytesRead)

private final JsonToken
private final JsonToken
_finishBigIntLen(int value, int bytesRead)

protected final JsonToken
_finishDouble(long value, int bytesRead)

protected final JsonToken
_finishFloat(int value, int bytesRead)

protected JsonToken
_finishHeader(int state)

Helper method that will decode information from a header block that has been detected.

private final JsonToken
_finishInt(int value, int bytesRead)

private final JsonToken
_finishLong(long value, int bytesRead)

private final JsonToken
private final JsonToken
private final JsonToken
private final boolean
private final JsonToken
private final JsonToken
_finishRawBinaryLen(int value, int bytesRead)

protected final JsonToken
_finishToken()

Method called when a (scalar) value type has been detected, but not all of contents have been decoded due to incomplete input available.

private final int
_fourBytesToInt(int ptr)

private final JsonToken
private final JsonToken
private final JsonToken
protected final JsonToken
protected final JsonToken
_startFieldName(int ch)

Method that handles initial token type recognition for token that has to be either FIELD_NAME or END_OBJECT.

protected final JsonToken
private final JsonToken
private final JsonToken
private final JsonToken
protected final JsonToken
protected final JsonToken
private final JsonToken
_startShortASCII(final int len)

private final JsonToken
_startShortUnicode(final int len)

private final JsonToken
_startValue(int ch)

Helper method called to detect type of a value token (at any level), and possibly decode it if contained in input buffer.

public void
endOfInput()

Implements com.fasterxml.jackson.core.async.NonBlockingInputFeeder.endOfInput.

Method that should be called after last chunk of data to parse has been fed (with feedInput in sub-class); can be called regardless of what needMoreInput returns.
public void
feedInput(byte[]
Byte array that contains data to feed: caller must ensure data remains stable until it is fully processed (which is true when needMoreInput returns true)
buf
,
int
Offset within array where input data to process starts
start
,
int
Offset after last byte contained in the input array
end
)

Implements com.fasterxml.jackson.core.async.ByteArrayFeeder.feedInput.

Method that can be called to feed more data, if (and only if) needMoreInput returns true.
public ByteArrayFeeder
getNonBlockingInputFeeder()

Overrides com.fasterxml.jackson.core.JsonParser.getNonBlockingInputFeeder.

Method that will either return a feeder instance (if parser uses non-blocking, aka asynchronous access); or null for parsers that use blocking I/O.
public final boolean
needMoreInput()

Implements com.fasterxml.jackson.core.async.NonBlockingInputFeeder.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).
public JsonToken
nextToken()

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any.
public int
releaseBuffered(OutputStream
OutputStream to which buffered, undecoded content is written to
out
)

Implements abstract com.fasterxml.jackson.dataformat.smile.async.NonBlockingParserBase.releaseBuffered.

Method that can be called to push back any content that has been read but not consumed by the parser.
Inherited from com.fasterxml.jackson.dataformat.smile.async.NonBlockingParserBase:
_addDecodedToSymbols_addSeenStringValue_closeArrayScope_closeInput_closeObjectScope_eofAsNextToken_expandSeenNames_findDecodedFromSymbols_handleSharedName_handleSharedString_initByteArrayBuilder_parseNumericValue_releaseBuffers2_reportInvalidInitial_reportInvalidOther_reportInvalidSharedName_reportInvalidSharedStringValue_reportMissingHeader_startArrayScope_startObjectScope_valueCompletecanParseAsyncgetBinaryValuegetCodecgetEmbeddedObjectgetInputSourcegetTextgetTextgetTextCharactersgetTextLengthgetTextOffsethasTextCharactersreadBinaryValuesetCodecsymbolTableForTests

Field Detail

_inputBufferback to summary
protected byte[] _inputBuffer

This buffer is actually provided via NonBlockingInputFeeder

_origBufferLenback to summary
protected int _origBufferLen

In addition to current buffer pointer, and end pointer, we will also need to know number of bytes originally contained. This is needed to correctly update location information when the block has been completed.

Constructor Detail

NonBlockingByteArrayParserback to summary
public NonBlockingByteArrayParser(IOContext ctxt, int parserFeatures, int smileFeatures, ByteQuadsCanonicalizer sym)

Method Detail

_decode7BitEncodedback to summary
private final boolean _decode7BitEncoded() throws IOException
_decode7BitEncodedTailback to summary
protected final boolean _decode7BitEncodedTail(int bytesToDecode, int buffered) throws IOException
_decodeASCIITextback to summary
private final String _decodeASCIIText(byte[] inBuf, int inPtr, int len) throws IOException
_decodeLongUnicodeNameback to summary
private final String _decodeLongUnicodeName(byte[] inBuf, int inPtr, int len) throws IOException
_decodeShortUnicodeTextback to summary
private final String _decodeShortUnicodeText(byte[] inBuf, int inPtr, int len) throws IOException

Helper method used to decode short Unicode string, length for which actual length (in bytes) is known

Parameters
len:int

Length between 1 and 64

_decodeUTF8_2back to summary
private final int _decodeUTF8_2(int c, int d) throws IOException
_decodeUTF8_3back to summary
private final int _decodeUTF8_3(int c, int d, int e) throws IOException
_decodeUTF8_4back to summary
private final int _decodeUTF8_4(int c, int d, int e, int f) throws IOException
_decodeVIntback to summary
private final int _decodeVInt() throws IOException
_finish7BitBinaryBodyback to summary
private final JsonToken _finish7BitBinaryBody() throws IOException
_finish7BitBinaryLenback to summary
private final JsonToken _finish7BitBinaryLen(int value, int bytesRead) throws IOException
_finishBigDecimalBodyback to summary
private final JsonToken _finishBigDecimalBody() throws IOException
_finishBigDecimalLenback to summary
private final JsonToken _finishBigDecimalLen(int value, int bytesRead) throws IOException
_finishBigDecimalScaleback to summary
private final JsonToken _finishBigDecimalScale(int value, int bytesRead) throws IOException
_finishBigIntBodyback to summary
private final JsonToken _finishBigIntBody() throws IOException
_finishBigIntLenback to summary
private final JsonToken _finishBigIntLen(int value, int bytesRead) throws IOException
_finishDoubleback to summary
protected final JsonToken _finishDouble(long value, int bytesRead) throws IOException
_finishFloatback to summary
protected final JsonToken _finishFloat(int value, int bytesRead) throws IOException
_finishHeaderback to summary
protected JsonToken _finishHeader(int state) throws IOException

Helper method that will decode information from a header block that has been detected.

_finishIntback to summary
private final JsonToken _finishInt(int value, int bytesRead) throws IOException
_finishLongback to summary
private final JsonToken _finishLong(long value, int bytesRead) throws IOException
_finishLongASCIIback to summary
private final JsonToken _finishLongASCII() throws IOException
_finishLongFieldNameback to summary
private final JsonToken _finishLongFieldName(int outPtr) throws IOException
_finishLongUnicodeback to summary
private final JsonToken _finishLongUnicode() throws IOException
_finishPartialUnicodeCharback to summary
private final boolean _finishPartialUnicodeChar() throws IOException
_finishRawBinaryBodyback to summary
private final JsonToken _finishRawBinaryBody() throws IOException
_finishRawBinaryLenback to summary
private final JsonToken _finishRawBinaryLen(int value, int bytesRead) throws IOException
_finishTokenback to summary
protected final JsonToken _finishToken() throws IOException

Method called when a (scalar) value type has been detected, but not all of contents have been decoded due to incomplete input available.

_fourBytesToIntback to summary
private final int _fourBytesToInt(int ptr) throws IOException
_start7BitBinaryback to summary
private final JsonToken _start7BitBinary() throws IOException
_startBigDecimalback to summary
private final JsonToken _startBigDecimal() throws IOException
_startBigIntback to summary
private final JsonToken _startBigInt() throws IOException
_startDoubleback to summary
protected final JsonToken _startDouble() throws IOException
_startFieldNameback to summary
protected final JsonToken _startFieldName(int ch) throws IOException

Method that handles initial token type recognition for token that has to be either FIELD_NAME or END_OBJECT.

_startFloatback to summary
protected final JsonToken _startFloat() throws IOException
_startIntback to summary
private final JsonToken _startInt() throws IOException
_startLongback to summary
private final JsonToken _startLong() throws IOException
_startLongASCIIback to summary
private final JsonToken _startLongASCII() throws IOException
_startLongUnicodeback to summary
protected final JsonToken _startLongUnicode() throws IOException
_startRawBinaryback to summary
protected final JsonToken _startRawBinary() throws IOException
_startShortASCIIback to summary
private final JsonToken _startShortASCII(final int len) throws IOException
_startShortUnicodeback to summary
private final JsonToken _startShortUnicode(final int len) throws IOException
_startValueback to summary
private final JsonToken _startValue(int ch) throws IOException

Helper method called to detect type of a value token (at any level), and possibly decode it if contained in input buffer. Note that possible header has been ruled out by caller and is not checked here.

endOfInputback to summary
public void endOfInput()

Implements com.fasterxml.jackson.core.async.NonBlockingInputFeeder.endOfInput.

Doc from com.fasterxml.jackson.core.async.NonBlockingInputFeeder.endOfInput.

Method that should be called after last chunk of data to parse has been fed (with feedInput in sub-class); can be called regardless of what needMoreInput returns. After calling this method, no more data can be fed; and parser assumes no more data will be available.

Annotations
@Override
feedInputback to summary
public void feedInput(byte[] buf, int start, int end) throws IOException

Implements com.fasterxml.jackson.core.async.ByteArrayFeeder.feedInput.

Doc from com.fasterxml.jackson.core.async.ByteArrayFeeder.feedInput.

Method that can be called to feed more data, if (and only if) needMoreInput returns true.

Parameters
buf:byte[]

Byte array that contains data to feed: caller must ensure data remains stable until it is fully processed (which is true when needMoreInput returns true)

start:int

Offset within array where input data to process starts

end:int

Offset after last byte contained in the input array

Annotations
@Override
Exceptions
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)
getNonBlockingInputFeederback to summary
public ByteArrayFeeder getNonBlockingInputFeeder()

Overrides com.fasterxml.jackson.core.JsonParser.getNonBlockingInputFeeder.

Doc from com.fasterxml.jackson.core.JsonParser.getNonBlockingInputFeeder.

Method that will either return a feeder instance (if parser uses non-blocking, aka asynchronous access); or null for parsers that use blocking I/O.

Returns:ByteArrayFeeder

Input feeder to use with non-blocking (async) parsing

Annotations
@Override
needMoreInputback to summary
public final boolean needMoreInput()

Implements com.fasterxml.jackson.core.async.NonBlockingInputFeeder.needMoreInput.

Doc from com.fasterxml.jackson.core.async.NonBlockingInputFeeder.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).

Returns:boolean

True if more input is needed (and can be fed); false if there is still some input to decode

Annotations
@Override
nextTokenback to summary
public JsonToken nextToken() throws IOException

Implements abstract com.fasterxml.jackson.core.base.ParserMinimalBase.nextToken.

Doc from com.fasterxml.jackson.core.JsonParser.nextToken.

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.

Returns:JsonToken

Next token from the stream, if any found, or null to indicate end-of-input

Annotations
@Override
Exceptions
IOException:
for low-level read issues, or JsonParseException for decoding problems
releaseBufferedback to summary
public int releaseBuffered(OutputStream out) throws IOException

Implements abstract com.fasterxml.jackson.dataformat.smile.async.NonBlockingParserBase.releaseBuffered.

Doc from com.fasterxml.jackson.core.JsonParser.releaseBuffered.

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.

Parameters
out:OutputStream

OutputStream to which buffered, undecoded content is written to

Returns:int

-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)

Annotations
@Override
Exceptions
IOException:
if write to stream threw exception