com.fasterxml.jackson.core.io

## Class IOContext

- java.lang.Object
- - com.fasterxml.jackson.core.io.IOContext

-     public final class IOContext
      extends Object

  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.

- - ### Field Summary

    Fields
    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 JsonEncoding` | `_encoding` Encoding used by the underlying stream, if known.
    `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 Object` | `_sourceRef` Reference to the source object, which can be used for displaying location information
    `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 Summary

    Constructors
    Constructor and Description
    `IOContext(BufferRecycler br, Object sourceRef, boolean managedResource)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `allocBase64Buffer()`
    `char[]` | `allocConcatBuffer()`
    `char[]` | `allocNameCopyBuffer(int minSize)`
    `byte[]` | `allocReadIOBuffer()` Note: the method can only be called once during its life cycle.
    `char[]` | `allocTokenBuffer()`
    `byte[]` | `allocWriteEncodingBuffer()`
    `TextBuffer` | `constructTextBuffer()`
    `JsonEncoding` | `getEncoding()`
    `Object` | `getSourceReference()`
    `boolean` | `isResourceManaged()`
    `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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _sourceRef

          protected final Object _sourceRef

      Reference to the source object, which can be used for displaying location information

    - #### _encoding

          protected JsonEncoding _encoding

      Encoding used by the underlying stream, if known.

    - #### _managedResource

          protected final boolean _managedResource

      Flag that indicates whether underlying input/output source/target object is fully managed by the owner of this context (parser or generator). If true, it is, and is to be closed by parser/generator; if false, calling application has to do closing (unless auto-closing feature is enabled for the parser/generator in question; in which case it acts like the owner).

    - #### _bufferRecycler

          protected final BufferRecycler _bufferRecycler

      Recycler used for actual allocation/deallocation/reuse

    - #### _readIOBuffer

          protected byte[] _readIOBuffer

      Reference to the allocated I/O buffer for low-level input reading, if any allocated.

    - #### _writeEncodingBuffer

          protected byte[] _writeEncodingBuffer

      Reference to the allocated I/O buffer used for low-level encoding-related buffering.

    - #### _base64Buffer

          protected byte[] _base64Buffer

      Reference to the buffer allocated for temporary use with base64 encoding or decoding.

    - #### _tokenCBuffer

          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.

    - #### _concatCBuffer

          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.

    - #### _nameCopyBuffer

          protected char[] _nameCopyBuffer

      Reference temporary buffer Parser instances need if calling app decides it wants to access name via 'getTextCharacters' method. Regular text buffer can not be used as it may contain textual representation of the value token.

  - ### Constructor Detail

    - #### IOContext

          public IOContext(BufferRecycler br,
                   Object sourceRef,
                   boolean managedResource)

  - ### Method Detail

    - #### setEncoding

          public void setEncoding(JsonEncoding enc)

    - #### getSourceReference

          public Object getSourceReference()

    - #### getEncoding

          public JsonEncoding getEncoding()

    - #### isResourceManaged

          public boolean isResourceManaged()

    - #### constructTextBuffer

          public TextBuffer constructTextBuffer()

    - #### allocReadIOBuffer

          public byte[] allocReadIOBuffer()

      Note: the method can only be called once during its life cycle. This is to protect against accidental sharing.

    - #### allocWriteEncodingBuffer

          public byte[] allocWriteEncodingBuffer()

    - #### allocBase64Buffer

          public byte[] allocBase64Buffer()

      Since:
        2.1

    - #### allocTokenBuffer

          public char[] allocTokenBuffer()

    - #### 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.

    - #### 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)

Copyright © 2012-2013 FasterXML. All Rights Reserved.