com.fasterxml.jackson.dataformat.protobuf

## Class ProtobufGenerator

- java.lang.Object
- - com.fasterxml.jackson.core.JsonGenerator
  - - com.fasterxml.jackson.core.base.GeneratorBase
    - - com.fasterxml.jackson.dataformat.protobuf.ProtobufGenerator

- All Implemented Interfaces:
    com.fasterxml.jackson.core.Versioned, Closeable, Flushable, AutoCloseable

      public class ProtobufGenerator
      extends com.fasterxml.jackson.core.base.GeneratorBase

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonGenerator

      `com.fasterxml.jackson.core.JsonGenerator.Feature`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ByteAccumulator` | `_buffered` Object used in cases where we need to buffer content to calculate length-prefix.
    `protected boolean` | `_complete` Flag that is set when the whole content is complete, can be output.
    `protected byte[]` | `_currBuffer` Currently active output buffer, place where appends occur.
    `protected ProtobufField` | `_currField` Field to be output next; set when `JsonToken.FIELD_NAME` is written, cleared once value has been written
    `protected ProtobufMessage` | `_currMessage` Type of protobuf message that is currently being output: usually matches write context, but for arrays may indicate "parent" of array.
    `protected int` | `_currPtr`
    `protected int` | `_currStart`
    `protected boolean` | `_inObject`
    `protected com.fasterxml.jackson.core.io.IOContext` | `_ioContext`
    `protected byte[]` | `_origCurrBuffer` The first allocated (or recycled) buffer instance; needed to avoid issue [dataformat-protobuf#14].
    `protected OutputStream` | `_output` Ultimate destination
    `protected ProtobufWriteContext` | `_pbContext` Current context, in form we can use it.
    `protected ProtobufWriteContext` | `_rootContext` Reference to the root context since that is needed for serialization
    `protected ProtobufSchema` | `_schema`
    `protected boolean` | `_writeTag` Flag that indicates whether values should be written with tag or not; false for packed arrays, true for others.
    `protected static com.fasterxml.jackson.core.json.JsonWriteContext` | `BOGUS_WRITE_CONTEXT` Since our context object does NOT implement standard write context, need to do something like use a placeholder...
    `protected static 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.
    `protected static 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.

    - ### Fields inherited from class com.fasterxml.jackson.core.base.GeneratorBase

      `_cfgNumbersAsStrings, _closed, _features, _objectCodec, _writeContext, DERIVED_FEATURES_MASK, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST, WRITE_BINARY, WRITE_BOOLEAN, WRITE_NULL, WRITE_NUMBER, WRITE_RAW, WRITE_STRING`

    - ### Fields inherited from class com.fasterxml.jackson.core.JsonGenerator

      `_cfgPrettyPrinter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProtobufGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int jsonFeatures, com.fasterxml.jackson.core.ObjectCodec codec, OutputStream output)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `_complete()`
    `protected void` | `_encodeLongerString(char[] text, int offset, int clen)`
    `protected void` | `_encodeLongerString(String text)`
    `protected void` | `_ensureMore()`
    `protected void` | `_ensureRoom(int needed)`
    `protected void` | `_releaseBuffers()`
    `protected void` | `_reportEnumError(Object enumValue)`
    `protected void` | `_reportWrongWireType(String typeStr)`
    `protected void` | `_verifyValueWrite()`
    `protected void` | `_verifyValueWrite(String typeMsg)`
    `protected void` | `_writeEmptyString()`
    `protected void` | `_writeEnum(int index)`
    `protected void` | `_writeEnum(String str)`
    `protected void` | `_writeLengthPrefixed(byte[] data, int offset, int len)`
    `boolean` | `canUseSchema(com.fasterxml.jackson.core.FormatSchema schema)`
    `void` | `close()`
    `void` | `flush()`
    `Object` | `getCurrentValue()`
    `int` | `getOutputBuffered()` 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.
    `Object` | `getOutputTarget()`
    `ProtobufSchema` | `getSchema()`
    `void` | `setCurrentValue(Object v)`
    `ProtobufGenerator` | `setPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp)`
    `void` | `setSchema(com.fasterxml.jackson.core.FormatSchema schema)`
    `void` | `setSchema(ProtobufSchema schema)`
    `ProtobufGenerator` | `useDefaultPrettyPrinter()` Not sure whether to throw an exception or just do no-op; for now, latter.
    `com.fasterxml.jackson.core.Version` | `version()`
    `void` | `writeArray(double[] array, int offset, int length)`
    `void` | `writeArray(int[] array, int offset, int length)`
    `void` | `writeArray(long[] array, int offset, int length)`
    `void` | `writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len)`
    `void` | `writeBoolean(boolean state)`
    `void` | `writeEndArray()`
    `void` | `writeEndObject()`
    `void` | `writeFieldName(com.fasterxml.jackson.core.SerializableString sstr)`
    `void` | `writeFieldName(String name)`
    `void` | `writeNull()`
    `void` | `writeNumber(BigDecimal v)`
    `void` | `writeNumber(BigInteger v)`
    `void` | `writeNumber(double d)`
    `void` | `writeNumber(float f)`
    `void` | `writeNumber(int v)`
    `void` | `writeNumber(long v)`
    `void` | `writeNumber(String encodedValue)`
    `void` | `writeRaw(char c)`
    `void` | `writeRaw(char[] text, int offset, int len)`
    `void` | `writeRaw(String text)`
    `void` | `writeRaw(String text, int offset, int len)`
    `void` | `writeRawUTF8String(byte[] text, int offset, int len)`
    `void` | `writeRawValue(char[] text, int offset, int len)`
    `void` | `writeRawValue(String text)`
    `void` | `writeRawValue(String text, int offset, int len)`
    `void` | `writeStartArray()`
    `void` | `writeStartObject()`
    `void` | `writeString(char[] text, int offset, int clen)`
    `void` | `writeString(com.fasterxml.jackson.core.SerializableString sstr)`
    `void` | `writeString(String text)`
    `void` | `writeUTF8String(byte[] text, int offset, int len)`

    - ### Methods inherited from class com.fasterxml.jackson.core.base.GeneratorBase

      `_checkStdFeatureChanges, _constructDefaultPrettyPrinter, _decodeSurrogate, disable, enable, getCodec, getFeatureMask, getOutputContext, isClosed, isEnabled, overrideStdFeatures, setCodec, setFeatureMask, writeBinary, writeObject, writeRawValue, writeStartObject, writeTree`

    - ### Methods inherited from class com.fasterxml.jackson.core.JsonGenerator

      `_reportError, _reportUnsupportedOperation, _throwInternal, _verifyOffsets, _writeSimpleObject, canOmitFields, canWriteBinaryNatively, canWriteFormattedNumbers, canWriteObjectId, canWriteTypeId, configure, copyCurrentEvent, copyCurrentStructure, getCharacterEscapes, getFormatFeatures, getHighestEscapedChar, getPrettyPrinter, overrideFormatFeatures, setCharacterEscapes, setHighestNonEscapedChar, setRootValueSeparator, writeArrayFieldStart, writeBinary, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeEmbeddedObject, writeFieldId, writeNullField, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectId, writeObjectRef, writeOmittedField, writeRaw, writeStartArray, writeStringField, writeTypeId`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BOGUS_WRITE_CONTEXT

          protected static final com.fasterxml.jackson.core.json.JsonWriteContext BOGUS_WRITE_CONTEXT

      Since our context object does NOT implement standard write context, need to do something like use a placeholder...

    - #### 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.

    - #### _ioContext

          protected final com.fasterxml.jackson.core.io.IOContext _ioContext

    - #### _schema

          protected 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.FIELD_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.

    - #### _pbContext

          protected ProtobufWriteContext _pbContext

      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 Detail

    - #### ProtobufGenerator

          public ProtobufGenerator(com.fasterxml.jackson.core.io.IOContext ctxt,
                           int jsonFeatures,
                           com.fasterxml.jackson.core.ObjectCodec codec,
                           OutputStream output)
                            throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### setSchema

          public void setSchema(ProtobufSchema schema)

    - #### getCurrentValue

          public Object getCurrentValue()

      Overrides:
        `getCurrentValue` in class `com.fasterxml.jackson.core.base.GeneratorBase`

    - #### setCurrentValue

          public void setCurrentValue(Object v)

      Overrides:
        `setCurrentValue` in class `com.fasterxml.jackson.core.base.GeneratorBase`

    - #### version

          public com.fasterxml.jackson.core.Version version()

      Specified by:
        `version` in interface `com.fasterxml.jackson.core.Versioned`
      Overrides:
        `version` in class `com.fasterxml.jackson.core.base.GeneratorBase`

    - #### useDefaultPrettyPrinter

          public ProtobufGenerator useDefaultPrettyPrinter()

      Not sure whether to throw an exception or just do no-op; for now, latter.
      Overrides:
        `useDefaultPrettyPrinter` in class `com.fasterxml.jackson.core.base.GeneratorBase`

    - #### setPrettyPrinter

          public ProtobufGenerator setPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp)

      Overrides:
        `setPrettyPrinter` in class `com.fasterxml.jackson.core.JsonGenerator`

    - #### getOutputTarget

          public Object getOutputTarget()

      Overrides:
        `getOutputTarget` in class `com.fasterxml.jackson.core.JsonGenerator`

    - #### getOutputBuffered

          public int getOutputBuffered()

      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.
      Overrides:
        `getOutputBuffered` in class `com.fasterxml.jackson.core.JsonGenerator`

    - #### canUseSchema

          public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema)

      Overrides:
        `canUseSchema` in class `com.fasterxml.jackson.core.JsonGenerator`

    - #### getSchema

          public ProtobufSchema getSchema()

      Overrides:
        `getSchema` in class `com.fasterxml.jackson.core.JsonGenerator`

    - #### setSchema

          public void setSchema(com.fasterxml.jackson.core.FormatSchema schema)

      Overrides:
        `setSchema` in class `com.fasterxml.jackson.core.JsonGenerator`

    - #### writeFieldName

          public final void writeFieldName(String name)
                                    throws IOException

      Specified by:
        `writeFieldName` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeFieldName

          public final void writeFieldName(com.fasterxml.jackson.core.SerializableString sstr)
                                    throws IOException

      Overrides:
        `writeFieldName` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### flush

          public final void flush()
                           throws IOException

      Specified by:
        `flush` in interface `Flushable`
      Specified by:
        `flush` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### writeStartArray

          public final void writeStartArray()
                                     throws IOException

      Specified by:
        `writeStartArray` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeEndArray

          public final void writeEndArray()
                                   throws IOException

      Specified by:
        `writeEndArray` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeStartObject

          public final void writeStartObject()
                                      throws IOException

      Specified by:
        `writeStartObject` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeEndObject

          public final void writeEndObject()
                                    throws IOException

      Specified by:
        `writeEndObject` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeArray

          public void writeArray(int[] array,
                        int offset,
                        int length)
                          throws IOException

      Overrides:
        `writeArray` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeArray

          public void writeArray(long[] array,
                        int offset,
                        int length)
                          throws IOException

      Overrides:
        `writeArray` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeArray

          public void writeArray(double[] array,
                        int offset,
                        int length)
                          throws IOException

      Overrides:
        `writeArray` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeString

          public void writeString(String text)
                           throws IOException

      Specified by:
        `writeString` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeString

          public void writeString(char[] text,
                         int offset,
                         int clen)
                           throws IOException

      Specified by:
        `writeString` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeString

          public final void writeString(com.fasterxml.jackson.core.SerializableString sstr)
                                 throws IOException

      Overrides:
        `writeString` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### writeRawUTF8String

          public void writeRawUTF8String(byte[] text,
                                int offset,
                                int len)
                                  throws IOException

      Specified by:
        `writeRawUTF8String` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeUTF8String

          public final void writeUTF8String(byte[] text,
                             int offset,
                             int len)
                                     throws IOException

      Specified by:
        `writeUTF8String` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### _writeEmptyString

          protected void _writeEmptyString()
                                    throws IOException

      Throws:
        `IOException`

    - #### _writeEnum

          protected void _writeEnum(String str)
                             throws IOException

      Throws:
        `IOException`

    - #### _writeEnum

          protected void _writeEnum(int index)
                             throws IOException

      Throws:
        `IOException`

    - #### _reportEnumError

          protected void _reportEnumError(Object enumValue)
                                   throws IOException

      Throws:
        `IOException`

    - #### writeRaw

          public void writeRaw(String text)
                        throws IOException

      Specified by:
        `writeRaw` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeRaw

          public void writeRaw(String text,
                      int offset,
                      int len)
                        throws IOException

      Specified by:
        `writeRaw` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeRaw

          public void writeRaw(char[] text,
                      int offset,
                      int len)
                        throws IOException

      Specified by:
        `writeRaw` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeRaw

          public void writeRaw(char c)
                        throws IOException

      Specified by:
        `writeRaw` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeRawValue

          public void writeRawValue(String text)
                             throws IOException

      Overrides:
        `writeRawValue` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### writeRawValue

          public void writeRawValue(String text,
                           int offset,
                           int len)
                             throws IOException

      Overrides:
        `writeRawValue` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### writeRawValue

          public void writeRawValue(char[] text,
                           int offset,
                           int len)
                             throws IOException

      Overrides:
        `writeRawValue` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### writeBinary

          public void writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
                         byte[] data,
                         int offset,
                         int len)
                           throws IOException

      Specified by:
        `writeBinary` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeBoolean

          public void writeBoolean(boolean state)
                            throws IOException

      Specified by:
        `writeBoolean` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNull

          public void writeNull()
                         throws IOException

      Specified by:
        `writeNull` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(int v)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(long v)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(BigInteger v)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(double d)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(float f)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(BigDecimal v)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### writeNumber

          public void writeNumber(String encodedValue)
                           throws IOException

      Specified by:
        `writeNumber` in class `com.fasterxml.jackson.core.JsonGenerator`
      Throws:
        `IOException`

    - #### _verifyValueWrite

          protected final void _verifyValueWrite()
                                          throws IOException

      Throws:
        `IOException`

    - #### _verifyValueWrite

          protected void _verifyValueWrite(String typeMsg)
                                    throws IOException

      Specified by:
        `_verifyValueWrite` in class `com.fasterxml.jackson.core.base.GeneratorBase`
      Throws:
        `IOException`

    - #### _releaseBuffers

          protected void _releaseBuffers()

      Specified by:
        `_releaseBuffers` in class `com.fasterxml.jackson.core.base.GeneratorBase`

    - #### _encodeLongerString

          protected void _encodeLongerString(char[] text,
                                 int offset,
                                 int clen)
                                      throws IOException

      Throws:
        `IOException`

    - #### _encodeLongerString

          protected void _encodeLongerString(String text)
                                      throws IOException

      Throws:
        `IOException`

    - #### _writeLengthPrefixed

          protected void _writeLengthPrefixed(byte[] data,
                                  int offset,
                                  int len)
                                       throws IOException

      Throws:
        `IOException`

    - #### _ensureRoom

          protected final void _ensureRoom(int needed)
                                    throws IOException

      Throws:
        `IOException`

    - #### _ensureMore

          protected final void _ensureMore()
                                    throws IOException

      Throws:
        `IOException`

    - #### _complete

          protected void _complete()
                            throws IOException

      Throws:
        `IOException`

    - #### _reportWrongWireType

          protected void _reportWrongWireType(String typeStr)
                                       throws IOException

      Throws:
        `IOException`

Copyright © 2016 FasterXML. All rights reserved.