com.fasterxml.jackson.dataformat.smile.SmileBufferRecycler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-dataformat-smile Show documentation
Show all versions of jackson-dataformat-smile Show documentation
Support for reading and writing Smile ("binary JSON")
encoded data using Jackson abstractions (streaming API, data binding,
tree model)
package com.fasterxml.jackson.dataformat.smile;
/**
* Simple helper class used for implementing simple reuse system for Smile-specific
* buffers that are used.
*
* @param Type of name entries stored in arrays to recycle
*/
public class SmileBufferRecycler
{
public final static int DEFAULT_NAME_BUFFER_LENGTH = 64;
public final static int DEFAULT_STRING_VALUE_BUFFER_LENGTH = 64;
protected T[] _seenNamesBuffer;
protected T[] _seenStringValuesBuffer;
public SmileBufferRecycler() { }
public T[] allocSeenNamesBuffer()
{
// 11-Feb-2011, tatu: Used to alloc here; but due to generics, can't easily any more
T[] result = _seenNamesBuffer;
if (result != null) {
// let's ensure we don't retain it here, unless returned
_seenNamesBuffer = null;
// note: caller must have cleaned it up before returning
}
return result;
}
public T[] allocSeenStringValuesBuffer()
{
// 11-Feb-2011, tatu: Used to alloc here; but due to generics, can't easily any more
T[] result = _seenStringValuesBuffer;
if (result != null) {
_seenStringValuesBuffer = null;
// note: caller must have cleaned it up before returning
}
return result;
}
public void releaseSeenNamesBuffer(T[] buffer) {
_seenNamesBuffer = buffer;
}
public void releaseSeenStringValuesBuffer(T[] buffer) {
_seenStringValuesBuffer = buffer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy