Top Description Inners Fields Constructors Methods
tools.jackson.databind.util

public Class TokenBuffer

extends JsonGenerator
Class Inheritance
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.util.Arrays, .TreeMap, tools.jackson.core.*, tools.jackson.core.base.ParserMinimalBase, tools.jackson.core.exc.InputCoercionException, .StreamWriteException, .UnexpectedEndOfInputException, tools.jackson.core.io.CharacterEscapes, .NumberInput, .NumberOutput, tools.jackson.core.sym.PropertyNameMatcher, tools.jackson.core.util.ByteArrayBuilder, .JacksonFeatureSet, .SimpleStreamWriteContext, tools.jackson.databind.*

Utility class used for efficient storage of 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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
protected static class
TokenBuffer.Segment

Individual segment of TokenBuffer that can store up to 16 tokens (limited by 4 bits per token type marker requirement).

Field Summary

Modifier and TypeField and Description
protected int
_appendAt

Offset within last segment,

protected boolean
protected TokenBuffer.Segment
_first

First segment, for contents this buffer has

protected boolean
_forceBigDecimal

Flag set during construction, if use of BigDecimal is to be forced on all floating-point values.

protected boolean
_hasNativeId

Do we currently have a native type or object id buffered?

protected boolean
protected boolean
protected TokenBuffer.Segment
_last

Last segment of this buffer, one that is used for appending more tokens

protected boolean
protected Object
_objectId

If native object ids supported, this is the id for following value (or first token of one) to be written.

protected ObjectWriteContext
protected TokenStreamContext
_parentContext

Parse context from "parent" parser (one from which content to buffer is read, if specified).

protected final StreamReadConstraints
protected int
_streamWriteFeatures

Bit flag composed of bits that indicate which StreamWriteFeatures are enabled.

protected SimpleStreamWriteContext
protected Object
_typeId

If native type ids supported, this is the id for following value (or first token of one) to be written.

protected static final JacksonFeatureSet<StreamWriteCapability>
protected static final int

Constructor Summary

AccessConstructor and Description
public
TokenBuffer(boolean
Whether resulting JsonParser (if created) is considered to support native type and object ids
hasNativeIds
)
Deprecated

public
TokenBuffer(ObjectWriteContext writeContext, boolean hasNativeIds)

protected

Method Summary

Modifier and TypeMethod and Description
protected final void
_appendEndMarker(JsonToken type)

Specialized method used for appending a structural end Object/Array marker

protected final void
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 <T> T
public TokenBuffer

Returns:

This buffer
append
(TokenBuffer other)

Helper method that will append contents of given buffer into this buffer.

public JsonParser

Returns:

Parser that can be used for reading contents stored in this buffer
asParser
()

Method used to create a JsonParser that can read contents stored in this buffer.

public JsonParser

Returns:

Parser that can be used for reading contents stored in this buffer
asParser
(ObjectReadContext
Active read context to use.
readCtxt
)

Method used to create a JsonParser that can read contents stored in this buffer.

public JsonParser
asParser(ObjectReadContext readCtxt, JsonParser
Parser to use for accessing source information like location, streamReadConstraints
p0
)

public JsonParser
asParserOnFirstToken(ObjectReadContext readCtxt)

Same as:

  JsonParser p = asParser(readCtxt);
  p.nextToken();
  return p;
public JsonParser
public void
assignCurrentValue(Object v)

Implements abstract tools.jackson.core.JsonGenerator.assignCurrentValue.

Helper method, usually equivalent to: getOutputContext().assignCurrentValue(v); used to assign "current value" for the current context of this generator.

public boolean
canWriteObjectId()

Overrides tools.jackson.core.JsonGenerator.canWriteObjectId.

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 tools.jackson.core.JsonGenerator.canWriteTypeId.

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 tools.jackson.core.JsonGenerator.close.

Implements java.io.Closeable.close.

Method called to close this generator, so that no more content can be written.

public JsonGenerator
configure(StreamWriteFeature f, boolean state)

Implements abstract tools.jackson.core.JsonGenerator.configure.

Method for enabling or disabling specified feature: check StreamWriteFeature for list of available features.

public void
copyCurrentEvent(JsonParser p)

Overrides tools.jackson.core.JsonGenerator.copyCurrentEvent.

Method for copying contents of the current event that the given parser instance points to.

public void
copyCurrentStructure(JsonParser p)

Overrides tools.jackson.core.JsonGenerator.copyCurrentStructure.

Method for copying contents of the current event and following events that it encloses the given parser instance points to.

public Object
currentValue()

Implements abstract tools.jackson.core.JsonGenerator.currentValue.

Helper method, usually equivalent to: getOutputContext().currentValue();

Note that "current value" is NOT populated (or used) by Streaming generator; it is only used by higher-level data-binding functionality.

public TokenBuffer
deserialize(JsonParser p, DeserializationContext ctxt)

Helper method used by standard deserializer.

public JsonToken
public void
flush()

Implements abstract tools.jackson.core.JsonGenerator.flush.

Implements java.io.Flushable.flush.

Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well.

public static TokenBuffer
forBuffering(JsonParser p, ObjectReadContext ctxt)

Specialized factory method used when we are specifically buffering contents of a token stream for further processing.

public TokenBuffer
public static TokenBuffer
forGeneration()

Specialized factory method used when we are generating token stream for further processing without tokens coming from specific input token stream.

public CharacterEscapes
getCharacterEscapes()

Overrides tools.jackson.core.JsonGenerator.getCharacterEscapes.

Method for accessing custom escapes generator uses for JsonGenerators it creates.

public int
getHighestNonEscapedChar()

Overrides tools.jackson.core.JsonGenerator.getHighestNonEscapedChar.

Accessor method for testing what is the highest unescaped character configured for this generator.

public PrettyPrinter
getPrettyPrinter()

Overrides tools.jackson.core.JsonGenerator.getPrettyPrinter.

Accessor for object that handles pretty-printing (usually additional white space to make results more human-readable) during output.

public FormatSchema
getSchema()

Overrides tools.jackson.core.JsonGenerator.getSchema.

Method for accessing Schema that this generator uses, if any.

public boolean
has(StreamWriteCapability capability)

Implements abstract tools.jackson.core.JsonGenerator.has.

Accessor for checking whether this generator has specified capability.

public boolean
isClosed()

Implements abstract tools.jackson.core.JsonGenerator.isClosed.

Method that can be called to determine whether this generator is closed or not.

public boolean

Returns:

True if this buffer instance has no tokens
isEmpty
()

Accessor for checking whether this buffer has one or more tokens or not.

public boolean
isEnabled(StreamWriteFeature f)

Implements abstract tools.jackson.core.JsonGenerator.isEnabled.

Method for checking whether given feature is enabled.

public ObjectWriteContext
objectWriteContext()

Implements abstract tools.jackson.core.JsonGenerator.objectWriteContext.

Accessor for context object provided by higher-level databinding functionality (or, in some cases, simple placeholder of the same) that allows some level of interaction including ability to trigger serialization of Object values through generator instance.

public TokenBuffer
overrideParentContext(TokenStreamContext ctxt)

Method that allows explicitly specifying parent parse context to associate with contents of this buffer.

public void
serialize(JsonGenerator gen)

Helper method that will write all contents of this buffer using given JsonGenerator.

public JacksonFeatureSet<StreamWriteCapability>
streamWriteCapabilities()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteCapabilities.

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.jackson.core.JsonGenerator.streamWriteContext.

Accessor for context object that provides information about low-level logical position withing output token stream.

public int
streamWriteFeatures()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteFeatures.

Bulk access method for getting state of all standard (format-agnostic) StreamWriteFeatures.

public int
streamWriteOutputBuffered()

Implements abstract tools.jackson.core.JsonGenerator.streamWriteOutputBuffered.

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.jackson.core.JsonGenerator.streamWriteOutputTarget.

Method that can be used to get access to object that is used as target for generated output; this is usually either java.io.OutputStream or java.io.Writer, depending on what generator was constructed with.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Version
version()

Implements abstract tools.jackson.core.JsonGenerator.version.

Implements tools.jackson.core.Versioned.version.

Accessor for finding out version of the bundle that provided this generator instance.

public JsonGenerator
writeBinary(Base64Variant b64variant, byte[] data, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeBinary.

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 b64variant, InputStream data, int dataLength)

Implements abstract tools.jackson.core.JsonGenerator.writeBinary.

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 JsonGenerator
writeBoolean(boolean state)

Implements abstract tools.jackson.core.JsonGenerator.writeBoolean.

Method for outputting literal JSON boolean value (one of Strings 'true' and 'false').

public JsonGenerator
writeEmbeddedObject(Object object)

Overrides tools.jackson.core.JsonGenerator.writeEmbeddedObject.

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

Implements abstract tools.jackson.core.JsonGenerator.writeEndArray.

Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled).

public final JsonGenerator
writeEndObject()

Implements abstract tools.jackson.core.JsonGenerator.writeEndObject.

Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled).

private void
writeLazyDecimal(Object encodedValue)

private void
writeLazyInteger(Object encodedValue)

public final JsonGenerator
writeName(String name)

Implements abstract tools.jackson.core.JsonGenerator.writeName.

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)

Implements abstract tools.jackson.core.JsonGenerator.writeName.

Method similar to writeName(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 JsonGenerator
writeNull()

Implements abstract tools.jackson.core.JsonGenerator.writeNull.

Method for outputting literal JSON null value.

public JsonGenerator
writeNumber(short i)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(int i)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(long l)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(double d)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting indicate JSON numeric value.

public JsonGenerator
writeNumber(float f)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting indicate JSON numeric value.

public JsonGenerator
writeNumber(BigDecimal dec)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting indicate JSON numeric value.

public JsonGenerator
writeNumber(BigInteger v)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

Method for outputting given value as JSON number.

public JsonGenerator
writeNumber(String encodedValue)

Implements abstract tools.jackson.core.JsonGenerator.writeNumber.

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 JsonGenerator
writeObjectId(Object id)

Overrides tools.jackson.core.JsonGenerator.writeObjectId.

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 canWriteObjectId()), as not all data formats have native type id support; and some may only allow them in certain positions or locations.

public JsonGenerator
writePOJO(Object value)

Implements abstract tools.jackson.core.JsonGenerator.writePOJO.

Method for writing given Java object (POJO) as tokens into stream this generator manages; serialization must be a valid JSON Value (Object, Array, null, Number, String or Boolean).

public JsonGenerator
writePropertyId(long id)

Implements abstract tools.jackson.core.JsonGenerator.writePropertyId.

Alternative to writeName(String) that may be used in cases where Object Property key is of numeric type; usually where underlying format supports such notion (some binary formats do, unlike JSON).

public JsonGenerator
writeRaw(String text)

Implements abstract tools.jackson.core.JsonGenerator.writeRaw.

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.jackson.core.JsonGenerator.writeRaw.

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

Overrides tools.jackson.core.JsonGenerator.writeRaw.

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.jackson.core.JsonGenerator.writeRaw.

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.jackson.core.JsonGenerator.writeRaw.

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
writeRawUTF8String(byte[] text, int offset, int length)

Implements abstract tools.jackson.core.JsonGenerator.writeRawUTF8String.

Method similar to 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 JsonGenerator
writeRawValue(String text)

Implements abstract tools.jackson.core.JsonGenerator.writeRawValue.

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)

Implements abstract tools.jackson.core.JsonGenerator.writeRawValue.

public JsonGenerator
writeRawValue(char[] text, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeRawValue.

public final JsonGenerator
writeStartArray()

Implements abstract tools.jackson.core.JsonGenerator.writeStartArray.

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 final JsonGenerator
writeStartArray(Object forValue)

Implements abstract tools.jackson.core.JsonGenerator.writeStartArray.

Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying what is the Java object that the Array Object being written represents (if any); null may be passed if not known or not applicable.

public final JsonGenerator
writeStartArray(Object forValue, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeStartArray.

Method for writing start marker of an Array value, similar to writeStartArray(), but also specifying what is the Java object that the Array Object being written represents (if any) and how many elements will be written for the array before calling writeEndArray().

public final JsonGenerator
writeStartObject()

Implements abstract tools.jackson.core.JsonGenerator.writeStartObject.

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.jackson.core.JsonGenerator.writeStartObject.

Method for writing starting marker of an Object value to represent the given Java Object value.

public JsonGenerator
writeStartObject(Object forValue, int size)

Implements abstract tools.jackson.core.JsonGenerator.writeStartObject.

Method for writing starting marker of an Object value to represent the given Java Object value.

public JsonGenerator
writeString(String text)

Implements abstract tools.jackson.core.JsonGenerator.writeString.

Method for outputting a String value.

public JsonGenerator
writeString(char[] text, int offset, int len)

Implements abstract tools.jackson.core.JsonGenerator.writeString.

Method for outputting a String value.

public JsonGenerator
writeString(SerializableString text)

Implements abstract tools.jackson.core.JsonGenerator.writeString.

Method similar to 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 JsonGenerator
writeString(Reader reader, final int len)

Implements abstract tools.jackson.core.JsonGenerator.writeString.

Method for outputting a String value.

public JsonGenerator
writeTree(TreeNode node)

Implements abstract tools.jackson.core.JsonGenerator.writeTree.

Method for writing given JSON tree (expressed as a tree where given TreeNode is the root) using this generator.

public JsonGenerator
writeTypeId(Object id)

Overrides tools.jackson.core.JsonGenerator.writeTypeId.

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 canWriteTypeId()), as not all data formats have native type id support; and some may only allow them in certain positions or locations.

public JsonGenerator
writeUTF8String(byte[] text, int offset, int length)

Implements abstract tools.jackson.core.JsonGenerator.writeUTF8String.

Method similar to 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).

Inherited from tools.jackson.core.JsonGenerator:
_constructWriteException_constructWriteException_constructWriteException_constructWriteException_copyCurrentContents_copyCurrentContentsExact_copyCurrentFloatValue_copyCurrentFloatValueExact_copyCurrentIntValue_copyCurrentStringValue_reportArgumentError_reportError_reportUnsupportedOperation_verifyOffsets_wrapIOFailure_writeTypePrefixUsingNative_writeTypePrefixUsingWrappercanOmitPropertiescopyCurrentEventExactcopyCurrentStructureExactsetCharacterEscapesstreamWriteConstraintswriteArraywriteArraywriteArraywriteArraywriteArrayPropertyStartwriteBinarywriteBinarywriteBinarywriteBinaryPropertywriteBooleanPropertywriteNullPropertywriteNumberwriteNumberPropertywriteNumberPropertywriteNumberPropertywriteNumberPropertywriteNumberPropertywriteNumberPropertywriteNumberPropertywriteObjectPropertyStartwriteObjectRefwriteOmittedPropertywritePOJOPropertywriteRawValuewriteStringPropertywriteTypePrefixwriteTypeSuffix