JsonGenerator implementation that writes CBOR encoded content.
| Modifier and Type | Field and Description |
|---|---|
| protected boolean | _bufferRecyclable
Flag that indicates whether the output buffer is recyclable (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 final boolean | |
| protected final boolean | |
| protected char[] | _charBuffer
Intermediate buffer in which characters of a String are copied before being encoded. |
| protected final int | |
| protected int | _currentRemainingElements
Number of elements remaining in the current complex structure (if any), when writing defined-length Arrays, Objects; marker {code INDEFINITE_LENGTH} otherwise. |
| protected int[] | |
| protected int | |
| protected final int | _formatFeatures
Bit flag composed of bits that indicate which
|
| protected final OutputStream | |
| protected byte[] | _outputBuffer
Intermediate buffer in which contents are buffered before being written
using |
| protected final int | _outputEnd
Offset to index after the last valid index in |
| protected int | _outputTail
Pointer to the next available byte in |
| protected CBORWriteContext | |
| protected HashMap | _stringRefs
Table of previously referenced text and binary strings when the STRINGREF feature is used. |
| private static final BigInteger | |
| protected static final 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 final int | INDEFINITE_LENGTH
Special value that is use to keep tracks of arrays and maps opened with infinite length |
| private static final int | MAX_LONG_STRING_BYTES
This is the worst case length (in bytes) of maximum chunk we ever write. |
| private static final 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 final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final 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 final int[] | |
| protected static final int | REPLACEMENT_CHAR
The replacement character to use to fix invalid Unicode sequences (mismatched surrogate pair). |
| Access | Constructor and Description |
|---|---|
| public | CBORGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, int streamWriteFeatures, int formatFeatures, OutputStream out)
|
| public | CBORGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, int streamWriteFeatures, int formatFeatures, OutputStream out, byte[]
Buffer to use for output before flushing to the underlying stream outputBuffer, int Offset pointing past already buffered content; that is, number
of bytes of valid content to output, within buffer. offset, boolean bufferRecyclable)Alternative constructor that may be used to feed partially initialized content. |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| protected void | |
| private int | |
| private final 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 final int | |
| private final int | |
| private final void | |
| protected final void | |
| private void | |
| protected final void | |
| private int | |
| private int | |
| protected UnsupportedOperationException | |
| private final void | |
| protected void | _releaseBuffers()
Implements abstract tools. Method called to release any buffers generator may be holding, once generator is being closed. |
| private final 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. |
| protected final void | _verifyValueWrite(String typeMsg)
Implements abstract tools. Method called before trying to write a value (scalar or structured), to verify that this is legal in current output state, as well as to output separators if and as necessary. |
| protected void | |
| private final void | |
| private final void | |
| private final int | |
| private final void | |
| protected final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| protected final void | |
| protected final int | |
| public void | assignCurrentValue(Object v)
Implements abstract tools. Helper method, usually equivalent to:
|
| private final void | |
| public Object | currentValue()
Implements abstract tools. Helper method, usually equivalent to:
Note that "current value" is NOT populated (or used) by Streaming generator; it is only used by higher-level data-binding functionality. |
| public final void | flush()
Implements abstract tools. Implements java. Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well. |
| public PrettyPrinter | getPrettyPrinter()
Overrides tools. Accessor for object that handles pretty-printing (usually additional white space to make results more human-readable) during output. |
| public final boolean | |
| public JacksonFeatureSet | streamWriteCapabilities()
Implements abstract tools. Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly). |
| public TokenStreamContext | streamWriteContext()
Implements abstract tools. Accessor for context object that provides information about low-level logical position withing output token stream. |
| public int | streamWriteOutputBuffered()
Implements abstract tools. Method for verifying amount of content that is buffered by generator but not yet flushed to the underlying target (stream, writer), in units (byte, char) that the generator implementation uses for buffering; or -1 if this information is not available. |
| public Object | streamWriteOutputTarget()
Implements abstract tools. Method that can be used to get access to object that is used
as target for generated output; this is usually either
|
| public Version | version()
Implements abstract tools. Implements tools. Accessor for finding out version of the bundle that provided this generator instance. |
| public JsonGenerator | writeArray(int[] array, int offset, int length)
Overrides tools. Value write method that can be called to write a single
array (sequence of |
| public JsonGenerator | writeArray(long[] array, int offset, int length)
Overrides tools. Value write method that can be called to write a single
array (sequence of |
| public JsonGenerator | writeArray(double[] array, int offset, int length)
Overrides tools. Value write method that can be called to write a single
array (sequence of |
| public JsonGenerator | writeBinary(Base64Variant b64variant, byte[] data, int offset, int len)
Implements abstract tools. Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes). |
| public int | writeBinary(InputStream data, int dataLength)
Overrides tools. Similar to |
| public int | writeBinary(Base64Variant b64variant, InputStream data, int dataLength)
Overrides tools. Method similar to |
| public JsonGenerator | writeBoolean(boolean state)
Implements abstract tools. Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). |
| public JsonGenerator | writeBytes(byte[] data, int offset, int len)
Method for directly inserting specified bytes in output at current position. |
| public JsonGenerator | writeEndArray()
Implements abstract tools. Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeEndObject()
Implements abstract tools. Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeName(String name)
Implements abstract tools. Method for writing an Object Property name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled. |
| public JsonGenerator | writeName(SerializableString name)
Overrides tools. Method similar to |
| public JsonGenerator | writeNull()
Implements abstract tools. Method for outputting literal JSON null value. |
| public JsonGenerator | writeNumber(short v)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(int i)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(long l)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(BigInteger v)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(double d)
Implements abstract tools. Method for outputting indicate JSON numeric value. |
| public JsonGenerator | writeNumber(float f)
Implements abstract tools. Method for outputting indicate JSON numeric value. |
| public JsonGenerator | writeNumber(BigDecimal dec)
Implements abstract tools. Method for outputting indicate JSON numeric value. |
| public JsonGenerator | writeNumber(String encodedValue)
Implements abstract tools. Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types. |
| public void | writeNumberUnsigned(int
Number value to write i)Method for outputting given value as an unsigned integer. |
| public void | writeNumberUnsigned(long
Number value to write l)Method for outputting given value as an unsigned integer. |
| public JsonGenerator | writePropertyId(long id)
Implements abstract tools. Alternative to |
| public JsonGenerator | writeRaw(String text)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRaw(String text, int offset, int len)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRaw(char[] text, int offset, int len)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRaw(char c)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | |
| public JsonGenerator | writeRawUTF8String(byte[] raw, int offset, int len)
Implements abstract tools. Method similar to |
| public JsonGenerator | writeRawValue(String text)
Overrides tools. Method that will force generator to copy input text verbatim without any modifications, but assuming it must constitute a single legal JSON value (number, string, boolean, null, Array or List). |
| public JsonGenerator | writeRawValue(String text, int offset, int len)
Overrides tools.
|
| public JsonGenerator | writeRawValue(char[] text, int offset, int len)
Overrides tools.
|
| public JsonGenerator | writeStartArray()
Implements abstract tools. Method for writing starting marker of a Array value (for JSON this is character '['; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeStartArray(Object currValue)
Implements abstract tools. Method for writing start marker of an Array value, similar
to |
| public JsonGenerator | writeStartArray(Object forValue, int elementsToWrite)
Overrides tools. Method for writing start marker of an Array value, similar
to |
| public JsonGenerator | writeStartObject()
Implements abstract tools. Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeStartObject(Object forValue)
Implements abstract tools. Method for writing starting marker of an Object value to represent the given Java Object value. |
| public JsonGenerator | writeStartObject(Object forValue, int elementsToWrite)
Overrides tools. Method for writing starting marker of an Object value to represent the given Java Object value. |
| public JsonGenerator | writeString(String text)
Implements abstract tools. Method for outputting a String value. |
| public JsonGenerator | writeString(SerializableString sstr)
Overrides tools. Method similar to |
| public JsonGenerator | writeString(char[] text, int offset, int len)
Implements abstract tools. Method for outputting a String value. |
| public JsonGenerator | |
| public JsonGenerator | writeUTF8String(byte[] text, int offset, int len)
Implements abstract tools. Method similar to |