Class ProtobufParser
java.lang.Object
tools.jackson.core.JsonParser
tools.jackson.core.base.ParserMinimalBase
tools.jackson.dataformat.protobuf.ProtobufParser
- All Implemented Interfaces:
Closeable,AutoCloseable,tools.jackson.core.Versioned
public class ProtobufParser
extends tools.jackson.core.base.ParserMinimalBase
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.core.JsonParser
tools.jackson.core.JsonParser.NumberType, tools.jackson.core.JsonParser.NumberTypeFP -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]We will hold on to decoded binary data, for duration of current event, so that multiple calls togetBinaryValue(tools.jackson.core.Base64Variant)will not need to decode data more than once.protected booleanFlag that indicates whether the input buffer is recycable (and needs to be returned to recycler once we are done) or not.protected tools.jackson.core.util.ByteArrayBuilderByteArrayBuilder is needed if 'getBinaryValue' is called.protected intprotected ProtobufFieldprotected ProtobufMessageThe innermost Object type ("message" in proto lingo) we are handling.protected longNumber of characters/bytes that were contained in previous blocks (blocks that were already processed prior to the current buffer).protected intLength of the value that parser points to, for scalar values that use length prefixes (Strings, binary data).protected byte[]Current buffer from which data is read; generally data is read into buffer from input source, but in some cases pre-loaded buffer is handed to the parser.protected intIndex of character after last available one in the buffer.protected intPointer to next available character in bufferprotected InputStreamInput stream that can be used for reading more content, if one in use.protected booleanFlag set to indicate whether the field name is available from the name copy buffer or not (in addition to its String representation being available via read context)protected char[]Temporary buffer that is needed if field name is accessed usingJsonParser.getTextCharacters()method (instead of String returning alternatives)protected intprotected BigDecimalprotected BigIntegerprotected doubleprotected floatprotected intprotected longprotected intBitfield that indicates which numeric representations have been calculated for the current typeprotected ProtobufSchemaprotected intCurrent state of the parser.protected ProtobufReadContextInformation about parser context, context in which the next token is to be parsed (root, array, object).protected final tools.jackson.core.util.TextBufferBuffer that contains contents of String values, including field names if necessary (name split across boundary, contains escape sequence, or access needed to char array)protected booleanFlag that indicates that the current token has not yet been fully processed, and needs to be finished for some access (or skipped to obtain the next token)protected intColumn on input row that current token starts; 0-based (although in the end it'll be converted to 1-based)protected intInput row on which current token starts, 1-basedprotected longTotal number of bytes/characters read before start of current token.protected static final tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability>Fields inherited from class tools.jackson.core.base.ParserMinimalBase
_closed, _currToken, _ioContext, _lastClearedToken, _objectReadContext, _streamReadConstraints, _streamReadFeatures, _tokenCount, _trackMaxTokenCount, BD_MAX_INT, BD_MAX_LONG, BD_MIN_INT, BD_MIN_LONG, BI_MAX_INT, BI_MAX_LONG, BI_MIN_INT, BI_MIN_LONG, CHAR_NULL, INT_0, INT_9, INT_APOS, INT_ASTERISK, INT_BACKSLASH, INT_COLON, INT_COMMA, INT_CR, INT_e, INT_E, INT_HASH, INT_LBRACKET, INT_LCURLY, INT_LF, INT_MINUS, INT_PERIOD, INT_PLUS, INT_QUOTE, INT_RBRACKET, INT_RCURLY, INT_RS, INT_SLASH, INT_SPACE, INT_TAB, MAX_BYTE_I, MAX_INT_D, MAX_INT_L, MAX_LONG_D, MAX_SHORT_I, MIN_BYTE_I, MIN_INT_D, MIN_INT_L, MIN_LONG_D, MIN_SHORT_I, NO_BYTES, NO_INTS, NR_BIGDECIMAL, NR_BIGINT, NR_DOUBLE, NR_FLOAT, NR_INT, NR_LONG, NR_UNKNOWN, STREAM_READ_FEATURE_DEFAULTSFields inherited from class tools.jackson.core.JsonParser
DEFAULT_READ_CAPABILITIES -
Constructor Summary
ConstructorsConstructorDescriptionProtobufParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, int parserFeatures, ProtobufSchema schema, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected final intprotected final longprotected intprotected longprotected byte[]_finishBytes(int len) protected voidMethod called to finish parsing of a token so that token contents are retriableprotected tools.jackson.core.util.ByteArrayBuilderprotected voidprotected final void_loadToHaveAtLeast(int minAvailable) Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessaryprotected static final long_long(int i1, int i2) protected voidprotected void_skipBytes(int len) protected voidprotected voidprotected final int_slow32()protected final long_slow64()voidvoidclose()protected voidprotected voidprotected voidprotected voidprotected voidprotected voidtools.jackson.core.TokenStreamLocationOverridden since we do not really have character-based locations, but we do have byte offset to specify.Method that can be called to get the name associated with the current event.tools.jackson.core.TokenStreamLocationOverridden since we do not really have character-based locations, but we do have byte offset to specify.byte[]getBinaryValue(tools.jackson.core.Base64Variant b64variant) doublefloatintlongtools.jackson.core.JsonParser.NumberTypetools.jackson.core.JsonParser.NumberTypeFPfinal NumberMethod for accessing textual representation of the current event; if no current event (before first call tonextToken(), or after encountering end-of-input), returns null.intchar[]intintgetValueAsString(String defaultValue) booleanbooleanisNaN()protected final booleanloadMore()protected final voidnextName()booleannextName(tools.jackson.core.SerializableString sstr) intnextNameMatch(tools.jackson.core.sym.PropertyNameMatcher matcher) tools.jackson.core.JsonTokenintreadBinaryValue(tools.jackson.core.Base64Variant b64variant, OutputStream out) intvoidsetSchema(ProtobufSchema schema) tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability>tools.jackson.core.Versionversion()Methods inherited from class tools.jackson.core.base.ParserMinimalBase
_constructInputCoercion, _constructNotNumericType, _currentLocationMinusOne, _decodeBase64, _getCharDesc, _hasTextualNull, _longIntegerDesc, _longNumberDesc, _nullSafeUpdateToken, _reportBadInputStream, _reportBadReader, _reportError, _reportError, _reportError, _reportError, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportInvalidNumber, _reportInvalidSpace, _reportInvalidUTF8Surrogate, _reportMissingRootWS, _reportOverflowByte, _reportOverflowInt, _reportOverflowInt, _reportOverflowInt, _reportOverflowLong, _reportOverflowLong, _reportOverflowLong, _reportOverflowShort, _reportUnexpectedChar, _reportUnexpectedNumberChar, _throwInternal, _updateToken, _updateTokenToNA, _updateTokenToNull, _wrapIOFailure, clearCurrentToken, currentNameMatch, currentToken, currentTokenCount, currentTokenId, finishToken, getBooleanValue, getByteValue, getLastClearedToken, getNumberValueDeferred, getShortValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, hasCurrentToken, hasToken, hasTokenId, isClosed, isEnabled, isExpectedNumberIntToken, isExpectedStartArrayToken, isExpectedStartObjectToken, nextValue, objectReadContext, readValueAs, readValueAs, readValueAs, readValueAsTree, skipChildren, streamReadConstraints, streamReadFeaturesMethods inherited from class tools.jackson.core.JsonParser
_constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _constructReadException, _reportUnsupportedOperation, canParseAsync, canReadObjectId, canReadTypeId, getBinaryValue, getObjectId, getText, getTextCharacters, getTextLength, getTextOffset, getTypeId, getValueAsBoolean, getValueAsDouble, nextBooleanValue, nextIntValue, nextLongValue, nonBlockingInputFeeder, readBinaryValue, releaseBuffered
-
Field Details
-
PROTOBUF_READ_CAPABILITIES
protected static final tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability> PROTOBUF_READ_CAPABILITIES -
_schema
-
_inputPtr
protected int _inputPtrPointer to next available character in buffer -
_inputEnd
protected int _inputEndIndex of character after last available one in the buffer. -
_currInputProcessed
protected long _currInputProcessedNumber of characters/bytes that were contained in previous blocks (blocks that were already processed prior to the current buffer). -
_tokenInputTotal
protected long _tokenInputTotalTotal number of bytes/characters read before start of current token. For big (gigabyte-sized) sizes are possible, needs to be long, unlike pointers and sizes related to in-memory buffers. -
_tokenInputRow
protected int _tokenInputRowInput row on which current token starts, 1-based -
_tokenInputCol
protected int _tokenInputColColumn on input row that current token starts; 0-based (although in the end it'll be converted to 1-based) -
_streamReadContext
Information about parser context, context in which the next token is to be parsed (root, array, object). -
_textBuffer
protected final tools.jackson.core.util.TextBuffer _textBufferBuffer that contains contents of String values, including field names if necessary (name split across boundary, contains escape sequence, or access needed to char array) -
_nameCopyBuffer
protected char[] _nameCopyBufferTemporary buffer that is needed if field name is accessed usingJsonParser.getTextCharacters()method (instead of String returning alternatives) -
_nameCopied
protected boolean _nameCopiedFlag set to indicate whether the field name is available from the name copy buffer or not (in addition to its String representation being available via read context) -
_byteArrayBuilder
protected tools.jackson.core.util.ByteArrayBuilder _byteArrayBuilderByteArrayBuilder is needed if 'getBinaryValue' is called. If so, we better reuse it for remainder of content. -
_binaryValue
protected byte[] _binaryValueWe will hold on to decoded binary data, for duration of current event, so that multiple calls togetBinaryValue(tools.jackson.core.Base64Variant)will not need to decode data more than once. -
_inputStream
Input stream that can be used for reading more content, if one in use. May be null, if input comes just as a full buffer, or if the stream has been closed. -
_inputBuffer
protected byte[] _inputBufferCurrent buffer from which data is read; generally data is read into buffer from input source, but in some cases pre-loaded buffer is handed to the parser. -
_bufferRecyclable
protected boolean _bufferRecyclableFlag that indicates whether the input buffer is recycable (and needs to be returned to recycler once we are done) or not.If it is not, it also means that parser can NOT modify underlying buffer.
-
_currentMessage
The innermost Object type ("message" in proto lingo) we are handling. -
_currentField
-
_tokenIncomplete
protected boolean _tokenIncompleteFlag that indicates that the current token has not yet been fully processed, and needs to be finished for some access (or skipped to obtain the next token) -
_state
protected int _stateCurrent state of the parser. -
_nextTag
protected int _nextTag -
_decodedLength
protected int _decodedLengthLength of the value that parser points to, for scalar values that use length prefixes (Strings, binary data). -
_currentEndOffset
protected int _currentEndOffset -
_numTypesValid
protected int _numTypesValidBitfield that indicates which numeric representations have been calculated for the current type -
_numberInt
protected int _numberInt -
_numberFloat
protected float _numberFloat -
_numberLong
protected long _numberLong -
_numberDouble
protected double _numberDouble -
_numberBigInt
-
_numberBigDecimal
-
-
Constructor Details
-
ProtobufParser
public ProtobufParser(tools.jackson.core.ObjectReadContext readCtxt, tools.jackson.core.io.IOContext ioCtxt, int parserFeatures, ProtobufSchema schema, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable)
-
-
Method Details
-
setSchema
-
version
public tools.jackson.core.Version version()- Specified by:
versionin interfacetools.jackson.core.Versioned- Specified by:
versionin classtools.jackson.core.JsonParser
-
streamReadCapabilities
public tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamReadCapability> streamReadCapabilities()- Overrides:
streamReadCapabilitiesin classtools.jackson.core.base.ParserMinimalBase
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classtools.jackson.core.base.ParserMinimalBase
-
releaseBuffered
- Overrides:
releaseBufferedin classtools.jackson.core.JsonParser
-
_closeInput
protected void _closeInput() throws tools.jackson.core.JacksonException- Specified by:
_closeInputin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
streamReadInputSource
- Specified by:
streamReadInputSourcein classtools.jackson.core.JsonParser
-
currentTokenLocation
public tools.jackson.core.TokenStreamLocation currentTokenLocation()Overridden since we do not really have character-based locations, but we do have byte offset to specify.- Specified by:
currentTokenLocationin classtools.jackson.core.JsonParser
-
currentLocation
public tools.jackson.core.TokenStreamLocation currentLocation()Overridden since we do not really have character-based locations, but we do have byte offset to specify.- Specified by:
currentLocationin classtools.jackson.core.JsonParser
-
currentName
Method that can be called to get the name associated with the current event.- Specified by:
currentNamein classtools.jackson.core.JsonParser
-
streamReadContext
- Specified by:
streamReadContextin classtools.jackson.core.JsonParser
-
assignCurrentValue
- Specified by:
assignCurrentValuein classtools.jackson.core.JsonParser
-
currentValue
- Specified by:
currentValuein classtools.jackson.core.JsonParser
-
getSchema
- Overrides:
getSchemain classtools.jackson.core.JsonParser
-
hasStringCharacters
public boolean hasStringCharacters()- Specified by:
hasStringCharactersin classtools.jackson.core.JsonParser
-
_releaseBuffers
protected void _releaseBuffers()- Specified by:
_releaseBuffersin classtools.jackson.core.base.ParserMinimalBase
-
nextToken
public tools.jackson.core.JsonToken nextToken() throws tools.jackson.core.JacksonException- Specified by:
nextTokenin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
nextName
- Overrides:
nextNamein classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
nextName
public boolean nextName(tools.jackson.core.SerializableString sstr) throws tools.jackson.core.JacksonException - Overrides:
nextNamein classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
nextNameMatch
public int nextNameMatch(tools.jackson.core.sym.PropertyNameMatcher matcher) throws tools.jackson.core.JacksonException - Overrides:
nextNameMatchin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
nextStringValue
- Overrides:
nextStringValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getString
Method for accessing textual representation of the current event; if no current event (before first call tonextToken(), or after encountering end-of-input), returns null. Method can be called for any event.- Specified by:
getStringin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getStringCharacters
public char[] getStringCharacters() throws tools.jackson.core.JacksonException- Specified by:
getStringCharactersin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getStringLength
public int getStringLength() throws tools.jackson.core.JacksonException- Specified by:
getStringLengthin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getStringOffset
public int getStringOffset() throws tools.jackson.core.JacksonException- Specified by:
getStringOffsetin classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getValueAsString
- Overrides:
getValueAsStringin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getValueAsString
- Overrides:
getValueAsStringin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getString
- Overrides:
getStringin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getBinaryValue
public byte[] getBinaryValue(tools.jackson.core.Base64Variant b64variant) throws tools.jackson.core.JacksonException - Specified by:
getBinaryValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getEmbeddedObject
- Overrides:
getEmbeddedObjectin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
readBinaryValue
public int readBinaryValue(tools.jackson.core.Base64Variant b64variant, OutputStream out) throws tools.jackson.core.JacksonException - Overrides:
readBinaryValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
isNaN
public boolean isNaN()- Specified by:
isNaNin classtools.jackson.core.JsonParser
-
getNumberValue
- Specified by:
getNumberValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getNumberValueExact
- Overrides:
getNumberValueExactin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getNumberType
public tools.jackson.core.JsonParser.NumberType getNumberType() throws tools.jackson.core.JacksonException- Specified by:
getNumberTypein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getNumberTypeFP
public tools.jackson.core.JsonParser.NumberTypeFP getNumberTypeFP() throws tools.jackson.core.JacksonException- Overrides:
getNumberTypeFPin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.JacksonException
-
getIntValue
public int getIntValue() throws tools.jackson.core.JacksonException- Specified by:
getIntValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getLongValue
public long getLongValue() throws tools.jackson.core.JacksonException- Specified by:
getLongValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getBigIntegerValue
- Specified by:
getBigIntegerValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getFloatValue
public float getFloatValue() throws tools.jackson.core.JacksonException- Specified by:
getFloatValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getDoubleValue
public double getDoubleValue() throws tools.jackson.core.JacksonException- Specified by:
getDoubleValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
getDecimalValue
- Specified by:
getDecimalValuein classtools.jackson.core.JsonParser- Throws:
tools.jackson.core.JacksonException
-
_checkNumericValue
protected void _checkNumericValue() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
convertNumberToInt
protected void convertNumberToInt() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
convertNumberToLong
protected void convertNumberToLong() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
convertNumberToBigInteger
protected void convertNumberToBigInteger() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
convertNumberToFloat
protected void convertNumberToFloat() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
convertNumberToDouble
protected void convertNumberToDouble() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
convertNumberToBigDecimal
protected void convertNumberToBigDecimal() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_finishToken
protected void _finishToken() throws tools.jackson.core.JacksonExceptionMethod called to finish parsing of a token so that token contents are retriable- Throws:
tools.jackson.core.JacksonException
-
_finishBytes
protected byte[] _finishBytes(int len) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
loadMore
protected final boolean loadMore() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
loadMoreGuaranteed
protected final void loadMoreGuaranteed() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_loadToHaveAtLeast
protected final void _loadToHaveAtLeast(int minAvailable) throws tools.jackson.core.JacksonException Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessary- Throws:
tools.jackson.core.JacksonException
-
_getByteArrayBuilder
protected tools.jackson.core.util.ByteArrayBuilder _getByteArrayBuilder() -
_handleEOF
protected void _handleEOF() throws tools.jackson.core.exc.StreamReadException- Specified by:
_handleEOFin classtools.jackson.core.base.ParserMinimalBase- Throws:
tools.jackson.core.exc.StreamReadException
-
_skipBytes
protected void _skipBytes(int len) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
_skipVInt
protected void _skipVInt() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_skipVIntSlow
protected void _skipVIntSlow() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_decodeVIntSlow
protected int _decodeVIntSlow() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_decodeVLongSlow
protected long _decodeVLongSlow() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_decode32Bits
protected final int _decode32Bits() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_slow32
protected final int _slow32() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_decode64Bits
protected final long _decode64Bits() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_slow64
protected final long _slow64() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_long
protected static final long _long(int i1, int i2)
-