Class ProtobufGenerator
java.lang.Object
tools.jackson.core.JsonGenerator
tools.jackson.core.base.GeneratorBase
tools.jackson.dataformat.protobuf.ProtobufGenerator
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,tools.jackson.core.Versioned
public class ProtobufGenerator
extends tools.jackson.core.base.GeneratorBase
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteAccumulatorObject used in cases where we need to buffer content to calculate length-prefix.protected booleanFlag that is set when the whole content is complete, can be output.protected byte[]Currently active output buffer, place where appends occur.protected ProtobufFieldField to be output next; set whenJsonToken.PROPERTY_NAMEis written, cleared once value has been writtenprotected ProtobufMessageType of protobuf message that is currently being output: usually matches write context, but for arrays may indicate "parent" of array.protected intprotected intprotected booleanprotected byte[]The first allocated (or recycled) buffer instance; needed to avoid issue [dataformat-protobuf#14].protected final OutputStreamUltimate destinationprotected ProtobufWriteContextReference to the root context since that is needed for serializationprotected final ProtobufSchemaprotected ProtobufWriteContextCurrent context, in form we can use it.protected booleanFlag that indicates whether values should be written with tag or not; false for packed arrays, true for others.protected static final ProtobufFieldThis instance is used as a placeholder for cases where we do not know actual field and want to simply skip over any values that caller tries to write for it.protected static final ProtobufMessageThis is used as a placeholder for case where we don't have an actual message to use, but know (from context) that one is expected.Fields inherited from class tools.jackson.core.base.GeneratorBase
_closed, _ioContext, _objectWriteContext, _streamWriteConstraints, _streamWriteFeatures, DEFAULT_BINARY_WRITE_CAPABILITIES, DEFAULT_TEXTUAL_WRITE_CAPABILITIES, DEFAULT_WRITE_CAPABILITIES, MAX_BIG_DECIMAL_SCALE, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST, WRITE_BINARY, WRITE_BOOLEAN, WRITE_NULL, WRITE_NUMBER, WRITE_RAW, WRITE_STRING -
Constructor Summary
ConstructorsConstructorDescriptionProtobufGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, ProtobufSchema schema, OutputStream output) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected void_encodeLongerString(char[] text, int offset, int clen) protected void_encodeLongerString(String text) protected final voidprotected final void_ensureRoom(int needed) protected voidprotected void_reportEnumError(Object enumValue) protected void_reportWrongWireType(String typeStr) protected final voidprotected void_verifyValueWrite(String typeMsg) protected voidprotected void_writeEnum(int index) protected void_writeEnum(String str) protected void_writeLengthPrefixed(byte[] data, int offset, int len) final voidfinal Objectfinal voidflush()tools.jackson.core.PrettyPrintertools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamWriteCapability>final tools.jackson.core.TokenStreamContextintCalculating actual amount of buffering is somewhat complicated, and can not necessarily give 100% accurate answer due to presence of VInt encoding for length indicators.tools.jackson.core.Versionversion()tools.jackson.core.JsonGeneratorwriteArray(double[] array, int offset, int length) tools.jackson.core.JsonGeneratorwriteArray(int[] array, int offset, int length) tools.jackson.core.JsonGeneratorwriteArray(long[] array, int offset, int length) tools.jackson.core.JsonGeneratorwriteBinary(tools.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) tools.jackson.core.JsonGeneratorwriteBoolean(boolean state) tools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratorwriteName(tools.jackson.core.SerializableString sstr) tools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratorwriteNumber(double d) tools.jackson.core.JsonGeneratorwriteNumber(float f) tools.jackson.core.JsonGeneratorwriteNumber(int v) tools.jackson.core.JsonGeneratorwriteNumber(long v) tools.jackson.core.JsonGeneratorwriteNumber(short v) tools.jackson.core.JsonGeneratorwriteNumber(String encodedValue) tools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratorwritePropertyId(long id) tools.jackson.core.JsonGeneratorwriteRaw(char c) tools.jackson.core.JsonGeneratorwriteRaw(char[] text, int offset, int len) tools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratorwriteRawUTF8String(byte[] text, int offset, int len) tools.jackson.core.JsonGeneratorwriteRawValue(char[] text, int offset, int len) tools.jackson.core.JsonGeneratorwriteRawValue(String text) tools.jackson.core.JsonGeneratorwriteRawValue(String text, int offset, int len) tools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratorwriteStartArray(Object currValue) tools.jackson.core.JsonGeneratortools.jackson.core.JsonGeneratorwriteStartObject(Object currValue) tools.jackson.core.JsonGeneratorwriteString(char[] text, int offset, int clen) tools.jackson.core.JsonGeneratorwriteString(String text) tools.jackson.core.JsonGeneratorwriteString(tools.jackson.core.SerializableString sstr) tools.jackson.core.JsonGeneratorwriteUTF8String(byte[] text, int offset, int len) Methods inherited from class tools.jackson.core.base.GeneratorBase
_asString, _checkRangeBoundsForByteArray, _checkRangeBoundsForCharArray, _checkRangeBoundsForString, _constructDefaultPrettyPrinter, _decodeSurrogate, _throwInternal, close, configure, has, ioContext, isClosed, isEnabled, objectWriteContext, streamWriteConstraints, streamWriteFeatures, writeBinary, writePOJO, writeRawValue, writeStartArray, writeStartObject, writeString, writeTreeMethods inherited from class tools.jackson.core.JsonGenerator
_constructWriteException, _constructWriteException, _constructWriteException, _constructWriteException, _copyCurrentContents, _copyCurrentContentsExact, _copyCurrentFloatValue, _copyCurrentFloatValueExact, _copyCurrentIntValue, _copyCurrentStringValue, _reportArgumentError, _reportError, _reportUnsupportedOperation, _reportUnsupportedOperation, _verifyOffsets, _wrapIOFailure, _writeTypePrefixUsingNative, _writeTypePrefixUsingWrapper, canOmitProperties, canWriteObjectId, canWriteTypeId, copyCurrentEvent, copyCurrentEventExact, copyCurrentStructure, copyCurrentStructureExact, getCharacterEscapes, getHighestNonEscapedChar, setCharacterEscapes, writeArray, writeArrayPropertyStart, writeBinary, writeBinary, writeBinary, writeBinaryProperty, writeBooleanProperty, writeEmbeddedObject, writeNullProperty, writeNumber, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeObjectId, writeObjectPropertyStart, writeObjectRef, writeOmittedProperty, writePOJOProperty, writeRaw, writeStringProperty, writeTypeId, writeTypePrefix, writeTypeSuffix
-
Field Details
-
UNKNOWN_FIELD
This instance is used as a placeholder for cases where we do not know actual field and want to simply skip over any values that caller tries to write for it. -
UNKNOWN_MESSAGE
This is used as a placeholder for case where we don't have an actual message to use, but know (from context) that one is expected. -
_schema
-
_rootContext
Reference to the root context since that is needed for serialization -
_inObject
protected boolean _inObject -
_writeTag
protected boolean _writeTagFlag that indicates whether values should be written with tag or not; false for packed arrays, true for others. -
_complete
protected boolean _completeFlag that is set when the whole content is complete, can be output. -
_currMessage
Type of protobuf message that is currently being output: usually matches write context, but for arrays may indicate "parent" of array. -
_currField
Field to be output next; set whenJsonToken.PROPERTY_NAMEis written, cleared once value has been written -
_output
Ultimate destination -
_buffered
Object used in cases where we need to buffer content to calculate length-prefix. -
_streamWriteContext
Current context, in form we can use it. -
_currBuffer
protected byte[] _currBufferCurrently active output buffer, place where appends occur. -
_origCurrBuffer
protected byte[] _origCurrBufferThe first allocated (or recycled) buffer instance; needed to avoid issue [dataformat-protobuf#14]. -
_currStart
protected int _currStart -
_currPtr
protected int _currPtr
-
-
Constructor Details
-
ProtobufGenerator
public ProtobufGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, ProtobufSchema schema, OutputStream output)
-
-
Method Details
-
currentValue
- Specified by:
currentValuein classtools.jackson.core.JsonGenerator
-
assignCurrentValue
- Specified by:
assignCurrentValuein classtools.jackson.core.JsonGenerator
-
streamWriteContext
public final tools.jackson.core.TokenStreamContext streamWriteContext()- Specified by:
streamWriteContextin classtools.jackson.core.JsonGenerator
-
version
public tools.jackson.core.Version version()- Specified by:
versionin interfacetools.jackson.core.Versioned- Specified by:
versionin classtools.jackson.core.JsonGenerator
-
streamWriteCapabilities
public tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamWriteCapability> streamWriteCapabilities()- Specified by:
streamWriteCapabilitiesin classtools.jackson.core.JsonGenerator
-
streamWriteOutputTarget
- Specified by:
streamWriteOutputTargetin classtools.jackson.core.JsonGenerator
-
streamWriteOutputBuffered
public int streamWriteOutputBuffered()Calculating actual amount of buffering is somewhat complicated, and can not necessarily give 100% accurate answer due to presence of VInt encoding for length indicators. So, for now, we'll respond "don't know": this may be improved if and as needed.- Specified by:
streamWriteOutputBufferedin classtools.jackson.core.JsonGenerator
-
getPrettyPrinter
public tools.jackson.core.PrettyPrinter getPrettyPrinter()- Overrides:
getPrettyPrinterin classtools.jackson.core.JsonGenerator
-
getSchema
- Overrides:
getSchemain classtools.jackson.core.JsonGenerator
-
writeName
public tools.jackson.core.JsonGenerator writeName(String name) throws tools.jackson.core.JacksonException - Specified by:
writeNamein classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeName
public tools.jackson.core.JsonGenerator writeName(tools.jackson.core.SerializableString sstr) throws tools.jackson.core.JacksonException - Overrides:
writeNamein classtools.jackson.core.base.GeneratorBase- Throws:
tools.jackson.core.JacksonException
-
writePropertyId
public tools.jackson.core.JsonGenerator writePropertyId(long id) throws tools.jackson.core.JacksonException - Specified by:
writePropertyIdin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
flush
public final void flush() throws tools.jackson.core.JacksonException -
_closeInput
- Specified by:
_closeInputin classtools.jackson.core.base.GeneratorBase- Throws:
IOException
-
writeStartArray
public tools.jackson.core.JsonGenerator writeStartArray() throws tools.jackson.core.JacksonException- Specified by:
writeStartArrayin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeStartArray
public tools.jackson.core.JsonGenerator writeStartArray(Object currValue) throws tools.jackson.core.JacksonException - Specified by:
writeStartArrayin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeEndArray
public tools.jackson.core.JsonGenerator writeEndArray() throws tools.jackson.core.JacksonException- Specified by:
writeEndArrayin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeStartObject
public tools.jackson.core.JsonGenerator writeStartObject(Object currValue) throws tools.jackson.core.JacksonException - Specified by:
writeStartObjectin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeStartObject
public tools.jackson.core.JsonGenerator writeStartObject() throws tools.jackson.core.JacksonException- Specified by:
writeStartObjectin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeEndObject
public tools.jackson.core.JsonGenerator writeEndObject() throws tools.jackson.core.JacksonException- Specified by:
writeEndObjectin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeArray
public tools.jackson.core.JsonGenerator writeArray(int[] array, int offset, int length) throws tools.jackson.core.JacksonException - Overrides:
writeArrayin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeArray
public tools.jackson.core.JsonGenerator writeArray(long[] array, int offset, int length) throws tools.jackson.core.JacksonException - Overrides:
writeArrayin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeArray
public tools.jackson.core.JsonGenerator writeArray(double[] array, int offset, int length) throws tools.jackson.core.JacksonException - Overrides:
writeArrayin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeString
public tools.jackson.core.JsonGenerator writeString(String text) throws tools.jackson.core.JacksonException - Specified by:
writeStringin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeString
public tools.jackson.core.JsonGenerator writeString(char[] text, int offset, int clen) throws tools.jackson.core.JacksonException - Specified by:
writeStringin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeString
public tools.jackson.core.JsonGenerator writeString(tools.jackson.core.SerializableString sstr) throws tools.jackson.core.JacksonException - Overrides:
writeStringin classtools.jackson.core.base.GeneratorBase- Throws:
tools.jackson.core.JacksonException
-
writeRawUTF8String
public tools.jackson.core.JsonGenerator writeRawUTF8String(byte[] text, int offset, int len) throws tools.jackson.core.JacksonException - Specified by:
writeRawUTF8Stringin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeUTF8String
public tools.jackson.core.JsonGenerator writeUTF8String(byte[] text, int offset, int len) throws tools.jackson.core.JacksonException - Specified by:
writeUTF8Stringin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
_writeEmptyString
protected void _writeEmptyString() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_writeEnum
- Throws:
tools.jackson.core.JacksonException
-
_writeEnum
protected void _writeEnum(int index) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
_reportEnumError
- Throws:
tools.jackson.core.JacksonException
-
writeRaw
public tools.jackson.core.JsonGenerator writeRaw(String text) throws tools.jackson.core.JacksonException - Specified by:
writeRawin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeRaw
public tools.jackson.core.JsonGenerator writeRaw(String text, int offset, int len) throws tools.jackson.core.JacksonException - Specified by:
writeRawin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeRaw
public tools.jackson.core.JsonGenerator writeRaw(char[] text, int offset, int len) throws tools.jackson.core.JacksonException - Specified by:
writeRawin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeRaw
public tools.jackson.core.JsonGenerator writeRaw(char c) throws tools.jackson.core.JacksonException - Specified by:
writeRawin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeRawValue
public tools.jackson.core.JsonGenerator writeRawValue(String text) throws tools.jackson.core.JacksonException - Overrides:
writeRawValuein classtools.jackson.core.base.GeneratorBase- Throws:
tools.jackson.core.JacksonException
-
writeRawValue
public tools.jackson.core.JsonGenerator writeRawValue(String text, int offset, int len) throws tools.jackson.core.JacksonException - Overrides:
writeRawValuein classtools.jackson.core.base.GeneratorBase- Throws:
tools.jackson.core.JacksonException
-
writeRawValue
public tools.jackson.core.JsonGenerator writeRawValue(char[] text, int offset, int len) throws tools.jackson.core.JacksonException - Overrides:
writeRawValuein classtools.jackson.core.base.GeneratorBase- Throws:
tools.jackson.core.JacksonException
-
writeBinary
public tools.jackson.core.JsonGenerator writeBinary(tools.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) throws tools.jackson.core.JacksonException - Specified by:
writeBinaryin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeBoolean
public tools.jackson.core.JsonGenerator writeBoolean(boolean state) throws tools.jackson.core.JacksonException - Specified by:
writeBooleanin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNull
public tools.jackson.core.JsonGenerator writeNull() throws tools.jackson.core.JacksonException- Specified by:
writeNullin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(short v) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(int v) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(long v) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(BigInteger v) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(double d) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(float f) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(BigDecimal v) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
writeNumber
public tools.jackson.core.JsonGenerator writeNumber(String encodedValue) throws tools.jackson.core.JacksonException - Specified by:
writeNumberin classtools.jackson.core.JsonGenerator- Throws:
tools.jackson.core.JacksonException
-
_verifyValueWrite
protected final void _verifyValueWrite() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_verifyValueWrite
- Specified by:
_verifyValueWritein classtools.jackson.core.base.GeneratorBase- Throws:
tools.jackson.core.JacksonException
-
_releaseBuffers
protected void _releaseBuffers()- Specified by:
_releaseBuffersin classtools.jackson.core.base.GeneratorBase
-
_encodeLongerString
protected void _encodeLongerString(char[] text, int offset, int clen) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
_encodeLongerString
- Throws:
tools.jackson.core.JacksonException
-
_writeLengthPrefixed
protected void _writeLengthPrefixed(byte[] data, int offset, int len) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
_ensureRoom
protected final void _ensureRoom(int needed) throws tools.jackson.core.JacksonException - Throws:
tools.jackson.core.JacksonException
-
_ensureMore
protected final void _ensureMore() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_complete
protected void _complete() throws tools.jackson.core.JacksonException- Throws:
tools.jackson.core.JacksonException
-
_reportWrongWireType
- Throws:
tools.jackson.core.JacksonException
-