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

    Fields
    Modifier and Type
    Field
    Description
    protected ByteAccumulator
    Object used in cases where we need to buffer content to calculate length-prefix.
    protected boolean
    Flag that is set when the whole content is complete, can be output.
    protected byte[]
    Currently active output buffer, place where appends occur.
    protected ProtobufField
    Field to be output next; set when JsonToken.PROPERTY_NAME is written, cleared once value has been written
    protected ProtobufMessage
    Type of protobuf message that is currently being output: usually matches write context, but for arrays may indicate "parent" of array.
    protected int
     
    protected int
     
    protected boolean
     
    protected byte[]
    The first allocated (or recycled) buffer instance; needed to avoid issue [dataformat-protobuf#14].
    protected final OutputStream
    Ultimate destination
    Reference to the root context since that is needed for serialization
    protected final ProtobufSchema
     
    Current context, in form we can use it.
    protected boolean
    Flag that indicates whether values should be written with tag or not; false for packed arrays, true for others.
    protected static final ProtobufField
    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.
    protected static final ProtobufMessage
    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.

    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

    Constructors
    Constructor
    Description
    ProtobufGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, ProtobufSchema schema, OutputStream output)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    protected void
    _encodeLongerString(char[] text, int offset, int clen)
     
    protected void
     
    protected final void
     
    protected final void
    _ensureRoom(int needed)
     
    protected void
     
    protected void
     
    protected void
     
    protected final void
     
    protected void
     
    protected void
     
    protected void
    _writeEnum(int index)
     
    protected void
     
    protected void
    _writeLengthPrefixed(byte[] data, int offset, int len)
     
    final void
     
    final Object
     
    final void
     
    tools.jackson.core.PrettyPrinter
     
     
    tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamWriteCapability>
     
    final tools.jackson.core.TokenStreamContext
     
    int
    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.
     
    tools.jackson.core.Version
     
    tools.jackson.core.JsonGenerator
    writeArray(double[] array, int offset, int length)
     
    tools.jackson.core.JsonGenerator
    writeArray(int[] array, int offset, int length)
     
    tools.jackson.core.JsonGenerator
    writeArray(long[] array, int offset, int length)
     
    tools.jackson.core.JsonGenerator
    writeBinary(tools.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len)
     
    tools.jackson.core.JsonGenerator
    writeBoolean(boolean state)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeName(tools.jackson.core.SerializableString sstr)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeNumber(double d)
     
    tools.jackson.core.JsonGenerator
    writeNumber(float f)
     
    tools.jackson.core.JsonGenerator
    writeNumber(int v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(long v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(short v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(String encodedValue)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writePropertyId(long id)
     
    tools.jackson.core.JsonGenerator
    writeRaw(char c)
     
    tools.jackson.core.JsonGenerator
    writeRaw(char[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeRaw(String text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
    writeRawUTF8String(byte[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
    writeRawValue(char[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeRawValue(String text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeString(char[] text, int offset, int clen)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeString(tools.jackson.core.SerializableString sstr)
     
    tools.jackson.core.JsonGenerator
    writeUTF8String(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, writeTree

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNKNOWN_FIELD

      protected static final ProtobufField 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

      protected static final ProtobufMessage 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

      protected final ProtobufSchema _schema
    • _rootContext

      protected ProtobufWriteContext _rootContext
      Reference to the root context since that is needed for serialization
    • _inObject

      protected boolean _inObject
    • _writeTag

      protected boolean _writeTag
      Flag that indicates whether values should be written with tag or not; false for packed arrays, true for others.
    • _complete

      protected boolean _complete
      Flag that is set when the whole content is complete, can be output.
    • _currMessage

      protected ProtobufMessage _currMessage
      Type of protobuf message that is currently being output: usually matches write context, but for arrays may indicate "parent" of array.
    • _currField

      protected ProtobufField _currField
      Field to be output next; set when JsonToken.PROPERTY_NAME is written, cleared once value has been written
    • _output

      protected final OutputStream _output
      Ultimate destination
    • _buffered

      protected ByteAccumulator _buffered
      Object used in cases where we need to buffer content to calculate length-prefix.
    • _streamWriteContext

      protected ProtobufWriteContext _streamWriteContext
      Current context, in form we can use it.
    • _currBuffer

      protected byte[] _currBuffer
      Currently active output buffer, place where appends occur.
    • _origCurrBuffer

      protected byte[] _origCurrBuffer
      The 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

      public final Object currentValue()
      Specified by:
      currentValue in class tools.jackson.core.JsonGenerator
    • assignCurrentValue

      public final void assignCurrentValue(Object v)
      Specified by:
      assignCurrentValue in class tools.jackson.core.JsonGenerator
    • streamWriteContext

      public final tools.jackson.core.TokenStreamContext streamWriteContext()
      Specified by:
      streamWriteContext in class tools.jackson.core.JsonGenerator
    • version

      public tools.jackson.core.Version version()
      Specified by:
      version in interface tools.jackson.core.Versioned
      Specified by:
      version in class tools.jackson.core.JsonGenerator
    • streamWriteCapabilities

      public tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamWriteCapability> streamWriteCapabilities()
      Specified by:
      streamWriteCapabilities in class tools.jackson.core.JsonGenerator
    • streamWriteOutputTarget

      public Object streamWriteOutputTarget()
      Specified by:
      streamWriteOutputTarget in class tools.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:
      streamWriteOutputBuffered in class tools.jackson.core.JsonGenerator
    • getPrettyPrinter

      public tools.jackson.core.PrettyPrinter getPrettyPrinter()
      Overrides:
      getPrettyPrinter in class tools.jackson.core.JsonGenerator
    • getSchema

      public ProtobufSchema getSchema()
      Overrides:
      getSchema in class tools.jackson.core.JsonGenerator
    • writeName

      public tools.jackson.core.JsonGenerator writeName(String name) throws tools.jackson.core.JacksonException
      Specified by:
      writeName in class tools.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:
      writeName in class tools.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:
      writePropertyId in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • flush

      public final void flush() throws tools.jackson.core.JacksonException
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • _closeInput

      protected void _closeInput() throws IOException
      Specified by:
      _closeInput in class tools.jackson.core.base.GeneratorBase
      Throws:
      IOException
    • writeStartArray

      public tools.jackson.core.JsonGenerator writeStartArray() throws tools.jackson.core.JacksonException
      Specified by:
      writeStartArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeStartArray

      public tools.jackson.core.JsonGenerator writeStartArray(Object currValue) throws tools.jackson.core.JacksonException
      Specified by:
      writeStartArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeEndArray

      public tools.jackson.core.JsonGenerator writeEndArray() throws tools.jackson.core.JacksonException
      Specified by:
      writeEndArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeStartObject

      public tools.jackson.core.JsonGenerator writeStartObject(Object currValue) throws tools.jackson.core.JacksonException
      Specified by:
      writeStartObject in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeStartObject

      public tools.jackson.core.JsonGenerator writeStartObject() throws tools.jackson.core.JacksonException
      Specified by:
      writeStartObject in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeEndObject

      public tools.jackson.core.JsonGenerator writeEndObject() throws tools.jackson.core.JacksonException
      Specified by:
      writeEndObject in class tools.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:
      writeArray in class tools.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:
      writeArray in class tools.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:
      writeArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeString

      public tools.jackson.core.JsonGenerator writeString(String text) throws tools.jackson.core.JacksonException
      Specified by:
      writeString in class tools.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:
      writeString in class tools.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:
      writeString in class tools.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:
      writeRawUTF8String in class tools.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:
      writeUTF8String in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • _writeEmptyString

      protected void _writeEmptyString() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _writeEnum

      protected void _writeEnum(String str) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _writeEnum

      protected void _writeEnum(int index) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _reportEnumError

      protected void _reportEnumError(Object enumValue) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • writeRaw

      public tools.jackson.core.JsonGenerator writeRaw(String text) throws tools.jackson.core.JacksonException
      Specified by:
      writeRaw in class tools.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:
      writeRaw in class tools.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:
      writeRaw in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRaw

      public tools.jackson.core.JsonGenerator writeRaw(char c) throws tools.jackson.core.JacksonException
      Specified by:
      writeRaw in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRawValue

      public tools.jackson.core.JsonGenerator writeRawValue(String text) throws tools.jackson.core.JacksonException
      Overrides:
      writeRawValue in class tools.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:
      writeRawValue in class tools.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:
      writeRawValue in class tools.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:
      writeBinary in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeBoolean

      public tools.jackson.core.JsonGenerator writeBoolean(boolean state) throws tools.jackson.core.JacksonException
      Specified by:
      writeBoolean in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNull

      public tools.jackson.core.JsonGenerator writeNull() throws tools.jackson.core.JacksonException
      Specified by:
      writeNull in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(short v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(int v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(long v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(BigInteger v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(double d) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(float f) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(BigDecimal v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(String encodedValue) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • _verifyValueWrite

      protected final void _verifyValueWrite() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _verifyValueWrite

      protected void _verifyValueWrite(String typeMsg) throws tools.jackson.core.JacksonException
      Specified by:
      _verifyValueWrite in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • _releaseBuffers

      protected void _releaseBuffers()
      Specified by:
      _releaseBuffers in class tools.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

      protected void _encodeLongerString(String text) throws tools.jackson.core.JacksonException
      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

      protected void _reportWrongWireType(String typeStr) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException