Package com.fasterxml.jackson.core.util
Class BufferRecycler
- java.lang.Object
-
- com.fasterxml.jackson.core.util.BufferRecycler
-
public class BufferRecycler extends java.lang.ObjectThis is a small utility class, whose main functionality is to allow simple reuse of raw byte/char buffers. It is usually used throughThreadLocalmember of the owning class pointing to instance of this class through aSoftReference. The end result is a low-overhead GC-cleanable recycling: hopefully ideal for use by stream readers.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[][]_byteBuffersprotected char[][]_charBuffersstatic intBYTE_BASE64_CODEC_BUFFERBuffer used for concatenating binary data that is either being encoded as base64 output, or decoded from base64 input.static intBYTE_READ_IO_BUFFERBuffer used for reading byte-based input.static intBYTE_WRITE_CONCAT_BUFFERBuffer used for temporarily concatenating output; used for example when requesting output as byte array.static intBYTE_WRITE_ENCODING_BUFFERBuffer used for temporarily storing encoded content; used for example by UTF-8 encoding writerstatic intCHAR_CONCAT_BUFFERstatic intCHAR_NAME_COPY_BUFFERstatic intCHAR_TEXT_BUFFERstatic intCHAR_TOKEN_BUFFER
-
Constructor Summary
Constructors Modifier Constructor Description BufferRecycler()Default constructor used for creating instances of this default implementation.protectedBufferRecycler(int bbCount, int cbCount)Alternate constructor to be used by sub-classes, to allow customization of number of low-level buffers in use.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]allocByteBuffer(int ix)byte[]allocByteBuffer(int ix, int minSize)char[]allocCharBuffer(int ix)char[]allocCharBuffer(int ix, int minSize)protected byte[]balloc(int size)protected intbyteBufferLength(int ix)protected char[]calloc(int size)protected intcharBufferLength(int ix)voidreleaseByteBuffer(int ix, byte[] buffer)voidreleaseCharBuffer(int ix, char[] buffer)
-
-
-
Field Detail
-
BYTE_READ_IO_BUFFER
public static final int BYTE_READ_IO_BUFFER
Buffer used for reading byte-based input.- See Also:
- Constant Field Values
-
BYTE_WRITE_ENCODING_BUFFER
public static final int BYTE_WRITE_ENCODING_BUFFER
Buffer used for temporarily storing encoded content; used for example by UTF-8 encoding writer- See Also:
- Constant Field Values
-
BYTE_WRITE_CONCAT_BUFFER
public static final int BYTE_WRITE_CONCAT_BUFFER
Buffer used for temporarily concatenating output; used for example when requesting output as byte array.- See Also:
- Constant Field Values
-
BYTE_BASE64_CODEC_BUFFER
public static final int BYTE_BASE64_CODEC_BUFFER
Buffer used for concatenating binary data that is either being encoded as base64 output, or decoded from base64 input.- Since:
- 2.1
- See Also:
- Constant Field Values
-
CHAR_TOKEN_BUFFER
public static final int CHAR_TOKEN_BUFFER
- See Also:
- Constant Field Values
-
CHAR_CONCAT_BUFFER
public static final int CHAR_CONCAT_BUFFER
- See Also:
- Constant Field Values
-
CHAR_TEXT_BUFFER
public static final int CHAR_TEXT_BUFFER
- See Also:
- Constant Field Values
-
CHAR_NAME_COPY_BUFFER
public static final int CHAR_NAME_COPY_BUFFER
- See Also:
- Constant Field Values
-
_byteBuffers
protected final byte[][] _byteBuffers
-
_charBuffers
protected final char[][] _charBuffers
-
-
Constructor Detail
-
BufferRecycler
public BufferRecycler()
Default constructor used for creating instances of this default implementation.
-
BufferRecycler
protected BufferRecycler(int bbCount, int cbCount)Alternate constructor to be used by sub-classes, to allow customization of number of low-level buffers in use.- Since:
- 2.4
-
-
Method Detail
-
allocByteBuffer
public final byte[] allocByteBuffer(int ix)
- Parameters:
ix- One ofREAD_IO_BUFFERconstants.
-
allocByteBuffer
public byte[] allocByteBuffer(int ix, int minSize)
-
releaseByteBuffer
public void releaseByteBuffer(int ix, byte[] buffer)
-
allocCharBuffer
public final char[] allocCharBuffer(int ix)
-
allocCharBuffer
public char[] allocCharBuffer(int ix, int minSize)
-
releaseCharBuffer
public void releaseCharBuffer(int ix, char[] buffer)
-
byteBufferLength
protected int byteBufferLength(int ix)
-
charBufferLength
protected int charBufferLength(int ix)
-
balloc
protected byte[] balloc(int size)
-
calloc
protected char[] calloc(int size)
-
-