com.fasterxml.jackson.dataformat.cbor

## Class CBORGenerator

- java.lang.Object
- - com.fasterxml.jackson.core.JsonGenerator
  - - com.fasterxml.jackson.core.base.GeneratorBase
    - - com.fasterxml.jackson.dataformat.cbor.CBORGenerator

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

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

`JsonGenerator` implementation that writes CBOR encoded content.

Author:
  Tatu Saloranta

### Nested Class Summary

Nested Classes
`static class` `CBORGenerator.Feature` Enumeration that defines all togglable features for CBOR generator.

### Field Summary

Fields
`protected boolean` `_bufferRecyclable` Flag that indicates whether the output buffer is recycable (and needs to be returned to recycler once we are done) or not.
`protected int` `_bytesWritten` Let's keep track of how many bytes have been output, may prove useful when debugging.
`protected boolean` `_cfgMinimalInts`
`protected char[]` `_charBuffer` Intermediate buffer in which characters of a String are copied before being encoded.
`protected int` `_charBufferLength`
`protected int` `_formatFeatures` Bit flag composed of bits that indicate which `CBORGenerator.Feature`s are enabled.
`protected com.fasterxml.jackson.core.io.IOContext` `_ioContext`
`protected OutputStream` `_out`
`protected byte[]` `_outputBuffer` Intermediate buffer in which contents are buffered before being written using `_out`.
`protected int` `_outputEnd` Offset to index after the last valid index in `_outputBuffer`.
`protected int` `_outputTail` Pointer to the next available byte in `_outputBuffer`

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

`_cfgNumbersAsStrings, _closed, _features, _objectCodec, _writeContext, DERIVED_FEATURES_MASK, MAX_BIG_DECIMAL_SCALE, 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
`CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int stdFeatures, int formatFeatures, com.fasterxml.jackson.core.ObjectCodec codec, OutputStream out)`
`CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int stdFeatures, int formatFeatures, com.fasterxml.jackson.core.ObjectCodec codec, OutputStream out, byte[] outputBuffer, int offset, boolean bufferRecyclable)` Alternative constructor that may be used to feed partially initialized content.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `_ensureSpace(int needed)`
`protected void` `_flushBuffer()`
`protected UnsupportedOperationException` `_notSupported()`
`protected void` `_releaseBuffers()`
`protected void` `_verifyValueWrite(String typeMsg)`
`protected void` `_writeChunkedString(char[] text, int offset, int len)`
`protected void` `_writeString(char[] text, int offset, int len)`
`protected void` `_writeString(String name)`
`boolean` `canWriteBinaryNatively()`
`void` `close()`
`CBORGenerator` `configure(CBORGenerator.Feature f, boolean state)`
`void` `copyCurrentEvent(com.fasterxml.jackson.core.JsonParser p)` Specialize `JsonGenerator.copyCurrentEvent(com.fasterxml.jackson.core.JsonParser)` to handle tags.
`void` `copyCurrentStructure(com.fasterxml.jackson.core.JsonParser p)` Specialize `JsonGenerator.copyCurrentStructure(com.fasterxml.jackson.core.JsonParser)` to handle tags.
`CBORGenerator` `disable(CBORGenerator.Feature f)`
`CBORGenerator` `enable(CBORGenerator.Feature f)`
`void` `flush()`
`int` `getFormatFeatures()`
`int` `getOutputBuffered()`
`Object` `getOutputTarget()`
`boolean` `isEnabled(CBORGenerator.Feature f)`
`protected void` `maybeCopyTag(com.fasterxml.jackson.core.JsonParser p)`
`com.fasterxml.jackson.core.JsonGenerator` `overrideFormatFeatures(int values, int mask)`
`com.fasterxml.jackson.core.JsonGenerator` `overrideStdFeatures(int values, int mask)`
`com.fasterxml.jackson.core.JsonGenerator` `setPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp)` No way (or need) to indent anything, so let's block any attempts.
`com.fasterxml.jackson.core.JsonGenerator` `useDefaultPrettyPrinter()` No way (or need) to indent anything, so let's block any attempts.
`com.fasterxml.jackson.core.Version` `version()`
`void` `writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len)`
`int` `writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, InputStream data, int dataLength)`
`int` `writeBinary(InputStream data, int dataLength)`
`void` `writeBoolean(boolean state)`
`void` `writeBytes(byte[] data, int offset, int len)` Method for directly inserting specified bytes in output at current position.
`void` `writeEndArray()`
`void` `writeEndObject()`
`void` `writeFieldName(com.fasterxml.jackson.core.SerializableString name)`
`void` `writeFieldName(String name)`
`void` `writeNull()`
`void` `writeNumber(BigDecimal dec)`
`void` `writeNumber(BigInteger v)`
`void` `writeNumber(double d)`
`void` `writeNumber(float f)`
`void` `writeNumber(int i)`
`void` `writeNumber(long l)`
`void` `writeNumber(String encodedValue)`
`void` `writeRaw(byte b)` Method for directly inserting specified byte in output at current position.
`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[] raw, 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` `writeStartArray(int size)`
`void` `writeStartObject()`
`void` `writeString(char[] text, int offset, int len)`
`void` `writeString(com.fasterxml.jackson.core.SerializableString sstr)`
`void` `writeString(String text)`
`void` `writeStringField(String fieldName, String value)`
`void` `writeTag(int tagId)` Method for writing out an explicit CBOR Tag.
`void` `writeUTF8String(byte[] text, int offset, int len)`

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

`_asString, _checkStdFeatureChanges, _constructDefaultPrettyPrinter, _decodeSurrogate, disable, enable, getCodec, getCurrentValue, getFeatureMask, getOutputContext, isClosed, isEnabled, setCodec, setCurrentValue, setFeatureMask, writeObject, writeRawValue, writeStartObject, writeTree`

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

`_reportError, _reportUnsupportedOperation, _throwInternal, _verifyOffsets, _writeSimpleObject, canOmitFields, canUseSchema, canWriteFormattedNumbers, canWriteObjectId, canWriteTypeId, configure, getCharacterEscapes, getHighestEscapedChar, getPrettyPrinter, getSchema, setCharacterEscapes, setHighestNonEscapedChar, setRootValueSeparator, setSchema, writeArray, writeArray, writeArray, writeArrayFieldStart, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeEmbeddedObject, writeFieldId, writeNullField, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectId, writeObjectRef, writeOmittedField, writeRaw, writeString, writeTypeId, writeTypePrefix, writeTypeSuffix`

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

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

### Field Detail

#### _ioContext

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

#### _out

    protected final OutputStream _out

#### _formatFeatures

    protected int _formatFeatures

Bit flag composed of bits that indicate which `CBORGenerator.Feature`s are enabled.

#### _cfgMinimalInts

    protected boolean _cfgMinimalInts

#### _outputBuffer

    protected byte[] _outputBuffer

Intermediate buffer in which contents are buffered before being written using `_out`.

#### _outputTail

    protected int _outputTail

Pointer to the next available byte in `_outputBuffer`

#### _outputEnd

    protected final int _outputEnd

Offset to index after the last valid index in `_outputBuffer`. Typically same as length of the buffer.

#### _charBuffer

    protected char[] _charBuffer

Intermediate buffer in which characters of a String are copied before being encoded.

#### _charBufferLength

    protected final int _charBufferLength

#### _bytesWritten

    protected int _bytesWritten

Let's keep track of how many bytes have been output, may prove useful when debugging. This does not include bytes buffered in the output buffer, just bytes that have been written using underlying stream writer.

#### _bufferRecyclable

    protected boolean _bufferRecyclable

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

### Constructor Detail

#### CBORGenerator

    public CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt,
                         int stdFeatures,
                         int formatFeatures,
                         com.fasterxml.jackson.core.ObjectCodec codec,
                         OutputStream out)

#### CBORGenerator

    public CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt,
                         int stdFeatures,
                         int formatFeatures,
                         com.fasterxml.jackson.core.ObjectCodec codec,
                         OutputStream out,
                         byte[] outputBuffer,
                         int offset,
                         boolean bufferRecyclable)

Alternative constructor that may be used to feed partially initialized content.

Parameters:
  `outputBuffer` - Buffer to use for output before flushing to the underlying stream
  `offset` - Offset pointing past already buffered content; that is, number of bytes of valid content to output, within buffer.

### Method Detail

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

#### canWriteBinaryNatively

    public boolean canWriteBinaryNatively()

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

#### useDefaultPrettyPrinter

    public com.fasterxml.jackson.core.JsonGenerator useDefaultPrettyPrinter()

No way (or need) to indent anything, so let's block any attempts. (should we throw an exception instead?)

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

#### setPrettyPrinter

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

No way (or need) to indent anything, so let's block any attempts. (should we throw an exception instead?)

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()

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

#### getFormatFeatures

    public int getFormatFeatures()

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

#### overrideStdFeatures

    public com.fasterxml.jackson.core.JsonGenerator overrideStdFeatures(int values,
                                                                        int mask)

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

#### overrideFormatFeatures

    public com.fasterxml.jackson.core.JsonGenerator overrideFormatFeatures(int values,
                                                                           int mask)

Overrides:
  `overrideFormatFeatures` 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 name)
                              throws IOException

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

#### writeStringField

    public final void writeStringField(String fieldName,
                                       String value)
                                throws IOException

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

#### copyCurrentEvent

    public void copyCurrentEvent(com.fasterxml.jackson.core.JsonParser p)
                          throws IOException

Specialize `JsonGenerator.copyCurrentEvent(com.fasterxml.jackson.core.JsonParser)` to handle tags.

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

#### copyCurrentStructure

    public void copyCurrentStructure(com.fasterxml.jackson.core.JsonParser p)
                              throws IOException

Specialize `JsonGenerator.copyCurrentStructure(com.fasterxml.jackson.core.JsonParser)` to handle tags.

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

#### maybeCopyTag

    protected void maybeCopyTag(com.fasterxml.jackson.core.JsonParser p)
                         throws IOException

Throws:
  `IOException`

#### enable

    public CBORGenerator enable(CBORGenerator.Feature f)

#### disable

    public CBORGenerator disable(CBORGenerator.Feature f)

#### isEnabled

    public final boolean isEnabled(CBORGenerator.Feature f)

#### configure

    public CBORGenerator configure(CBORGenerator.Feature f,
                                   boolean state)

#### writeTag

    public void writeTag(int tagId)
                  throws IOException

Method for writing out an explicit CBOR Tag.

Parameters:
  `tagId` - Positive integer (0 or higher)
Throws:
  `IOException`
Since:
  2.5

#### writeRaw

    public void writeRaw(byte b)
                  throws IOException

Method for directly inserting specified byte in output at current position.

NOTE: only use this method if you really know what you are doing.

Throws:
  `IOException`

#### writeBytes

    public void writeBytes(byte[] data,
                           int offset,
                           int len)
                    throws IOException

Method for directly inserting specified bytes in output at current position.

NOTE: only use this method if you really know what you are doing.

Throws:
  `IOException`

#### writeStartArray

    public final void writeStartArray()
                               throws IOException

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

#### writeStartArray

    public void writeStartArray(int size)
                         throws IOException

Overrides:
  `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`

#### writeString

    public void writeString(String text)
                     throws IOException,
                            com.fasterxml.jackson.core.JsonGenerationException

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

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

#### writeString

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

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

#### writeRawUTF8String

    public void writeRawUTF8String(byte[] raw,
                                   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`

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

#### writeBinary

    public int writeBinary(InputStream data,
                           int dataLength)
                    throws IOException

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

#### writeBinary

    public int writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
                           InputStream data,
                           int dataLength)
                    throws IOException

Overrides:
  `writeBinary` in class `com.fasterxml.jackson.core.base.GeneratorBase`
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 i)
                     throws IOException

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

#### writeNumber

    public void writeNumber(long l)
                     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 dec)
                     throws IOException

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

#### writeNumber

    public void writeNumber(String encodedValue)
                     throws IOException,
                            com.fasterxml.jackson.core.JsonGenerationException,
                            UnsupportedOperationException

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

#### _verifyValueWrite

    protected final void _verifyValueWrite(String typeMsg)
                                    throws IOException

Specified by:
  `_verifyValueWrite` 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`

#### _writeString

    protected final void _writeString(String name)
                               throws IOException

Throws:
  `IOException`

#### _ensureSpace

    protected final void _ensureSpace(int needed)
                               throws IOException

Throws:
  `IOException`

#### _writeString

    protected final void _writeString(char[] text,
                                      int offset,
                                      int len)
                               throws IOException

Throws:
  `IOException`

#### _writeChunkedString

    protected final void _writeChunkedString(char[] text,
                                             int offset,
                                             int len)
                                      throws IOException

Throws:
  `IOException`

#### _releaseBuffers

    protected void _releaseBuffers()

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

#### _flushBuffer

    protected final void _flushBuffer()
                               throws IOException

Throws:
  `IOException`

#### _notSupported

    protected UnsupportedOperationException _notSupported()