JsonToken
sequences, needed for temporary buffering.
Space efficient for different sequence lengths (especially so for smaller
ones; but not significantly less efficient for larger), highly efficient
for linear iteration and appending. Implemented as segmented/chunked
linked list of tokens; only modifications are via appends.
| Modifier and Type | Class and Description |
|---|---|
| protected static class | |
| protected static class | TokenBuffer.
Individual segment of TokenBuffer that can store up to 16 tokens (limited by 4 bits per token type marker requirement). |
| Modifier and Type | Field and Description |
|---|---|
| protected int | _appendAt
Offset within last segment, |
| protected boolean | |
| protected TokenBuffer. | _first
First segment, for contents this buffer has |
| protected boolean | _forceBigDecimal
Flag set during construction, if use of |
| protected int | _generatorFeatures
Bit flag composed of bits that indicate which
|
| protected boolean | _hasNativeId
Do we currently have a native type or object id buffered? |
| protected boolean | |
| protected boolean | |
| protected TokenBuffer. | _last
Last segment of this buffer, one that is used for appending more tokens |
| protected boolean | |
| protected ObjectCodec | _objectCodec
Object codec to use for stream-based object conversion through parser/generator interfaces. |
| protected Object | _objectId
If native object ids supported, this is the id for following value (or first token of one) to be written. |
| protected JsonStreamContext | _parentContext
Parse context from "parent" parser (one from which content to buffer is read, if specified). |
| protected StreamReadConstraints | |
| protected Object | _typeId
If native type ids supported, this is the id for following value (or first token of one) to be written. |
| protected JsonWriteContext | |
| protected static final int |
| Access | Constructor and Description |
|---|---|
| public | TokenBuffer(ObjectCodec
Object codec to use for stream-based object
conversion through parser/generator interfaces. If null,
such methods cannot be used. codec, boolean Whether resulting hasNativeIds)JsonParser (if created)
is considered to support native type and object ids
|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | _appendEndMarker(JsonToken type)
Specialized method used for appending a structural end Object/Array marker |
| protected final void | _appendFieldName(Object value)
Specialized method used for appending a field name, appending either
|
| private final void | |
| protected final void | _appendStartMarker(JsonToken type)
Specialized method used for appending a structural start Object/Array marker |
| protected final void | _appendValue(JsonToken type)
Method used for appending token known to represent a "simple" scalar value where token is the only information |
| protected final void | _appendValue(JsonToken type, Object value)
Method used for appending token known to represent a scalar value where there is additional content (text, number) beyond type token |
| private final void | |
| protected void | |
| private void | |
| protected void | |
| public TokenBuffer | Returns: This bufferHelper method that will append contents of given buffer into this buffer. |
| public static TokenBuffer | asCopyOfValue(JsonParser p)
Deprecated
Since 2.13: use
DeserializationContext#bufferAsCopyOfValue instead.
Convenience method, equivalent to: TokenBuffer b = new TokenBuffer(p); b.copyCurrentStructure(p); return b; |
| public JsonParser | Returns: Parser that can be used for reading contents stored in this bufferMethod used to create a |
| public JsonParser | Returns: Parser that can be used for reading contents stored in this bufferObject codec to use for stream-based object
conversion through parser/generator interfaces. If null,
such methods cannot be used. codec)Method used to create a |
| public JsonParser | |
| public JsonParser | asParser(JsonParser
Parser to use for accessing source information
like location, configured codec, streamReadConstraints src)
|
| public JsonParser | |
| public boolean | canWriteBinaryNatively()
Overrides com. Since we can efficiently store |
| public boolean | canWriteObjectId()
Overrides com. Introspection method that may be called to see if the underlying data format supports some kind of Object Ids natively (many do not; for example, JSON doesn't). |
| public boolean | canWriteTypeId()
Overrides com. Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't). |
| public void | close()
Implements abstract com. Implements java. Method called to close this generator, so that no more content can be written. |
| public void | copyCurrentEvent(JsonParser
Parser that points to event (token) to copy p)Overrides com. Method for copying contents of the current event that the given parser instance points to. |
| public void | copyCurrentStructure(JsonParser
Parser that points to the value to copy p)Overrides com. Method for copying contents of the current event and following events that it encloses the given parser instance points to. |
| public TokenBuffer | |
| public JsonGenerator | disable(JsonGenerator.
Feature to disable fImplements abstract com. Method for disabling specified feature
(check |
| public JsonGenerator | enable(JsonGenerator.
Feature to enable fImplements abstract com. Method for enabling specified generator feature:
check |
| public JsonToken | |
| public void | flush()
Implements abstract com. 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 TokenBuffer | |
| public ObjectCodec | getCodec()
Implements abstract com. Method for accessing the object used for writing Java
object as JSON content
(using method |
| public int | getFeatureMask()
Implements abstract com. Bulk access method for getting state of all standard (non-dataformat-specific)
|
| public final JsonWriteContext | getOutputContext()
Implements abstract com. Accessor for context object that provides information about low-level logical position withing output token stream. |
| public JacksonFeatureSet | getWriteCapabilities()
Overrides com. Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly). |
| public boolean | isClosed()
Implements abstract com. Method that can be called to determine whether this generator is closed or not. |
| public boolean | Returns: True if this buffer instance has no tokensAccessor for checking whether this buffer has one or more tokens or not. |
| public boolean | isEnabled(JsonGenerator.
Feature to check fImplements abstract com. Method for checking whether given feature is enabled. |
| public TokenBuffer | overrideParentContext(JsonStreamContext ctxt)
Method that allows explicitly specifying parent parse context to associate with contents of this buffer. |
| public JsonGenerator | overrideStdFeatures(int
Bit mask of set/clear state for features to change values, int Bit mask of features to change mask)Overrides com. Bulk set method for (re)setting states of features specified by |
| public void | serialize(JsonGenerator gen)
Helper method that will write all contents of this buffer
using given |
| public JsonGenerator | setCodec(ObjectCodec
Codec to assign, if any; oc)null if noneImplements abstract com. Method that can be called to set or reset the object to
use for writing Java objects as JsonContent
(using method |
| public JsonGenerator | setFeatureMask(int
Bitmask that defines which mask)Features are enabled
and which disabledImplements abstract com.
Deprecated
Bulk set method for (re)setting states of all standard |
| public String | |
| public JsonGenerator | useDefaultPrettyPrinter()
Implements abstract com. Convenience method for enabling pretty-printing using
the default pretty printer
( |
| public Version | version()
Implements abstract com. Implements com. Accessor for finding out version of the bundle that provided this generator instance. |
| 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. Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes). |
| 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.Implements abstract com. Although we could support this method, it does not necessarily make sense: we cannot make good use of streaming because buffer must hold all the data. |
| public void | writeBoolean(boolean
Boolean value to write state)Implements abstract com. Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). |
| public void | writeEmbeddedObject(Object
Native format-specific value to write object)Overrides com. Method that can be called on backends that support passing opaque native values that some data formats support; not used with JSON backend, more common with binary formats. |
| public final void | writeEndArray()
Implements abstract com. Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled). |
| public final void | writeEndObject()
Implements abstract com. Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled). |
| public final void | writeFieldName(String
Field name to write name)Implements abstract com. Method for writing a field 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 void | writeFieldName(SerializableString
Field name to write name)Implements abstract com. Method similar to |
| private void | |
| private void | |
| public void | writeNull()
Implements abstract com. Method for outputting literal JSON null value. |
| public void | writeNumber(short
Number value to write i)Overrides com. Method for outputting given value as JSON number. |
| public void | writeNumber(int
Number value to write i)Implements abstract com. Method for outputting given value as JSON number. |
| public void | writeNumber(long
Number value to write l)Implements abstract com. Method for outputting given value as JSON number. |
| public void | writeNumber(double
Number value to write d)Implements abstract com. Method for outputting indicate JSON numeric value. |
| public void | writeNumber(float
Number value to write f)Implements abstract com. Method for outputting indicate JSON numeric value. |
| public void | writeNumber(BigDecimal
Number value to write dec)Implements abstract com. Method for outputting indicate JSON numeric value. |
| public void | writeNumber(BigInteger
Number value to write v)Implements abstract com. Method for outputting given value as JSON number. |
| public void | writeNumber(String
Textual (possibly formatted) number representation to write encodedValue)Implements abstract com. Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types. |
| public void | writeNumber(String
Textual (possibly formatted) number representation to write encodedValue, boolean Whether value should be considered an integer isInteger)Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types. |
| public void | writeObject(Object
Java value (usually POJO) to write value)Implements abstract com. Older alias for |
| public void | writeObjectId(Object
Native Object Id to write id)Overrides com. Method that can be called to output so-called native Object Id.
Note that it may only be called after ensuring this is legal
(with |
| public void | writeRaw(String
Textual contents to include as-is in output. text)Implements abstract com. 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 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. 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 void | writeRaw(SerializableString
Pre-encoded textual contents to included in output text)Overrides com. 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 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. 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 void | writeRaw(char
Character to included in output c)Implements abstract com. 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 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 length)Implements abstract com. Method similar to |
| public void | writeRawValue(String
Textual contents to included in output text)Implements abstract com. 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 void | writeRawValue(String text, int offset, int len)
Implements abstract com.
|
| public void | writeRawValue(char[] text, int offset, int len)
Implements abstract com.
|
| public final void | writeStartArray()
Implements abstract com. 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 void | writeStartArray(Object
"Current value" to assign for the Array context being created forValue)Overrides com. Method for writing start marker of an Array value, similar
to |
| public 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
size)writeEndArray() MUST match; generator MAY verify
this is the case (and SHOULD if format itself encodes length)Overrides com. Method for writing start marker of an Array value, similar
to |
| public final void | writeStartObject()
Implements abstract com. Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled). |
| public void | writeStartObject(Object
"Current value" to assign for the Object context being created forValue)Overrides com. Method for writing starting marker of an Object value to represent the given Java Object value. |
| 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
size)writeEndObject() MUST match; generator MAY verify
this is the case (and SHOULD if format itself encodes length)Overrides com. Method for writing starting marker of an Object value to represent the given Java Object value. |
| public void | writeString(String
Text value to write text)Implements abstract com. Method for outputting a String value. |
| 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. Method for outputting a String value. |
| public void | writeString(SerializableString
Pre-encoded String value to write text)Implements abstract com. Method similar to |
| public void | writeString(Reader
Reader to use for reading Text value to write reader, final int Maximum Length of Text value to read (in len)chars, non-negative)
if known; -1 to indicate "read and write it all"Overrides com. Method for outputting a String value. |
| public void | writeTree(TreeNode
TreeNode to writeImplements abstract com. Method for writing given JSON tree (expressed as a tree where given JsonNode is the root) using this generator. |
| public void | writeTypeId(Object
Native Type Id to write id)Overrides com. Method that can be called to output so-called native Type Id.
Note that it may only be called after ensuring this is legal
(with |
| public 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 length)Implements abstract com. Method similar to |