public class TokenBuffer
extends com.fasterxml.jackson.core.JsonGenerator
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 |
TokenBuffer.Parser |
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).
|
Modifier and Type | Field and Description |
---|---|
protected int |
_appendAt
Offset within last segment,
|
protected boolean |
_closed |
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 int |
_generatorFeatures
Bit flag composed of bits that indicate which
JsonGenerator.Feature s
are enabled. |
protected boolean |
_hasNativeId
Do we currently have a native type or object id buffered?
|
protected boolean |
_hasNativeObjectIds |
protected boolean |
_hasNativeTypeIds |
protected TokenBuffer.Segment |
_last
Last segment of this buffer, one that is used
for appending more tokens
|
protected boolean |
_mayHaveNativeIds |
protected com.fasterxml.jackson.core.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 com.fasterxml.jackson.core.JsonStreamContext |
_parentContext
Parse context from "parent" parser (one from which content to buffer is read,
if specified).
|
protected com.fasterxml.jackson.core.StreamReadConstraints |
_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 com.fasterxml.jackson.core.json.JsonWriteContext |
_writeContext |
protected static int |
DEFAULT_GENERATOR_FEATURES |
Constructor and Description |
---|
TokenBuffer(com.fasterxml.jackson.core.JsonParser p) |
TokenBuffer(com.fasterxml.jackson.core.JsonParser p,
DeserializationContext ctxt) |
TokenBuffer(com.fasterxml.jackson.core.ObjectCodec codec,
boolean hasNativeIds) |
Modifier and Type | Method and Description |
---|---|
protected void |
_appendEndMarker(com.fasterxml.jackson.core.JsonToken type)
Specialized method used for appending a structural end Object/Array marker
|
protected void |
_appendFieldName(Object value)
Specialized method used for appending a field name, appending either
String or SerializableString . |
protected void |
_appendStartMarker(com.fasterxml.jackson.core.JsonToken type)
Specialized method used for appending a structural start Object/Array marker
|
protected void |
_appendValue(com.fasterxml.jackson.core.JsonToken type)
Method used for appending token known to represent a "simple" scalar
value where token is the only information
|
protected void |
_appendValue(com.fasterxml.jackson.core.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
|
protected void |
_copyBufferContents(com.fasterxml.jackson.core.JsonParser p) |
protected void |
_reportUnsupportedOperation() |
TokenBuffer |
append(TokenBuffer other)
Helper method that will append contents of given buffer into this
buffer.
|
static TokenBuffer |
asCopyOfValue(com.fasterxml.jackson.core.JsonParser p)
Deprecated.
Since 2.13: use
DeserializationContext.bufferAsCopyOfValue(com.fasterxml.jackson.core.JsonParser) instead. |
com.fasterxml.jackson.core.JsonParser |
asParser()
Method used to create a
JsonParser that can read contents
stored in this buffer. |
com.fasterxml.jackson.core.JsonParser |
asParser(com.fasterxml.jackson.core.JsonParser src) |
com.fasterxml.jackson.core.JsonParser |
asParser(com.fasterxml.jackson.core.ObjectCodec codec)
Method used to create a
JsonParser that can read contents
stored in this buffer. |
com.fasterxml.jackson.core.JsonParser |
asParser(com.fasterxml.jackson.core.StreamReadConstraints streamReadConstraints) |
com.fasterxml.jackson.core.JsonParser |
asParserOnFirstToken()
Same as:
|
boolean |
canWriteBinaryNatively()
Since we can efficiently store
byte[] , yes. |
boolean |
canWriteObjectId() |
boolean |
canWriteTypeId() |
void |
close() |
void |
copyCurrentEvent(com.fasterxml.jackson.core.JsonParser p) |
void |
copyCurrentStructure(com.fasterxml.jackson.core.JsonParser p) |
TokenBuffer |
deserialize(com.fasterxml.jackson.core.JsonParser p,
DeserializationContext ctxt)
Helper method used by standard deserializer.
|
com.fasterxml.jackson.core.JsonGenerator |
disable(com.fasterxml.jackson.core.JsonGenerator.Feature f) |
com.fasterxml.jackson.core.JsonGenerator |
enable(com.fasterxml.jackson.core.JsonGenerator.Feature f) |
com.fasterxml.jackson.core.JsonToken |
firstToken() |
void |
flush() |
TokenBuffer |
forceUseOfBigDecimal(boolean b) |
com.fasterxml.jackson.core.ObjectCodec |
getCodec() |
int |
getFeatureMask() |
com.fasterxml.jackson.core.json.JsonWriteContext |
getOutputContext() |
com.fasterxml.jackson.core.util.JacksonFeatureSet<com.fasterxml.jackson.core.StreamWriteCapability> |
getWriteCapabilities() |
boolean |
isClosed() |
boolean |
isEmpty()
Accessor for checking whether this buffer has one or more tokens
or not.
|
boolean |
isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) |
TokenBuffer |
overrideParentContext(com.fasterxml.jackson.core.JsonStreamContext ctxt)
Method that allows explicitly specifying parent parse context to associate
with contents of this buffer.
|
com.fasterxml.jackson.core.JsonGenerator |
overrideStdFeatures(int values,
int mask) |
void |
serialize(com.fasterxml.jackson.core.JsonGenerator gen)
Helper method that will write all contents of this buffer
using given
JsonGenerator . |
com.fasterxml.jackson.core.JsonGenerator |
setCodec(com.fasterxml.jackson.core.ObjectCodec oc) |
com.fasterxml.jackson.core.JsonGenerator |
setFeatureMask(int mask)
Deprecated.
|
String |
toString() |
com.fasterxml.jackson.core.JsonGenerator |
useDefaultPrettyPrinter() |
com.fasterxml.jackson.core.Version |
version() |
void |
writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
byte[] data,
int offset,
int len) |
int |
writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
InputStream data,
int dataLength)
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.
|
void |
writeBoolean(boolean state) |
void |
writeEmbeddedObject(Object object) |
void |
writeEndArray() |
void |
writeEndObject() |
void |
writeFieldName(com.fasterxml.jackson.core.SerializableString name) |
void |
writeFieldName(String name) |
void |
writeNull() |
void |
writeNumber(BigDecimal dec) |
void |
writeNumber(BigInteger v) |
void |
writeNumber(double d) |
void |
writeNumber(float f) |
void |
writeNumber(int i) |
void |
writeNumber(long l) |
void |
writeNumber(short i) |
void |
writeNumber(String encodedValue) |
void |
writeObject(Object value) |
void |
writeObjectId(Object id) |
void |
writeRaw(char c) |
void |
writeRaw(char[] text,
int offset,
int len) |
void |
writeRaw(com.fasterxml.jackson.core.SerializableString text) |
void |
writeRaw(String text) |
void |
writeRaw(String text,
int offset,
int len) |
void |
writeRawUTF8String(byte[] text,
int offset,
int length) |
void |
writeRawValue(char[] text,
int offset,
int len) |
void |
writeRawValue(String text) |
void |
writeRawValue(String text,
int offset,
int len) |
void |
writeStartArray() |
void |
writeStartArray(Object forValue) |
void |
writeStartArray(Object forValue,
int size) |
void |
writeStartObject() |
void |
writeStartObject(Object forValue) |
void |
writeStartObject(Object forValue,
int size) |
void |
writeString(char[] text,
int offset,
int len) |
void |
writeString(Reader reader,
int len) |
void |
writeString(com.fasterxml.jackson.core.SerializableString text) |
void |
writeString(String text) |
void |
writeTree(com.fasterxml.jackson.core.TreeNode node) |
void |
writeTypeId(Object id) |
void |
writeUTF8String(byte[] text,
int offset,
int length) |
_copyCurrentContents, _copyCurrentFloatValue, _copyCurrentFloatValueExact, _copyCurrentIntValue, _copyCurrentStringValue, _reportError, _throwInternal, _verifyOffsets, _writeSimpleObject, assignCurrentValue, canOmitFields, canUseSchema, canWriteFormattedNumbers, configure, copyCurrentEventExact, currentValue, getCharacterEscapes, getCurrentValue, getFormatFeatures, getHighestEscapedChar, getOutputBuffered, getOutputTarget, getPrettyPrinter, getSchema, isEnabled, overrideFormatFeatures, setCharacterEscapes, setCurrentValue, setHighestNonEscapedChar, setPrettyPrinter, setRootValueSeparator, setSchema, streamWriteConstraints, writeArray, writeArray, writeArray, writeArray, writeArrayFieldStart, writeBinary, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeFieldId, writeNullField, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectRef, writeOmittedField, writePOJO, writePOJOField, writeRawValue, writeStartArray, writeStringField, writeTypePrefix, writeTypeSuffix
protected static final int DEFAULT_GENERATOR_FEATURES
protected com.fasterxml.jackson.core.ObjectCodec _objectCodec
protected com.fasterxml.jackson.core.JsonStreamContext _parentContext
protected int _generatorFeatures
JsonGenerator.Feature
s
are enabled.
NOTE: most features have no effect on this class
protected com.fasterxml.jackson.core.StreamReadConstraints _streamReadConstraints
protected boolean _closed
protected boolean _hasNativeTypeIds
protected boolean _hasNativeObjectIds
protected boolean _mayHaveNativeIds
protected boolean _forceBigDecimal
BigDecimal
is to be forced
on all floating-point values.protected TokenBuffer.Segment _first
protected TokenBuffer.Segment _last
protected int _appendAt
protected Object _typeId
protected Object _objectId
protected boolean _hasNativeId
protected com.fasterxml.jackson.core.json.JsonWriteContext _writeContext
public TokenBuffer(com.fasterxml.jackson.core.ObjectCodec codec, boolean hasNativeIds)
codec
- Object codec to use for stream-based object
conversion through parser/generator interfaces. If null,
such methods cannot be used.hasNativeIds
- Whether resulting JsonParser
(if created)
is considered to support native type and object idspublic TokenBuffer(com.fasterxml.jackson.core.JsonParser p)
public TokenBuffer(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt)
@Deprecated public static TokenBuffer asCopyOfValue(com.fasterxml.jackson.core.JsonParser p) throws IOException
DeserializationContext.bufferAsCopyOfValue(com.fasterxml.jackson.core.JsonParser)
instead.TokenBuffer b = new TokenBuffer(p); b.copyCurrentStructure(p); return b;
IOException
public TokenBuffer overrideParentContext(com.fasterxml.jackson.core.JsonStreamContext ctxt)
public TokenBuffer forceUseOfBigDecimal(boolean b)
public com.fasterxml.jackson.core.Version version()
version
in interface com.fasterxml.jackson.core.Versioned
version
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.JsonParser asParser()
JsonParser
that can read contents
stored in this buffer. Will use default _objectCodec
for
object conversions.
Note: instances are not synchronized, that is, they are not thread-safe if there are concurrent appends to the underlying buffer.
public com.fasterxml.jackson.core.JsonParser asParserOnFirstToken() throws IOException
JsonParser p = asParser(); p.nextToken(); return p;
IOException
public com.fasterxml.jackson.core.JsonParser asParser(com.fasterxml.jackson.core.ObjectCodec codec)
JsonParser
that can read contents
stored in this buffer.
Note: instances are not synchronized, that is, they are not thread-safe if there are concurrent appends to the underlying buffer.
codec
- Object codec to use for stream-based object
conversion through parser/generator interfaces. If null,
such methods cannot be used.public com.fasterxml.jackson.core.JsonParser asParser(com.fasterxml.jackson.core.StreamReadConstraints streamReadConstraints)
streamReadConstraints
- constraints for streaming readspublic com.fasterxml.jackson.core.JsonParser asParser(com.fasterxml.jackson.core.JsonParser src)
src
- Parser to use for accessing source information
like location, configured codec, streamReadConstraintspublic com.fasterxml.jackson.core.JsonToken firstToken()
public boolean isEmpty()
public TokenBuffer append(TokenBuffer other) throws IOException
IOException
public void serialize(com.fasterxml.jackson.core.JsonGenerator gen) throws IOException
JsonGenerator
.
Note: this method would be enough to implement
JsonSerializer
for TokenBuffer
type;
but we cannot have upwards
references (from core to mapper package); and as such we also
cannot take second argument.
IOException
public TokenBuffer deserialize(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt) throws IOException
IOException
public com.fasterxml.jackson.core.JsonGenerator enable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
enable
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.JsonGenerator disable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
disable
in class com.fasterxml.jackson.core.JsonGenerator
public boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f)
isEnabled
in class com.fasterxml.jackson.core.JsonGenerator
public int getFeatureMask()
getFeatureMask
in class com.fasterxml.jackson.core.JsonGenerator
@Deprecated public com.fasterxml.jackson.core.JsonGenerator setFeatureMask(int mask)
setFeatureMask
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.JsonGenerator
public com.fasterxml.jackson.core.JsonGenerator useDefaultPrettyPrinter()
useDefaultPrettyPrinter
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.JsonGenerator setCodec(com.fasterxml.jackson.core.ObjectCodec oc)
setCodec
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.ObjectCodec getCodec()
getCodec
in class com.fasterxml.jackson.core.JsonGenerator
public final com.fasterxml.jackson.core.json.JsonWriteContext getOutputContext()
getOutputContext
in class com.fasterxml.jackson.core.JsonGenerator
public boolean canWriteBinaryNatively()
byte[]
, yes.canWriteBinaryNatively
in class com.fasterxml.jackson.core.JsonGenerator
public com.fasterxml.jackson.core.util.JacksonFeatureSet<com.fasterxml.jackson.core.StreamWriteCapability> getWriteCapabilities()
getWriteCapabilities
in class com.fasterxml.jackson.core.JsonGenerator
public void flush() throws IOException
flush
in interface Flushable
flush
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public boolean isClosed()
isClosed
in class com.fasterxml.jackson.core.JsonGenerator
public final void writeStartArray() throws IOException
writeStartArray
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeStartArray(Object forValue) throws IOException
writeStartArray
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeStartArray(Object forValue, int size) throws IOException
writeStartArray
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public final void writeEndArray() throws IOException
writeEndArray
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public final void writeStartObject() throws IOException
writeStartObject
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeStartObject(Object forValue) throws IOException
writeStartObject
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeStartObject(Object forValue, int size) throws IOException
writeStartObject
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public final void writeEndObject() throws IOException
writeEndObject
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public final void writeFieldName(String name) throws IOException
writeFieldName
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeFieldName(com.fasterxml.jackson.core.SerializableString name) throws IOException
writeFieldName
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeString(String text) throws IOException
writeString
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeString(char[] text, int offset, int len) throws IOException
writeString
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeString(com.fasterxml.jackson.core.SerializableString text) throws IOException
writeString
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeString(Reader reader, int len) throws IOException
writeString
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRawUTF8String(byte[] text, int offset, int length) throws IOException
writeRawUTF8String
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeUTF8String(byte[] text, int offset, int length) throws IOException
writeUTF8String
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRaw(String text) throws IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRaw(String text, int offset, int len) throws IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRaw(com.fasterxml.jackson.core.SerializableString text) throws IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRaw(char[] text, int offset, int len) throws IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRaw(char c) throws IOException
writeRaw
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRawValue(String text) throws IOException
writeRawValue
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRawValue(String text, int offset, int len) throws IOException
writeRawValue
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeRawValue(char[] text, int offset, int len) throws IOException
writeRawValue
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(short i) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(int i) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(long l) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(double d) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(float f) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(BigDecimal dec) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(BigInteger v) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNumber(String encodedValue) throws IOException
writeNumber
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeBoolean(boolean state) throws IOException
writeBoolean
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeNull() throws IOException
writeNull
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeObject(Object value) throws IOException
writeObject
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeTree(com.fasterxml.jackson.core.TreeNode node) throws IOException
writeTree
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) throws IOException
writeBinary
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public int writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, InputStream data, int dataLength)
UnsupportedOperationException
writeBinary
in class com.fasterxml.jackson.core.JsonGenerator
public boolean canWriteTypeId()
canWriteTypeId
in class com.fasterxml.jackson.core.JsonGenerator
public boolean canWriteObjectId()
canWriteObjectId
in class com.fasterxml.jackson.core.JsonGenerator
public void writeTypeId(Object id)
writeTypeId
in class com.fasterxml.jackson.core.JsonGenerator
public void writeObjectId(Object id)
writeObjectId
in class com.fasterxml.jackson.core.JsonGenerator
public void writeEmbeddedObject(Object object) throws IOException
writeEmbeddedObject
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void copyCurrentEvent(com.fasterxml.jackson.core.JsonParser p) throws IOException
copyCurrentEvent
in class com.fasterxml.jackson.core.JsonGenerator
IOException
public void copyCurrentStructure(com.fasterxml.jackson.core.JsonParser p) throws IOException
copyCurrentStructure
in class com.fasterxml.jackson.core.JsonGenerator
IOException
protected void _copyBufferContents(com.fasterxml.jackson.core.JsonParser p) throws IOException
IOException
protected final void _appendValue(com.fasterxml.jackson.core.JsonToken type)
protected final void _appendValue(com.fasterxml.jackson.core.JsonToken type, Object value)
protected final void _appendFieldName(Object value)
String
or SerializableString
.protected final void _appendStartMarker(com.fasterxml.jackson.core.JsonToken type)
protected final void _appendEndMarker(com.fasterxml.jackson.core.JsonToken type)
protected void _reportUnsupportedOperation()
_reportUnsupportedOperation
in class com.fasterxml.jackson.core.JsonGenerator
Copyright © 2008–2024 FasterXML. All rights reserved.