Top Fields Constructors Methods
tools.jackson.dataformat.protobuf

public Class ProtobufParser

extends ParserMinimalBase
Class Inheritance
Imports
java.io.*, java.math.BigDecimal, .BigInteger, tools.jackson.core.*, tools.jackson.core.base.ParserMinimalBase, tools.jackson.core.exc.StreamReadException, tools.jackson.core.io.IOContext, .NumberInput, tools.jackson.core.sym.PropertyNameMatcher, tools.jackson.core.util.*, tools.jackson.dataformat.protobuf.schema.*

Field Summary

Modifier and TypeField and Description
protected byte[]
_binaryValue

We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue will not need to decode data more than once.

protected boolean
_bufferRecyclable

Flag that indicates whether the input buffer is recycable (and needs to be returned to recycler once we are done) or not.

protected ByteArrayBuilder
_byteArrayBuilder

ByteArrayBuilder is needed if 'getBinaryValue' is called.

protected int
protected ProtobufField
protected ProtobufMessage
_currentMessage

The innermost Object type ("message" in proto lingo) we are handling.

protected long
_currInputProcessed

Number of characters/bytes that were contained in previous blocks (blocks that were already processed prior to the current buffer).

protected int
_decodedLength

Length of the value that parser points to, for scalar values that use length prefixes (Strings, binary data).

protected byte[]
_inputBuffer

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 int
_inputEnd

Index of character after last available one in the buffer.

protected int
_inputPtr

Pointer to next available character in buffer

protected InputStream
_inputStream

Input stream that can be used for reading more content, if one in use.

protected boolean
_nameCopied

Flag 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[]
_nameCopyBuffer

Temporary buffer that is needed if field name is accessed using getTextCharacters method (instead of String returning alternatives)

protected int
protected BigDecimal
protected BigInteger
protected double
protected float
protected int
protected long
protected int
_numTypesValid

Bitfield that indicates which numeric representations have been calculated for the current type

protected ProtobufSchema
protected int
_state

Current state of the parser.

protected ProtobufReadContext
_streamReadContext

Information about parser context, context in which the next token is to be parsed (root, array, object).

protected final TextBuffer
_textBuffer

Buffer 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 boolean
_tokenIncomplete

Flag 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 int
_tokenInputCol

Column on input row that current token starts; 0-based (although in the end it'll be converted to 1-based)

protected int
_tokenInputRow

Input row on which current token starts, 1-based

protected long
_tokenInputTotal

Total number of bytes/characters read before start of current token.

protected static final JacksonFeatureSet<StreamReadCapability>
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int[]
Inherited from tools.jackson.core.base.ParserMinimalBase:
_closed_currToken_ioContext_lastClearedToken_objectReadContext_streamReadConstraints_streamReadFeatures_tokenCount_trackMaxTokenCountBD_MAX_INTBD_MAX_LONGBD_MIN_INTBD_MIN_LONGBI_MAX_INTBI_MAX_LONGBI_MIN_INTBI_MIN_LONGCHAR_NULLINT_0INT_9INT_APOSINT_ASTERISKINT_BACKSLASHINT_COLONINT_COMMAINT_CRINT_eINT_EINT_HASHINT_LBRACKETINT_LCURLYINT_LFINT_MINUSINT_PERIODINT_PLUSINT_QUOTEINT_RBRACKETINT_RCURLYINT_RSINT_SLASHINT_SPACEINT_TABMAX_BYTE_IMAX_INT_DMAX_INT_LMAX_LONG_DMAX_SHORT_IMIN_BYTE_IMIN_INT_DMIN_INT_LMIN_LONG_DMIN_SHORT_INO_BYTESNO_INTSNR_BIGDECIMALNR_BIGINTNR_DOUBLENR_FLOATNR_INTNR_LONGNR_UNKNOWNSTREAM_READ_FEATURE_DEFAULTS

Constructor Summary

AccessConstructor and Description
public
ProtobufParser(ObjectReadContext readCtxt, IOContext ioCtxt, int parserFeatures, ProtobufSchema schema, InputStream in, byte[] inputBuffer, int start, int end, boolean bufferRecyclable)

Method Summary

Modifier and TypeMethod and Description
private boolean
protected void
protected void
_closeInput()

Implements abstract tools.jackson.core.base.ParserMinimalBase._closeInput.

Abstract method for sub-classes to implement; to be called by close() implementation here.

protected final int
protected final long
private int
private final int
_decodeUTF8_3(int c1)

private final int

Returns:

Character value minus 0x10000; this so that caller can readily expand it to actual surrogates
_decodeUTF8_4
(int c)

private int
protected int
private long
protected long
private final ProtobufField
_findField(int id)

protected byte[]
_finishBytes(int len)

private final void
_finishLongText(int len)

private final String
protected void
_finishToken()

Method called to finish parsing of a token so that token contents are retriable

protected ByteArrayBuilder
protected void
_handleEOF()

Implements abstract tools.jackson.core.base.ParserMinimalBase._handleEOF.

Method sub-classes need to implement to check whether end-of-content is allowed at the current decoding position: formats often want to verify the all start/end token pairs match, for example.

private JsonToken
private JsonToken
_handleRootKey(int tag)

protected 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 necessary

protected static final long
_long(int i1, int i2)

private final int
private int
private JsonToken
_readNextValue(FieldType t, int nextState)

protected void
_releaseBuffers()

Implements abstract tools.jackson.core.base.ParserMinimalBase._releaseBuffers.

Method called to release internal buffers owned by the base reader.

private void
_reportErrorF(String format, Object... args)

private void
private void
private void
private void
private void
_reportInvalidOther(int mask, int ptr)

private void
_reportTooLongVInt(int fifth)

private void
protected void
_skipBytes(int len)

private JsonToken
_skipUnknownField(int tag, int wireType, boolean nestedField)

private void
_skipUnknownValue(int wireType)

protected void
protected void
protected final int
protected final long
public void
assignCurrentValue(Object v)

Implements abstract tools.jackson.core.JsonParser.assignCurrentValue.

Helper method, usually equivalent to: getParsingContext().assignCurrentValue(v);

public void
close()

Overrides tools.jackson.core.base.ParserMinimalBase.close.

Implements java.io.Closeable.close.

Closes the parser so that no further iteration or data access can be made; will also close the underlying input source if parser either owns the input source, or feature StreamReadFeature#AUTO_CLOSE_SOURCE is enabled.

protected void
protected void
protected void
protected void
protected void
protected void
public TokenStreamLocation
currentLocation()

Implements abstract tools.jackson.core.JsonParser.currentLocation.

Overridden since we do not really have character-based locations, but we do have byte offset to specify.

public String
currentName()

Implements abstract tools.jackson.core.JsonParser.currentName.

Method that can be called to get the name associated with the current event.

public TokenStreamLocation
currentTokenLocation()

Implements abstract tools.jackson.core.JsonParser.currentTokenLocation.

Overridden since we do not really have character-based locations, but we do have byte offset to specify.

public Object
currentValue()

Implements abstract tools.jackson.core.JsonParser.currentValue.

Helper method, usually equivalent to: getParsingContext().currentValue();

Note that "current value" is NOT populated (or used) by Streaming parser; it is only used by higher-level data-binding functionality.

public BigInteger
getBigIntegerValue()

Implements abstract tools.jackson.core.JsonParser.getBigIntegerValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it cannot be used as a Java long primitive type due to its magnitude.

public byte[]
getBinaryValue(Base64Variant b64variant)

Implements abstract tools.jackson.core.JsonParser.getBinaryValue.

Method that can be used to read (and consume -- results may not be accessible using other methods after the call) base64-encoded binary data included in the current textual JSON value.

public BigDecimal
getDecimalValue()

Implements abstract tools.jackson.core.JsonParser.getDecimalValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_FLOAT or JsonToken#VALUE_NUMBER_INT.

public double
getDoubleValue()

Implements abstract tools.jackson.core.JsonParser.getDoubleValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_FLOAT and it can be expressed as a Java double primitive type.

public Object
getEmbeddedObject()

Overrides tools.jackson.core.base.ParserMinimalBase.getEmbeddedObject.

Accessor that can be called if (and only if) the current token is JsonToken#VALUE_EMBEDDED_OBJECT.

public float
getFloatValue()

Implements abstract tools.jackson.core.JsonParser.getFloatValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_FLOAT and it can be expressed as a Java float primitive type.

public int
getIntValue()

Implements abstract tools.jackson.core.JsonParser.getIntValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it can be expressed as a value of Java int primitive type.

public long
getLongValue()

Implements abstract tools.jackson.core.JsonParser.getLongValue.

Numeric accessor that can be called when the current token is of type JsonToken#VALUE_NUMBER_INT and it can be expressed as a Java long primitive type.

public JsonParser.NumberType
getNumberType()

Implements abstract tools.jackson.core.JsonParser.getNumberType.

If current token is of type JsonToken#VALUE_NUMBER_INT or JsonToken#VALUE_NUMBER_FLOAT, returns one of NumberType constants; otherwise returns null.

public JsonParser.NumberTypeFP
getNumberTypeFP()

Overrides tools.jackson.core.base.ParserMinimalBase.getNumberTypeFP.

If current token is of type JsonToken#VALUE_NUMBER_FLOAT, returns one of NumberTypeFP constants; otherwise returns NumberTypeFP#UNKNOWN.

public Number
getNumberValue()

Implements abstract tools.jackson.core.JsonParser.getNumberValue.

Generic number value accessor method that will work for all kinds of numeric values.

public final Number
getNumberValueExact()

Overrides tools.jackson.core.base.ParserMinimalBase.getNumberValueExact.

Method similar to getNumberValue with the difference that for floating-point numbers value returned may be BigDecimal if the underlying format does not store floating-point numbers using native representation: for example, textual formats represent numbers as Strings (which are 10-based), and conversion to java.lang.Double is potentially lossy operation.

public ProtobufSchema
getSchema()

Overrides tools.jackson.core.JsonParser.getSchema.

Method for accessing Schema that this parser uses, if any.

public String
getString()

Implements abstract tools.jackson.core.JsonParser.getString.

Method for accessing textual representation of the current event; if no current event (before first call to nextToken, or after encountering end-of-input), returns null.

public int
getString(Writer writer)

Overrides tools.jackson.core.base.ParserMinimalBase.getString.

Method to read the textual representation of the current token in chunks and pass it to the given Writer.

public char[]
getStringCharacters()

Implements abstract tools.jackson.core.JsonParser.getStringCharacters.

Method similar to getString(), but that will return underlying (unmodifiable) character array that contains textual value, instead of constructing a String object to contain this information.

public int
getStringLength()

Implements abstract tools.jackson.core.JsonParser.getStringLength.

Accessor used with getStringCharacters, to know length of String stored in returned buffer.

public int
getStringOffset()

Implements abstract tools.jackson.core.JsonParser.getStringOffset.

Accessor used with getStringCharacters, to know offset of the first text content character within buffer.

public String
getValueAsString()

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsString.

Method that will try to convert value of current token to a java.lang.String.

public String
getValueAsString(String defaultValue)

Overrides tools.jackson.core.base.ParserMinimalBase.getValueAsString.

Method that will try to convert value of current token to a java.lang.String.

public boolean
hasStringCharacters()

Implements abstract tools.jackson.core.JsonParser.hasStringCharacters.

Method that can be used to determine whether calling of getStringCharacters would be the most efficient way to access String value for the event parser currently points to (compared to getString()).

public boolean
isNaN()

Implements abstract tools.jackson.core.JsonParser.isNaN.

Accessor for checking whether current token is a special "not-a-number" (NaN) token (including both "NaN" AND positive/negative infinity!).

protected final boolean
protected final void
public String
nextName()

Overrides tools.jackson.core.base.ParserMinimalBase.nextName.

Method that fetches next token (as if calling nextToken) and verifies whether it is JsonToken#PROPERTY_NAME; if it is, returns same as currentName(), otherwise null.

public boolean
nextName(SerializableString sstr)

Overrides tools.jackson.core.base.ParserMinimalBase.nextName.

Method that fetches next token (as if calling nextToken) and verifies whether it is JsonToken#PROPERTY_NAME with specified name and returns result of that comparison.

public int
nextNameMatch(PropertyNameMatcher matcher)

Overrides tools.jackson.core.base.ParserMinimalBase.nextNameMatch.

Method that tries to match next token from stream as JsonToken#PROPERTY_NAME, and if so, further match it to one of pre-specified (field) names.

public String
nextStringValue()

Overrides tools.jackson.core.JsonParser.nextStringValue.

Method that fetches next token (as if calling nextToken) and if it is JsonToken#VALUE_STRING returns contained String value; otherwise returns null.

public JsonToken
nextToken()

Implements abstract tools.jackson.core.JsonParser.nextToken.

Main iteration method, which will advance stream enough to determine type of the next token, if any.

public int
readBinaryValue(Base64Variant b64variant, OutputStream out)

Overrides tools.jackson.core.JsonParser.readBinaryValue.

Similar to readBinaryValue(OutputStream) but allows explicitly specifying base64 variant to use.

public int
releaseBuffered(OutputStream out)

Overrides tools.jackson.core.JsonParser.releaseBuffered.

Method that can be called to push back any content that has been read but not consumed by the parser.

public void
public JacksonFeatureSet<StreamReadCapability>
streamReadCapabilities()

Overrides tools.jackson.core.base.ParserMinimalBase.streamReadCapabilities.

Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).

public ProtobufReadContext
streamReadContext()

Implements abstract tools.jackson.core.JsonParser.streamReadContext.

Method that can be used to access current parsing context reader is in. There are 3 different types: root, array and object contexts, with slightly different available information.

public Object
streamReadInputSource()

Implements abstract tools.jackson.core.JsonParser.streamReadInputSource.

Method that can be used to get access to object that is used to access input being parsed; this is usually either InputStream or Reader, depending on what parser was constructed with.

public Version
version()

Implements abstract tools.jackson.core.JsonParser.version.

Implements tools.jackson.core.Versioned.version.

Accessor for getting version of the core package, given a parser instance.

Inherited from 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_reportMissingRootWS_reportOverflowByte_reportOverflowInt_reportOverflowInt_reportOverflowInt_reportOverflowLong_reportOverflowLong_reportOverflowLong_reportOverflowShort_reportUnexpectedChar_reportUnexpectedNumberChar_throwInternal_updateToken_updateTokenToNA_updateTokenToNull_wrapIOFailureclearCurrentTokencurrentNameMatchcurrentTokencurrentTokenCountcurrentTokenIdfinishTokengetBooleanValuegetByteValuegetLastClearedTokengetNumberValueDeferredgetShortValuegetValueAsBooleangetValueAsDoublegetValueAsIntgetValueAsIntgetValueAsLonggetValueAsLonghasCurrentTokenhasTokenhasTokenIdisClosedisEnabledisExpectedNumberIntTokenisExpectedStartArrayTokenisExpectedStartObjectTokennextValueobjectReadContextreadValueAsreadValueAsreadValueAsreadValueAsTreeskipChildrenstreamReadConstraintsstreamReadFeatures