Package com.fasterxml.jackson.core.io
Class IOContext
java.lang.Object
com.fasterxml.jackson.core.io.IOContext
- All Implemented Interfaces:
AutoCloseable
To limit number of configuration and state objects to pass, all
contextual objects that need to be passed by the factory to
readers and writers are combined under this object. One instance
is created for each reader and writer.
NOTE: non-final since 2.4, to allow sub-classing.
-
Constructor Summary
ConstructorsConstructorDescriptionIOContext(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc, BufferRecycler br, ContentReference contentRef, boolean managedResource) Main constructor to use.IOContext(StreamReadConstraints src, BufferRecycler br, ContentReference contentRef, boolean managedResource) Deprecated.Since 2.16.IOContext(BufferRecycler br, ContentReference contentRef, boolean managedResource) Deprecated.Since 2.15.IOContext(BufferRecycler br, Object rawContent, boolean managedResource) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Method for recycling or allocation byte buffer of "base 64 encode/decode" type.byte[]allocBase64Buffer(int minSize) Variant ofallocBase64Buffer()that specifies smallest acceptable buffer size.char[]char[]allocNameCopyBuffer(int minSize) byte[]Method for recycling or allocation byte buffer of "read I/O" type.byte[]allocReadIOBuffer(int minSize) Variant ofallocReadIOBuffer()that specifies smallest acceptable buffer size.char[]char[]allocTokenBuffer(int minSize) byte[]Method for recycling or allocation byte buffer of "write encoding" type.byte[]allocWriteEncodingBuffer(int minSize) Variant ofallocWriteEncodingBuffer()that specifies smallest acceptable buffer size.voidclose()Accessor for getting (some) information about input source, mostly usable for error reporting purposes.Deprecated.Since 2.13, usecontentReference()insteadbooleanMethod to call to prevent_bufferRecyclerrelease uponclose(): called when_bufferRecyclerlife-cycle is externally managed.voidreleaseBase64Buffer(byte[] buf) voidreleaseConcatBuffer(char[] buf) voidreleaseNameCopyBuffer(char[] buf) voidreleaseReadIOBuffer(byte[] buf) Method to call when all the processing buffers can be safely recycled.voidreleaseTokenBuffer(char[] buf) voidreleaseWriteEncodingBuffer(byte[] buf) voidsetEncoding(JsonEncoding enc) withEncoding(JsonEncoding enc)
-
Constructor Details
-
IOContext
public IOContext(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc, BufferRecycler br, ContentReference contentRef, boolean managedResource) Main constructor to use.- Parameters:
src- constraints for streaming readsswc- constraints for streaming writeserc- Error report configuration to usebr- BufferRecycler to use, if any (nullif none)contentRef- Input source reference for location reportingmanagedResource- Whether input source is managed (owned) by Jackson library- Since:
- 2.16
-
IOContext
@Deprecated public IOContext(StreamReadConstraints src, BufferRecycler br, ContentReference contentRef, boolean managedResource) Deprecated.Deprecated legacy constructor.- Parameters:
src- constraints for streaming readsbr- BufferRecycler to use, if any (nullif none)contentRef- Input source reference for location reportingmanagedResource- Whether input source is managed (owned) by Jackson library- Since:
- 2.15
-
IOContext
@Deprecated public IOContext(BufferRecycler br, ContentReference contentRef, boolean managedResource) Deprecated.Deprecated legacy constructor.- Parameters:
br- BufferRecycler to use, if any (nullif none)contentRef- Input source reference for location reportingmanagedResource- Whether input source is managed (owned) by Jackson library- Since:
- 2.13
-
IOContext
Deprecated.
-
-
Method Details
-
markBufferRecyclerReleased
Method to call to prevent_bufferRecyclerrelease uponclose(): called when_bufferRecyclerlife-cycle is externally managed.- Since:
- 2.17
-
streamReadConstraints
- Returns:
- constraints for streaming reads
- Since:
- 2.15
-
streamWriteConstraints
- Returns:
- constraints for streaming writes
- Since:
- 2.16
-
errorReportConfiguration
- Returns:
- Configured
ErrorReportConfiguration, containing configured values for handling error reporting. - Since:
- 2.16
-
setEncoding
-
withEncoding
-
getEncoding
-
isResourceManaged
public boolean isResourceManaged() -
contentReference
Accessor for getting (some) information about input source, mostly usable for error reporting purposes.- Returns:
- Reference to input source
- Since:
- 2.13
-
getSourceReference
Deprecated.Since 2.13, usecontentReference()instead- Returns:
- "Raw" source reference
-
bufferRecycler
-
constructTextBuffer
-
constructReadConstrainedTextBuffer
-
allocReadIOBuffer
public byte[] allocReadIOBuffer()Method for recycling or allocation byte buffer of "read I/O" type.Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.
- Returns:
- Allocated or recycled byte buffer
-
allocReadIOBuffer
public byte[] allocReadIOBuffer(int minSize) Variant ofallocReadIOBuffer()that specifies smallest acceptable buffer size.- Parameters:
minSize- Minimum size of the buffer to recycle or allocate- Returns:
- Allocated or recycled byte buffer
- Since:
- 2.4
-
allocWriteEncodingBuffer
public byte[] allocWriteEncodingBuffer()Method for recycling or allocation byte buffer of "write encoding" type.Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.
- Returns:
- Allocated or recycled byte buffer
-
allocWriteEncodingBuffer
public byte[] allocWriteEncodingBuffer(int minSize) Variant ofallocWriteEncodingBuffer()that specifies smallest acceptable buffer size.- Parameters:
minSize- Minimum size of the buffer to recycle or allocate- Returns:
- Allocated or recycled byte buffer
- Since:
- 2.4
-
allocBase64Buffer
public byte[] allocBase64Buffer()Method for recycling or allocation byte buffer of "base 64 encode/decode" type.Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.
- Returns:
- Allocated or recycled byte buffer
-
allocBase64Buffer
public byte[] allocBase64Buffer(int minSize) Variant ofallocBase64Buffer()that specifies smallest acceptable buffer size.- Parameters:
minSize- Minimum size of the buffer to recycle or allocate- Returns:
- Allocated or recycled byte buffer
- Since:
- 2.9
-
allocTokenBuffer
public char[] allocTokenBuffer() -
allocTokenBuffer
public char[] allocTokenBuffer(int minSize) -
allocConcatBuffer
public char[] allocConcatBuffer() -
allocNameCopyBuffer
public char[] allocNameCopyBuffer(int minSize) -
releaseReadIOBuffer
public void releaseReadIOBuffer(byte[] buf) Method to call when all the processing buffers can be safely recycled.- Parameters:
buf- Buffer instance to release (return for recycling)
-
releaseWriteEncodingBuffer
public void releaseWriteEncodingBuffer(byte[] buf) -
releaseBase64Buffer
public void releaseBase64Buffer(byte[] buf) -
releaseTokenBuffer
public void releaseTokenBuffer(char[] buf) -
releaseConcatBuffer
public void releaseConcatBuffer(char[] buf) -
releaseNameCopyBuffer
public void releaseNameCopyBuffer(char[] buf) -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-