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.
Note that before version 2.0, this class was located in the "core" bundle, not data-binding; but since it was only used by data binding, was moved here to reduce size of core package
| 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 |
_appendOffset
Offset within last segment,
|
protected boolean |
_closed |
protected TokenBuffer.Segment |
_first
First segment, for contents this buffer has
|
protected int |
_generatorFeatures
Bit flag composed of bits that indicate which
JsonGenerator.Features
are enabled. |
protected TokenBuffer.Segment |
_last
Last segment of this buffer, one that is used
for appending more tokens
|
protected com.fasterxml.jackson.core.ObjectCodec |
_objectCodec
Object codec to use for stream-based object
conversion through parser/generator interfaces.
|
protected com.fasterxml.jackson.core.json.JsonWriteContext |
_writeContext |
protected static int |
DEFAULT_PARSER_FEATURES |
| Constructor and Description |
|---|
TokenBuffer(com.fasterxml.jackson.core.ObjectCodec codec) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_append(com.fasterxml.jackson.core.JsonToken type) |
protected void |
_append(com.fasterxml.jackson.core.JsonToken type,
java.lang.Object value) |
protected void |
_appendRaw(int rawType,
java.lang.Object value) |
protected void |
_reportUnsupportedOperation() |
TokenBuffer |
append(TokenBuffer other)
Helper method that will append contents of given buffer into this
buffer.
|
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. |
void |
close() |
void |
copyCurrentEvent(com.fasterxml.jackson.core.JsonParser jp) |
void |
copyCurrentStructure(com.fasterxml.jackson.core.JsonParser jp) |
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() |
com.fasterxml.jackson.core.ObjectCodec |
getCodec() |
com.fasterxml.jackson.core.json.JsonWriteContext |
getOutputContext() |
boolean |
isClosed() |
boolean |
isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f) |
void |
serialize(com.fasterxml.jackson.core.JsonGenerator jgen)
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) |
java.lang.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,
java.io.InputStream data,
int dataLength)
Although we could support this method, it does not necessarily make
sense: we can not make good use of streaming because buffer must
hold all the data.
|
void |
writeBoolean(boolean state) |
void |
writeEndArray() |
void |
writeEndObject() |
void |
writeFieldName(com.fasterxml.jackson.core.SerializableString name) |
void |
writeFieldName(java.lang.String name) |
void |
writeNull() |
void |
writeNumber(java.math.BigDecimal dec) |
void |
writeNumber(java.math.BigInteger v) |
void |
writeNumber(double d) |
void |
writeNumber(float f) |
void |
writeNumber(int i) |
void |
writeNumber(long l) |
void |
writeNumber(short i) |
void |
writeNumber(java.lang.String encodedValue) |
void |
writeObject(java.lang.Object value) |
void |
writeRaw(char c) |
void |
writeRaw(char[] text,
int offset,
int len) |
void |
writeRaw(com.fasterxml.jackson.core.SerializableString text) |
void |
writeRaw(java.lang.String text) |
void |
writeRaw(java.lang.String text,
int offset,
int len) |
void |
writeRawUTF8String(byte[] text,
int offset,
int length) |
void |
writeRawValue(char[] text,
int offset,
int len) |
void |
writeRawValue(java.lang.String text) |
void |
writeRawValue(java.lang.String text,
int offset,
int len) |
void |
writeStartArray() |
void |
writeStartObject() |
void |
writeString(char[] text,
int offset,
int len) |
void |
writeString(com.fasterxml.jackson.core.SerializableString text) |
void |
writeString(java.lang.String text) |
void |
writeTree(com.fasterxml.jackson.core.TreeNode rootNode) |
void |
writeUTF8String(byte[] text,
int offset,
int length) |
canUseSchema, configure, getCharacterEscapes, getHighestEscapedChar, getOutputTarget, getPrettyPrinter, getSchema, setCharacterEscapes, setHighestNonEscapedChar, setPrettyPrinter, setRootValueSeparator, setSchema, writeArrayFieldStart, writeBinary, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeNullField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeStringFieldprotected static final int DEFAULT_PARSER_FEATURES
protected com.fasterxml.jackson.core.ObjectCodec _objectCodec
protected int _generatorFeatures
JsonGenerator.Features
are enabled.
NOTE: most features have no effect on this class
protected boolean _closed
protected TokenBuffer.Segment _first
protected TokenBuffer.Segment _last
protected int _appendOffset
protected com.fasterxml.jackson.core.json.JsonWriteContext _writeContext
public TokenBuffer(com.fasterxml.jackson.core.ObjectCodec codec)
codec - Object codec to use for stream-based object
conversion through parser/generator interfaces. If null,
such methods can not be used.public com.fasterxml.jackson.core.Version version()
version in interface com.fasterxml.jackson.core.Versionedversion in class com.fasterxml.jackson.core.JsonGeneratorpublic 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 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 can not be used.public com.fasterxml.jackson.core.JsonParser asParser(com.fasterxml.jackson.core.JsonParser src)
src - Parser to use for accessing source information
like location, configured codecpublic com.fasterxml.jackson.core.JsonToken firstToken()
public TokenBuffer append(TokenBuffer other) throws java.io.IOException, com.fasterxml.jackson.core.JsonGenerationException
java.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void serialize(com.fasterxml.jackson.core.JsonGenerator jgen)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
JsonGenerator.
Note: this method would be enough to implement
JsonSerializer for TokenBuffer type;
but we can not have upwards
references (from core to mapper package); and as such we also
can not take second argument.
java.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic com.fasterxml.jackson.core.JsonGenerator enable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
enable in class com.fasterxml.jackson.core.JsonGeneratorpublic com.fasterxml.jackson.core.JsonGenerator disable(com.fasterxml.jackson.core.JsonGenerator.Feature f)
disable in class com.fasterxml.jackson.core.JsonGeneratorpublic boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f)
isEnabled in class com.fasterxml.jackson.core.JsonGeneratorpublic com.fasterxml.jackson.core.JsonGenerator useDefaultPrettyPrinter()
useDefaultPrettyPrinter in class com.fasterxml.jackson.core.JsonGeneratorpublic com.fasterxml.jackson.core.JsonGenerator setCodec(com.fasterxml.jackson.core.ObjectCodec oc)
setCodec in class com.fasterxml.jackson.core.JsonGeneratorpublic com.fasterxml.jackson.core.ObjectCodec getCodec()
getCodec in class com.fasterxml.jackson.core.JsonGeneratorpublic final com.fasterxml.jackson.core.json.JsonWriteContext getOutputContext()
getOutputContext in class com.fasterxml.jackson.core.JsonGeneratorpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptionpublic boolean isClosed()
isClosed in class com.fasterxml.jackson.core.JsonGeneratorpublic final void writeStartArray()
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeStartArray in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic final void writeEndArray()
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeEndArray in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic final void writeStartObject()
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeStartObject in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic final void writeEndObject()
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeEndObject in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic final void writeFieldName(java.lang.String name)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeFieldName in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeFieldName(com.fasterxml.jackson.core.SerializableString name)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeFieldName in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeString(java.lang.String text)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeString in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeString(char[] text,
int offset,
int len)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeString in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeString(com.fasterxml.jackson.core.SerializableString text)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeString in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRawUTF8String(byte[] text,
int offset,
int length)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRawUTF8String in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeUTF8String(byte[] text,
int offset,
int length)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeUTF8String in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRaw(java.lang.String text)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRaw in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRaw(java.lang.String text,
int offset,
int len)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRaw in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRaw(com.fasterxml.jackson.core.SerializableString text)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRaw in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRaw(char[] text,
int offset,
int len)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRaw in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRaw(char c)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRaw in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRawValue(java.lang.String text)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRawValue in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRawValue(java.lang.String text,
int offset,
int len)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRawValue in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeRawValue(char[] text,
int offset,
int len)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeRawValue in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(short i)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(int i)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(long l)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(double d)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(float f)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(java.math.BigDecimal dec)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(java.math.BigInteger v)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNumber(java.lang.String encodedValue)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNumber in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeBoolean(boolean state)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeBoolean in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeNull()
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeNull in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic void writeObject(java.lang.Object value)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonProcessingException
writeObject in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionpublic void writeTree(com.fasterxml.jackson.core.TreeNode rootNode)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonProcessingException
writeTree in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionpublic void writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
byte[] data,
int offset,
int len)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException
writeBinary in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonGenerationExceptionpublic int writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant,
java.io.InputStream data,
int dataLength)
UnsupportedOperationExceptionwriteBinary in class com.fasterxml.jackson.core.JsonGeneratorpublic void copyCurrentEvent(com.fasterxml.jackson.core.JsonParser jp)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonProcessingException
copyCurrentEvent in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionpublic void copyCurrentStructure(com.fasterxml.jackson.core.JsonParser jp)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonProcessingException
copyCurrentStructure in class com.fasterxml.jackson.core.JsonGeneratorjava.io.IOExceptioncom.fasterxml.jackson.core.JsonProcessingExceptionprotected final void _append(com.fasterxml.jackson.core.JsonToken type)
protected final void _append(com.fasterxml.jackson.core.JsonToken type,
java.lang.Object value)
protected final void _appendRaw(int rawType,
java.lang.Object value)
protected void _reportUnsupportedOperation()
Copyright © 2013. All Rights Reserved.