JsonGenerator implementation for Smile-encoded content
(see Smile Format Specification)
| Modifier and Type | Class and Description |
|---|---|
| public static enum | SmileGenerator.Feature
Enumeration that defines all togglable features for Smile generators. |
| public static class | SmileGenerator.SharedStringNode
Helper class used for keeping track of possibly shareable String references (for field names and/or short String values) |
| 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 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 int | _seenNameCount
Number of entries in |
| protected SmileGenerator. | _seenNames
Raw data structure used for checking whether field name to write can be output using back reference or not. |
| protected int | _seenStringValueCount
Number of entries in |
| protected SmileGenerator. | _seenStringValues
Raw data structure used for checking whether String value to write can be output using back reference or not. |
| protected final StreamWriteConstraints | |
| protected SmileWriteContext | |
| protected static final int | |
| protected static final int | |
| protected static final long | |
| 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. |
| protected static final long | |
| protected static final int | REPLACEMENT_CHAR
The replacement character to use to fix invalid Unicode sequences (mismatched surrogate pair). |
| protected static final byte | |
| protected static final byte | |
| protected static final byte | |
| protected static final byte | |
| protected static final byte | |
| protected static final byte | |
| protected static final byte |
| Access | Constructor and Description |
|---|---|
| public | SmileGenerator(IOContext ioCtxt, int stdFeatures, int smileFeatures, ObjectCodec codec, OutputStream out)
|
| public | SmileGenerator(IOContext ioCtxt, int stdFeatures, int smileFeatures, ObjectCodec codec, OutputStream out, byte[] outputBuffer, int offset, boolean bufferRecyclable)
|
| Modifier and Type | Method and Description |
|---|---|
| private final void | |
| private final void | |
| private int | |
| private int | |
| private final void | |
| private final int | |
| private final int | |
| protected final void | |
| private int | |
| private int | |
| private void | |
| private void | |
| protected UnsupportedOperationException | |
| private int | |
| protected void | _releaseBuffers()
Implements abstract com. |
| private final int | _shortUTF8Encode(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 | _shortUTF8Encode2(char[] str, int i, int end, int outputPtr)
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 final int | |
| private static final boolean | _validBackRef(int index)
Helper method used to ensure that we do not use back-reference values that would produce illegal byte sequences (ones with byte 0xFE or 0xFF). |
| protected final void | _verifyValueWrite(String
Additional message used for generating exception message
if value output is NOT legal in current generator output state. typeMsg)Implements abstract com. |
| protected void | |
| protected int | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final void | |
| private final int | |
| private final void | |
| protected void | |
| private final void | |
| protected final void | |
| protected final void | |
| protected void | |
| private final void | |
| private final void | _writeNonSharedString(final String text, final int len)
Helper method called to handle cases where String value to write is known to be long enough not to be shareable. |
| private final void | |
| private final int | |
| private final int | |
| private final int | |
| private void | |
| private final void | |
| private final void | |
| private void | _writeSignedVInt(int input)
Helper method for writing 32-bit signed value, using "zig zag encoding" (see protocol buffers for explanation -- basically, sign bit is moved as LSB, rest of value shifted left by one) coupled with basic variable length encoding |
| public void | assignCurrentValue(Object
Current value to assign for the current context of this generator v)Overrides com.
getOutputContext().setCurrentValue(v);
|
| public boolean | canWriteBinaryNatively()
Overrides com. |
| public void | close()
Overrides com. Implements java. |
| public SmileGenerator | |
| public Object | currentValue()
Overrides com.
getOutputContext().getCurrentValue();
Note that "current value" is NOT populated (or used) by Streaming parser or generators; it is only used by higher-level data-binding functionality. |
| public SmileGenerator | |
| public SmileGenerator | |
| public final void | flush()
Implements abstract com. Implements java. |
| public Object | getCurrentValue()
Overrides com. currentValue(), to be deprecated in later
Jackson 2.x versions (and removed from Jackson 3.0).
|
| public int | getFormatFeatures()
Overrides com. FormatFeatures, format-specific
on/off configuration settings.
|
| public int | getOutputBuffered()
Overrides com. |
| public JsonStreamContext | getOutputContext()
Overrides com. Note type was co-variant until Jackson 2.7; reverted back to base type in 2.8 to allow for overriding by subtypes that use custom context type. |
| public Object | getOutputTarget()
Overrides com. OutputStream or Writer, depending on what
generator was constructed with.
|
| public JacksonFeatureSet | getWriteCapabilities()
Overrides com. |
| public final boolean | |
| protected long | outputOffset()
Method for accessing offset of the next byte within the whole output stream that this generator has produced. |
| public JsonGenerator | overrideFormatFeatures(int
Bit mask of set/clear state for features to change values, int Bit mask of features to change mask)Overrides com. FormatFeatures,
by specifying values (set / clear) along with a mask, to determine
which features to change, if any.
|
| public void | setCurrentValue(Object
Current value to assign for the current context of this generator v)Overrides com. assignCurrentValue, to be deprecated in later
Jackson 2.x versions (and removed from Jackson 3.0).
|
| public JsonGenerator | setPrettyPrinter(PrettyPrinter
PrettyPrinter to assign, if any; null if noneOverrides com. |
| public StreamWriteConstraints | streamWriteConstraints()
Overrides com. |
| public JsonGenerator | useDefaultPrettyPrinter()
Overrides com. |
| public Version | version()
Overrides com. Implements com. |
| public void | writeArray(int[]
Array that contains values to write array, int Offset of the first element to write, within array offset, int Number of elements in array to write, from `offset` to `offset + len - 1` length)Overrides com. JsonToken#START_ARRAY, zero or
more JsonToken#VALUE_NUMBER_INT, JsonToken#END_ARRAY)
|
| public void | writeArray(long[]
Array that contains values to write array, int Offset of the first element to write, within array offset, int Number of elements in array to write, from `offset` to `offset + len - 1` length)Overrides com. JsonToken#START_ARRAY, zero or
more JsonToken#VALUE_NUMBER_INT, JsonToken#END_ARRAY)
|
| public void | writeArray(double[]
Array that contains values to write array, int Offset of the first element to write, within array offset, int Number of elements in array to write, from `offset` to `offset + len - 1` length)Overrides com. JsonToken#START_ARRAY, zero or
more JsonToken#VALUE_NUMBER_FLOAT, JsonToken#END_ARRAY)
|
| public void | writeBinary(Base64Variant
Base64 variant to use: defines details such as
whether padding is used (and if so, using which character);
what is the maximum line length before adding linefeed,
and also the underlying alphabet to use. b64variant, byte[] Buffer that contains binary data to write data, int Offset in offset, int data of the first byte of data to writeLength of data to write len)Implements abstract com. |
| public int | writeBinary(InputStream
InputStream to use for reading binary data to write.
Will not be closed after successful write operation data, int (optional) number of bytes that will be available;
or -1 to be indicate it is not known. Note that implementations
need not support cases where length is not known in advance; this
depends on underlying data format: JSON output does NOT require length,
other formats may dataLength)Overrides com. writeBinary(Base64Variant, InputStream, int),
but assumes default to using the Jackson default Base64 variant
(which is Base64Variants#MIME_NO_LINEFEEDS).
|
| public int | writeBinary(Base64Variant
Base64 variant to use b64variant, InputStream InputStream to use for reading binary data to write.
Will not be closed after successful write operation data, int (optional) number of bytes that will be available;
or -1 to be indicate it is not known.
If a positive length is given, dataLength)data MUST provide at least
that many bytes: if not, an exception will be thrown.
Note that implementations
need not support cases where length is not known in advance; this
depends on underlying data format: JSON output does NOT require length,
other formats may.Overrides com. writeBinary(Base64Variant, byte[], int, int),
but where input is provided through a stream, allowing for incremental
writes without holding the whole input in memory.
|
| public void | writeBoolean(boolean
Boolean value to write state)Implements abstract com. |
| public void | writeBytes(byte[] data, int offset, int len)
Method for directly inserting specified bytes in output at current position. |
| public final void | writeEndArray()
Implements abstract com. |
| public final void | writeEndObject()
Implements abstract com. |
| public final void | writeFieldName(String
Field name to write name)Implements abstract com. |
| public final void | writeFieldName(SerializableString
Field name to write name)Overrides com. writeFieldName(String), main difference
being that it may perform better as some of processing (such as
quoting of certain characters, or encoding into external encoding
if supported by generator) can be done just once and reused for
later calls.
|
| public void | |
| public void | writeNull()
Implements abstract com. |
| public void | writeNumber(int
Number value to write i)Implements abstract com. |
| public void | writeNumber(long
Number value to write l)Implements abstract com. |
| public void | writeNumber(BigInteger
Number value to write v)Implements abstract com. |
| public void | writeNumber(double
Number value to write d)Implements abstract com. |
| public void | writeNumber(float
Number value to write f)Implements abstract com. |
| public void | writeNumber(BigDecimal
Number value to write dec)Implements abstract com. |
| public void | writeNumber(String
Textual (possibly format) number representation to write encodedValue)Implements abstract com. |
| public void | |
| public void | writeRaw(String
Textual contents to include as-is in output. text)Implements abstract com. |
| public void | writeRaw(String
String that has contents to include as-is in output text, int Offset within offset, int text of the first character to outputLength of content (from len)text, starting at offset offset) to outputImplements abstract com. |
| public void | writeRaw(char[]
Buffer that has contents to include as-is in output text, int Offset within offset, int text of the first character to outputLength of content (from len)text, starting at offset offset) to outputImplements abstract com. |
| public void | writeRaw(char
Character to included in output c)Implements abstract com. |
| public void | writeRawUTF8String(byte[]
Buffer that contains String value to write text, int Offset in offset, int buffer of the first byte of String value to writeLength of the String value (in characters) to write len)Implements abstract com. writeString(String) but that takes as
its input a UTF-8 encoded String that is to be output as-is, without additional
escaping (type of which depends on data format; backslashes for JSON).
|
| public void | writeRawValue(String
Textual contents to included in output text)Overrides com. |
| public void | writeRawValue(String text, int offset, int len)
Overrides com. |
| public void | writeRawValue(char[] text, int offset, int len)
Overrides com. |
| public final void | writeStartArray()
Implements abstract com. |
| public final void | writeStartArray(Object
"Current value" to assign for the Array context being created forValue)Overrides com. writeStartArray(),
but also specifying the "current value"
to assign to the new Array context being created.
|
| public final void | writeStartArray(Object
"Current value" to assign for the Array context being created forValue, int Number of elements this Array will have: actual
number of values written (before matching call to
elementsToWrite)writeEndArray() MUST match; generator MAY verify
this is the case (and SHOULD if format itself encodes length)Overrides com. writeStartArray(), but also specifying the "current value"
to assign to the new Array context being created
as well as how many elements will be written for the array before calling
writeEndArray().
|
| public final void | writeStartArray(int
Number of elements this array will have: actual
number of values written (before matching call to
size)writeEndArray() MUST match; generator MAY verify
this is the case (and SHOULD if format itself encodes length)Overrides com.
Deprecated
Method for writing start marker of an Array value, similar
to writeStartArray(),
but also specifying how many
elements will be written for the array before calling
writeEndArray().
|
| public final void | writeStartObject()
Implements abstract com. |
| public final void | writeStartObject(Object
"Current value" to assign for the Object context being created forValue)Overrides com. |
| public void | writeStartObject(Object
"Current value" to assign for the Object context being created forValue, int Number of key/value pairs this Object will have: actual
number of entries written (before matching call to
elementsToWrite)writeEndObject() MUST match; generator MAY verify
this is the case (and SHOULD if format itself encodes length)Overrides com. |
| public void | writeString(String
Text value to write text)Implements abstract com. |
| public void | writeString(char[]
Buffer that contains String value to write text, int Offset in offset, int buffer of the first character of String value to writeLength of the String value (in characters) to write len)Implements abstract com. |
| public final void | writeString(SerializableString
Pre-encoded String value to write sstr)Overrides com. writeString(String), but that takes
SerializableString which can make this potentially
more efficient to call as generator may be able to reuse
quoted and/or encoded representation.
|
| public final void | writeUTF8String(byte[]
Buffer that contains String value to write text, int Offset in offset, int buffer of the first byte of String value to writeLength of the String value (in characters) to write len)Implements abstract com. writeString(String) but that takes as its input
a UTF-8 encoded String which has not been escaped using whatever
escaping scheme data format requires (for JSON that is backslash-escaping
for control characters and double-quotes; for other formats something else).
|