public class IOContext extends Object implements AutoCloseable
NOTE: non-final since 2.4, to allow sub-classing.
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
_base64Buffer
Reference to the buffer allocated for temporary use with
base64 encoding or decoding.
|
protected BufferRecycler |
_bufferRecycler
Recycler used for actual allocation/deallocation/reuse
|
protected char[] |
_concatCBuffer
Reference to the buffer allocated for buffering it for
output, before being encoded: generally this means concatenating
output, then encoding when buffer fills up.
|
protected ContentReference |
_contentReference
Reference to the source object, which can be used for displaying
location information
|
protected JsonEncoding |
_encoding
Encoding used by the underlying stream, if known.
|
protected ErrorReportConfiguration |
_errorReportConfiguration |
protected boolean |
_managedResource
Flag that indicates whether underlying input/output source/target
object is fully managed by the owner of this context (parser or
generator).
|
protected char[] |
_nameCopyBuffer
Reference temporary buffer Parser instances need if calling
app decides it wants to access name via 'getTextCharacters' method.
|
protected byte[] |
_readIOBuffer
Reference to the allocated I/O buffer for low-level input reading,
if any allocated.
|
protected boolean |
_releaseRecycler
Flag that indicates whether this context instance should release
configured
_bufferRecycler or not: if it does, it needs to call
(via BufferRecycler.releaseToPool() when closed; if not,
should do nothing (recycler life-cycle is externally managed) |
protected Object |
_sourceRef
Deprecated.
Since 2.13, use
_contentReference instead |
protected StreamReadConstraints |
_streamReadConstraints |
protected StreamWriteConstraints |
_streamWriteConstraints |
protected char[] |
_tokenCBuffer
Reference to the buffer allocated for tokenization purposes,
in which character input is read, and from which it can be
further returned.
|
protected byte[] |
_writeEncodingBuffer
Reference to the allocated I/O buffer used for low-level
encoding-related buffering.
|
| Constructor and Description |
|---|
IOContext(BufferRecycler br,
ContentReference contentRef,
boolean managedResource)
Deprecated.
|
IOContext(BufferRecycler br,
Object rawContent,
boolean managedResource)
Deprecated.
|
IOContext(StreamReadConstraints src,
BufferRecycler br,
ContentReference contentRef,
boolean managedResource)
Deprecated.
|
IOContext(StreamReadConstraints src,
StreamWriteConstraints swc,
ErrorReportConfiguration erc,
BufferRecycler br,
ContentReference contentRef,
boolean managedResource)
Main constructor to use.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_verifyAlloc(Object buffer) |
protected void |
_verifyRelease(byte[] toRelease,
byte[] src) |
protected void |
_verifyRelease(char[] toRelease,
char[] src) |
byte[] |
allocBase64Buffer()
Method for recycling or allocation byte buffer of "base 64 encode/decode" type.
|
byte[] |
allocBase64Buffer(int minSize)
Variant of
allocBase64Buffer() that specifies smallest acceptable
buffer size. |
char[] |
allocConcatBuffer() |
char[] |
allocNameCopyBuffer(int minSize) |
byte[] |
allocReadIOBuffer()
Method for recycling or allocation byte buffer of "read I/O" type.
|
byte[] |
allocReadIOBuffer(int minSize)
Variant of
allocReadIOBuffer() that specifies smallest acceptable
buffer size. |
char[] |
allocTokenBuffer() |
char[] |
allocTokenBuffer(int minSize) |
byte[] |
allocWriteEncodingBuffer()
Method for recycling or allocation byte buffer of "write encoding" type.
|
byte[] |
allocWriteEncodingBuffer(int minSize)
Variant of
allocWriteEncodingBuffer() that specifies smallest acceptable
buffer size. |
BufferRecycler |
bufferRecycler() |
void |
close() |
TextBuffer |
constructReadConstrainedTextBuffer() |
TextBuffer |
constructTextBuffer() |
ContentReference |
contentReference()
Accessor for getting (some) information about input source, mostly
usable for error reporting purposes.
|
ErrorReportConfiguration |
errorReportConfiguration() |
JsonEncoding |
getEncoding() |
Object |
getSourceReference()
Deprecated.
Since 2.13, use
contentReference() instead |
boolean |
isResourceManaged() |
IOContext |
markBufferRecyclerReleased()
Method to call to prevent
_bufferRecycler release upon
close(): called when _bufferRecycler life-cycle is
externally managed. |
void |
releaseBase64Buffer(byte[] buf) |
void |
releaseConcatBuffer(char[] buf) |
void |
releaseNameCopyBuffer(char[] buf) |
void |
releaseReadIOBuffer(byte[] buf)
Method to call when all the processing buffers can be safely
recycled.
|
void |
releaseTokenBuffer(char[] buf) |
void |
releaseWriteEncodingBuffer(byte[] buf) |
void |
setEncoding(JsonEncoding enc) |
StreamReadConstraints |
streamReadConstraints() |
StreamWriteConstraints |
streamWriteConstraints() |
IOContext |
withEncoding(JsonEncoding enc) |
protected final ContentReference _contentReference
@Deprecated protected final Object _sourceRef
_contentReference insteadprotected JsonEncoding _encoding
protected final boolean _managedResource
protected final BufferRecycler _bufferRecycler
protected boolean _releaseRecycler
_bufferRecycler or not: if it does, it needs to call
(via BufferRecycler.releaseToPool() when closed; if not,
should do nothing (recycler life-cycle is externally managed)protected final StreamReadConstraints _streamReadConstraints
protected final StreamWriteConstraints _streamWriteConstraints
protected final ErrorReportConfiguration _errorReportConfiguration
protected byte[] _readIOBuffer
protected byte[] _writeEncodingBuffer
protected byte[] _base64Buffer
protected char[] _tokenCBuffer
protected char[] _concatCBuffer
protected char[] _nameCopyBuffer
public IOContext(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc, BufferRecycler br, ContentReference contentRef, boolean managedResource)
src - constraints for streaming readsswc - constraints for streaming writesbr - BufferRecycler to use, if any (null if none)contentRef - Input source reference for location reportingmanagedResource - Whether input source is managed (owned) by Jackson libraryerc - Error report configuration to use@Deprecated public IOContext(StreamReadConstraints src, BufferRecycler br, ContentReference contentRef, boolean managedResource)
IOContext(StreamReadConstraints, StreamWriteConstraints,
ErrorReportConfiguration, BufferRecycler, ContentReference, boolean) instead.src - constraints for streaming readsbr - BufferRecycler to use, if any (null if none)contentRef - Input source reference for location reportingmanagedResource - Whether input source is managed (owned) by Jackson library@Deprecated public IOContext(BufferRecycler br, ContentReference contentRef, boolean managedResource)
IOContext(StreamReadConstraints, StreamWriteConstraints,
ErrorReportConfiguration, BufferRecycler, ContentReference, boolean) instead.br - BufferRecycler to use, if any (null if none)contentRef - Input source reference for location reportingmanagedResource - Whether input source is managed (owned) by Jackson library@Deprecated public IOContext(BufferRecycler br, Object rawContent, boolean managedResource)
public IOContext markBufferRecyclerReleased()
_bufferRecycler release upon
close(): called when _bufferRecycler life-cycle is
externally managed.public StreamReadConstraints streamReadConstraints()
public StreamWriteConstraints streamWriteConstraints()
public ErrorReportConfiguration errorReportConfiguration()
ErrorReportConfiguration, containing configured values for
handling error reporting.public void setEncoding(JsonEncoding enc)
public IOContext withEncoding(JsonEncoding enc)
public JsonEncoding getEncoding()
public boolean isResourceManaged()
public ContentReference contentReference()
@Deprecated public Object getSourceReference()
contentReference() insteadpublic BufferRecycler bufferRecycler()
public TextBuffer constructTextBuffer()
public TextBuffer constructReadConstrainedTextBuffer()
public byte[] allocReadIOBuffer()
Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.
public byte[] allocReadIOBuffer(int minSize)
allocReadIOBuffer() that specifies smallest acceptable
buffer size.minSize - Minimum size of the buffer to recycle or allocatepublic byte[] allocWriteEncodingBuffer()
Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.
public byte[] allocWriteEncodingBuffer(int minSize)
allocWriteEncodingBuffer() that specifies smallest acceptable
buffer size.minSize - Minimum size of the buffer to recycle or allocatepublic byte[] allocBase64Buffer()
Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.
public byte[] allocBase64Buffer(int minSize)
allocBase64Buffer() that specifies smallest acceptable
buffer size.minSize - Minimum size of the buffer to recycle or allocatepublic char[] allocTokenBuffer()
public char[] allocTokenBuffer(int minSize)
public char[] allocConcatBuffer()
public char[] allocNameCopyBuffer(int minSize)
public void releaseReadIOBuffer(byte[] buf)
buf - Buffer instance to release (return for recycling)public void releaseWriteEncodingBuffer(byte[] buf)
public void releaseBase64Buffer(byte[] buf)
public void releaseTokenBuffer(char[] buf)
public void releaseConcatBuffer(char[] buf)
public void releaseNameCopyBuffer(char[] buf)
protected final void _verifyAlloc(Object buffer)
protected final void _verifyRelease(byte[] toRelease,
byte[] src)
protected final void _verifyRelease(char[] toRelease,
char[] src)
public void close()
close in interface AutoCloseableCopyright © 2008–2024 FasterXML. All rights reserved.