public class CBORGenerator
extends com.fasterxml.jackson.core.base.GeneratorBase
JsonGenerator
implementation that writes CBOR encoded content.Modifier and Type | Class and Description |
---|---|
static class |
CBORGenerator.Feature
Enumeration that defines all togglable features for CBOR generator.
|
Modifier and Type | Field and Description |
---|---|
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 |
_currentRemainingElements
Number of elements remaining in the current complex structure (if any),
when writing defined-length Arrays, Objects; marker
INDEFINITE_LENGTH
otherwise. |
protected int[] |
_elementCounts |
protected int |
_elementCountsPtr |
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 java.io.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 |
(package private) static int |
BYTE_BUFFER_FOR_OUTPUT
Let's ensure that we have big enough output buffer because of safety
margins we need for UTF-8 encoding.
|
private static int |
INDEFINITE_LENGTH
Special value that is use to keep tracks of arrays and maps opened with infinite length
|
private static long |
MAX_INT_AS_LONG |
private static int |
MAX_LONG_STRING_BYTES
This is the worst case length (in bytes) of maximum chunk we ever write.
|
private static int |
MAX_LONG_STRING_CHARS
Longest char chunk we will output is chosen so that it is guaranteed to
fit in an empty buffer even if everything encoded in 3-byte sequences;
but also fit two full chunks in case of single-byte (ascii) output.
|
private static int |
MAX_MEDIUM_STRING_BYTES |
private static int |
MAX_MEDIUM_STRING_CHARS |
private static int |
MAX_SHORT_STRING_BYTES |
private static int |
MAX_SHORT_STRING_CHARS |
private static int |
MIN_BUFFER_LENGTH
To simplify certain operations, we require output buffer length to allow
outputting of contiguous 256 character UTF-8 encoded String value.
|
private static long |
MIN_INT_AS_LONG |
private static int[] |
NO_INTS |
_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
Constructor and Description |
---|
CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt,
int stdFeatures,
int formatFeatures,
com.fasterxml.jackson.core.ObjectCodec codec,
java.io.OutputStream out) |
CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt,
int stdFeatures,
int formatFeatures,
com.fasterxml.jackson.core.ObjectCodec codec,
java.io.OutputStream out,
byte[] outputBuffer,
int offset,
boolean bufferRecyclable)
Alternative constructor that may be used to feed partially initialized content.
|
Modifier and Type | Method and Description |
---|---|
private int |
_convertSurrogate(int firstPart,
int secondPart)
Method called to calculate UTF codepoint, from a surrogate pair.
|
private int |
_encode(int outputPtr,
char[] str,
int i,
int end)
Helper method called when the whole character sequence is known to fit in
the output buffer regardless of UTF-8 expansion.
|
private int |
_encode(int outputPtr,
java.lang.String str,
int len) |
private int |
_encode2(int i,
int outputPtr,
java.lang.String str,
int len,
int outputStart) |
private void |
_ensureRoomForOutput(int needed) |
protected void |
_ensureSpace(int needed) |
private void |
_failSizedArrayOrObject() |
protected void |
_flushBuffer() |
protected java.lang.UnsupportedOperationException |
_notSupported() |
private void |
_pushRemainingElements() |
protected void |
_releaseBuffers() |
private int |
_shortUTF8Encode2(char[] str,
int i,
int end,
int outputPtr,
int outputStart)
Helper method called when the whole character sequence is known to fit in
the output buffer, but not all characters are single-byte (ASCII)
characters.
|
private void |
_throwIllegalSurrogate(int code) |
protected void |
_verifyValueWrite(java.lang.String typeMsg) |
protected void |
_write(java.math.BigInteger v) |
private void |
_writeByte(byte b) |
private void |
_writeBytes(byte[] data,
int offset,
int len) |
private int |
_writeBytes(java.io.InputStream in,
int bytesLeft) |
private void |
_writeBytesLong(byte[] data,
int offset,
int len) |
protected void |
_writeChunkedString(char[] text,
int offset,
int len) |
private void |
_writeIntValue(int i) |
private void |
_writeLengthMarker(int majorType,
int i) |
private void |
_writeLongValue(long l) |
private void |
_writeNumberNoCheck(double d) |
private void |
_writeNumberNoCheck(int i) |
private void |
_writeNumberNoCheck(long l) |
protected void |
_writeString(char[] text,
int offset,
int len) |
protected void |
_writeString(java.lang.String name) |
boolean |
canWriteBinaryNatively() |
void |
close() |
private void |
closeComplexElement() |
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() |
java.lang.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 |
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) |
int |
writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
java.io.InputStream data,
int dataLength) |
int |
writeBinary(java.io.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 |
writeFieldId(long size) |
void |
writeFieldName(com.fasterxml.jackson.core.SerializableString name) |
void |
writeFieldName(java.lang.String name) |
void |
writeNull() |
void |
writeNumber(java.math.BigDecimal dec) |
void |
writeNumber(java.math.BigInteger v) |
void |
writeNumber(double d) |
void |
writeNumber(float f) |
void |
writeNumber(int i) |
void |
writeNumber(long l) |
void |
writeNumber(java.lang.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(java.lang.String text) |
void |
writeRaw(java.lang.String text,
int offset,
int len) |
void |
writeRawUTF8String(byte[] raw,
int offset,
int len) |
void |
writeRawValue(char[] text,
int offset,
int len) |
void |
writeRawValue(java.lang.String text) |
void |
writeRawValue(java.lang.String text,
int offset,
int len) |
void |
writeStartArray() |
void |
writeStartArray(int elementsToWrite) |
void |
writeStartObject() |
void |
writeStartObject(int elementsToWrite) |
void |
writeStartObject(java.lang.Object forValue) |
void |
writeString(char[] text,
int offset,
int len) |
void |
writeString(com.fasterxml.jackson.core.SerializableString sstr) |
void |
writeString(java.lang.String text) |
void |
writeStringField(java.lang.String fieldName,
java.lang.String value) |
void |
writeTag(int tagId)
Method for writing out an explicit CBOR Tag.
|
void |
writeUTF8String(byte[] text,
int offset,
int len) |
_asString, _checkStdFeatureChanges, _constructDefaultPrettyPrinter, _decodeSurrogate, disable, enable, getCodec, getCurrentValue, getFeatureMask, getOutputContext, isClosed, isEnabled, setCodec, setCurrentValue, setFeatureMask, writeObject, writeRawValue, writeTree
_reportError, _reportUnsupportedOperation, _throwInternal, _verifyOffsets, _writeSimpleObject, canOmitFields, canUseSchema, canWriteFormattedNumbers, canWriteObjectId, canWriteTypeId, configure, getCharacterEscapes, getHighestEscapedChar, getPrettyPrinter, getSchema, setCharacterEscapes, setHighestNonEscapedChar, setRootValueSeparator, setSchema, writeArrayFieldStart, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeEmbeddedObject, writeNullField, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectId, writeObjectRef, writeOmittedField, writeRaw, writeString, writeTypeId, writeTypePrefix, writeTypeSuffix
private static final int[] NO_INTS
static final int BYTE_BUFFER_FOR_OUTPUT
private static final int MAX_LONG_STRING_CHARS
private static final int MAX_LONG_STRING_BYTES
private static final int MIN_BUFFER_LENGTH
Note: actually we could live with shorter one; absolute minimum would be for encoding 64-character Strings.
private static final long MIN_INT_AS_LONG
private static final long MAX_INT_AS_LONG
private static final int INDEFINITE_LENGTH
protected final com.fasterxml.jackson.core.io.IOContext _ioContext
protected final java.io.OutputStream _out
protected int _formatFeatures
CBORGenerator.Feature
s are enabled.protected boolean _cfgMinimalInts
protected byte[] _outputBuffer
_out
.protected int _outputTail
_outputBuffer
protected final int _outputEnd
_outputBuffer
.
Typically same as length of the buffer.protected char[] _charBuffer
protected final int _charBufferLength
protected int _bytesWritten
protected int[] _elementCounts
protected int _elementCountsPtr
protected int _currentRemainingElements
INDEFINITE_LENGTH
otherwise.protected boolean _bufferRecyclable
private static final int MAX_SHORT_STRING_CHARS
private static final int MAX_SHORT_STRING_BYTES
private static final int MAX_MEDIUM_STRING_CHARS
private static final int MAX_MEDIUM_STRING_BYTES
public CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int stdFeatures, int formatFeatures, com.fasterxml.jackson.core.ObjectCodec codec, java.io.OutputStream out)
public CBORGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int stdFeatures, int formatFeatures, com.fasterxml.jackson.core.ObjectCodec codec, java.io.OutputStream out, byte[] outputBuffer, int offset, boolean bufferRecyclable)
outputBuffer
- Buffer to use for output before flushing to the underlying streamoffset
- Offset pointing past already buffered content; that is, number
of bytes of valid content to output, within buffer.public com.fasterxml.jackson.core.Version version()
version
in interface com.fasterxml.jackson.core.Versioned
version
in class com.fasterxml.jackson.core.base.GeneratorBase
public boolean canWriteBinaryNatively()
canWriteBinaryNatively
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.JsonGenerator useDefaultPrettyPrinter()
useDefaultPrettyPrinter
in class com.fasterxml.jackson.core.base.GeneratorBase
public com.fasterxml.jackson.core.JsonGenerator setPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp)
setPrettyPrinter
in class com.fasterxml.jackson.core.JsonGenerator
public java.lang.Object getOutputTarget()
getOutputTarget
in class com.fasterxml.jackson.core.JsonGenerator
public int getOutputBuffered()
getOutputBuffered
in class com.fasterxml.jackson.core.JsonGenerator
public int getFormatFeatures()
getFormatFeatures
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.JsonGenerator overrideStdFeatures(int values, int mask)
overrideStdFeatures
in class com.fasterxml.jackson.core.base.GeneratorBase
public com.fasterxml.jackson.core.JsonGenerator overrideFormatFeatures(int values, int mask)
overrideFormatFeatures
in class com.fasterxml.jackson.core.JsonGenerator
public CBORGenerator enable(CBORGenerator.Feature f)
public CBORGenerator disable(CBORGenerator.Feature f)
public final boolean isEnabled(CBORGenerator.Feature f)
public CBORGenerator configure(CBORGenerator.Feature f, boolean state)
public final void writeFieldName(java.lang.String name) throws java.io.IOException
writeFieldName
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeFieldName(com.fasterxml.jackson.core.SerializableString name) throws java.io.IOException
writeFieldName
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public final void writeFieldId(long size) throws java.io.IOException
writeFieldId
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeStringField(java.lang.String fieldName, java.lang.String value) throws java.io.IOException
writeStringField
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void copyCurrentEvent(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
JsonGenerator.copyCurrentEvent(com.fasterxml.jackson.core.JsonParser)
to handle tags.copyCurrentEvent
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void copyCurrentStructure(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
JsonGenerator.copyCurrentStructure(com.fasterxml.jackson.core.JsonParser)
to handle tags.copyCurrentStructure
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
protected void maybeCopyTag(com.fasterxml.jackson.core.JsonParser p) throws java.io.IOException
java.io.IOException
public final void writeStartArray() throws java.io.IOException
writeStartArray
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeStartArray(int elementsToWrite) throws java.io.IOException
writeStartArray
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeEndArray() throws java.io.IOException
writeEndArray
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeStartObject() throws java.io.IOException
writeStartObject
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeStartObject(java.lang.Object forValue) throws java.io.IOException
writeStartObject
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public final void writeStartObject(int elementsToWrite) throws java.io.IOException
java.io.IOException
public final void writeEndObject() throws java.io.IOException
writeEndObject
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeArray(int[] array, int offset, int length) throws java.io.IOException
writeArray
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeArray(long[] array, int offset, int length) throws java.io.IOException
writeArray
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeArray(double[] array, int offset, int length) throws java.io.IOException
writeArray
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
private final void _pushRemainingElements()
private final void _writeNumberNoCheck(int i) throws java.io.IOException
java.io.IOException
private final void _writeNumberNoCheck(long l) throws java.io.IOException
java.io.IOException
private final void _writeNumberNoCheck(double d) throws java.io.IOException
java.io.IOException
public void writeString(java.lang.String text) throws java.io.IOException
writeString
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeString(com.fasterxml.jackson.core.SerializableString sstr) throws java.io.IOException
writeString
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void writeString(char[] text, int offset, int len) throws java.io.IOException
writeString
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeRawUTF8String(byte[] raw, int offset, int len) throws java.io.IOException
writeRawUTF8String
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public final void writeUTF8String(byte[] text, int offset, int len) throws java.io.IOException
writeUTF8String
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeRaw(java.lang.String text) throws java.io.IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeRaw(java.lang.String text, int offset, int len) throws java.io.IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeRaw(char[] text, int offset, int len) throws java.io.IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeRaw(char c) throws java.io.IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeRawValue(java.lang.String text) throws java.io.IOException
writeRawValue
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void writeRawValue(java.lang.String text, int offset, int len) throws java.io.IOException
writeRawValue
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void writeRawValue(char[] text, int offset, int len) throws java.io.IOException
writeRawValue
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) throws java.io.IOException
writeBinary
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public int writeBinary(java.io.InputStream data, int dataLength) throws java.io.IOException
writeBinary
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public int writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, java.io.InputStream data, int dataLength) throws java.io.IOException
writeBinary
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void writeBoolean(boolean state) throws java.io.IOException
writeBoolean
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNull() throws java.io.IOException
writeNull
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNumber(int i) throws java.io.IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNumber(long l) throws java.io.IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNumber(java.math.BigInteger v) throws java.io.IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
protected void _write(java.math.BigInteger v) throws java.io.IOException
java.io.IOException
public void writeNumber(double d) throws java.io.IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNumber(float f) throws java.io.IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNumber(java.math.BigDecimal dec) throws java.io.IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
public void writeNumber(java.lang.String encodedValue) throws java.io.IOException, com.fasterxml.jackson.core.JsonGenerationException, java.lang.UnsupportedOperationException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
java.io.IOException
com.fasterxml.jackson.core.JsonGenerationException
java.lang.UnsupportedOperationException
protected final void _verifyValueWrite(java.lang.String typeMsg) throws java.io.IOException
_verifyValueWrite
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
private void _failSizedArrayOrObject() throws java.io.IOException
java.io.IOException
public final void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class com.fasterxml.jackson.core.base.GeneratorBase
java.io.IOException
public void writeTag(int tagId) throws java.io.IOException
tagId
- Positive integer (0 or higher)java.io.IOException
public void writeRaw(byte b) throws java.io.IOException
NOTE: only use this method if you really know what you are doing.
java.io.IOException
public void writeBytes(byte[] data, int offset, int len) throws java.io.IOException
NOTE: only use this method if you really know what you are doing.
java.io.IOException
protected final void _writeString(java.lang.String name) throws java.io.IOException
java.io.IOException
protected final void _ensureSpace(int needed) throws java.io.IOException
java.io.IOException
protected final void _writeString(char[] text, int offset, int len) throws java.io.IOException
java.io.IOException
protected final void _writeChunkedString(char[] text, int offset, int len) throws java.io.IOException
java.io.IOException
private final int _encode(int outputPtr, char[] str, int i, int end)
private final int _shortUTF8Encode2(char[] str, int i, int end, int outputPtr, int outputStart)
private final int _encode(int outputPtr, java.lang.String str, int len)
private final int _encode2(int i, int outputPtr, java.lang.String str, int len, int outputStart)
private int _convertSurrogate(int firstPart, int secondPart)
private void _throwIllegalSurrogate(int code)
private final void _ensureRoomForOutput(int needed) throws java.io.IOException
java.io.IOException
private final void _writeIntValue(int i) throws java.io.IOException
java.io.IOException
private final void _writeLongValue(long l) throws java.io.IOException
java.io.IOException
private final void _writeLengthMarker(int majorType, int i) throws java.io.IOException
java.io.IOException
private final void _writeByte(byte b) throws java.io.IOException
java.io.IOException
private final void _writeBytes(byte[] data, int offset, int len) throws java.io.IOException
java.io.IOException
private final int _writeBytes(java.io.InputStream in, int bytesLeft) throws java.io.IOException
java.io.IOException
private final void _writeBytesLong(byte[] data, int offset, int len) throws java.io.IOException
java.io.IOException
protected void _releaseBuffers()
_releaseBuffers
in class com.fasterxml.jackson.core.base.GeneratorBase
protected final void _flushBuffer() throws java.io.IOException
java.io.IOException
private final void closeComplexElement() throws java.io.IOException
java.io.IOException
protected java.lang.UnsupportedOperationException _notSupported()