public final class DefaultCodecs extends Object implements Codecs, CodecRegistry
Codec implementation. Delegates to type-specific codec implementations.
Codecs can be configured to prefer or avoid attached buffers for certain data types. Using attached buffers is more memory-efficient as data doesn't need to be copied. In turn, attached buffers require release or consumption to avoid memory leaks. By default, codecs don't use attached buffers to minimize the risk of memory leaks.
| Constructor and Description |
|---|
DefaultCodecs(io.netty.buffer.ByteBufAllocator byteBufAllocator)
Create a new instance of
DefaultCodecs preferring detached (copied buffers). |
DefaultCodecs(io.netty.buffer.ByteBufAllocator byteBufAllocator,
boolean preferAttachedBuffers)
Create a new instance of
DefaultCodecs preferring detached (copied buffers). |
DefaultCodecs(io.netty.buffer.ByteBufAllocator byteBufAllocator,
boolean preferAttachedBuffers,
CodecConfiguration configuration)
Create a new instance of
DefaultCodecs. |
| Modifier and Type | Method and Description |
|---|---|
void |
addFirst(Codec<?> codec)
Register codec before all other codecs.
|
void |
addLast(Codec<?> codec)
Register codec after all other codecs.
|
<T> T |
decode(io.netty.buffer.ByteBuf buffer,
int dataType,
io.r2dbc.postgresql.message.Format format,
Class<? extends T> type)
Decode a data to a value.
|
io.r2dbc.postgresql.client.EncodedParameter |
encode(Object value)
Encode a value.
|
io.r2dbc.postgresql.client.EncodedParameter |
encodeNull(Class<?> type)
Encode a
null value. |
Iterator<Codec<?>> |
iterator() |
Class<?> |
preferredType(int dataType,
io.r2dbc.postgresql.message.Format format)
Returns the preferred Java type for a given data type and format.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic DefaultCodecs(io.netty.buffer.ByteBufAllocator byteBufAllocator)
DefaultCodecs preferring detached (copied buffers).byteBufAllocator - the ByteBufAllocator to use for encodingpublic DefaultCodecs(io.netty.buffer.ByteBufAllocator byteBufAllocator,
boolean preferAttachedBuffers)
DefaultCodecs preferring detached (copied buffers).byteBufAllocator - the ByteBufAllocator to use for encodingpreferAttachedBuffers - whether to prefer attached (pooled) buffers. Use false (default) to use detached buffers which minimize the risk of memory leaks.public DefaultCodecs(io.netty.buffer.ByteBufAllocator byteBufAllocator,
boolean preferAttachedBuffers,
CodecConfiguration configuration)
DefaultCodecs.byteBufAllocator - the ByteBufAllocator to use for encodingpreferAttachedBuffers - whether to prefer attached (pooled) buffers. Use false (default) to use detached buffers which minimize the risk of memory leaks.configuration - the CodecConfiguration to use for encoding/decodingpublic void addFirst(Codec<?> codec)
CodecRegistryaddFirst in interface CodecRegistrycodec - the codec to registerpublic void addLast(Codec<?> codec)
CodecRegistryaddLast in interface CodecRegistrycodec - the codec to register@Nullable public <T> T decode(@Nullable io.netty.buffer.ByteBuf buffer, int dataType, io.r2dbc.postgresql.message.Format format, Class<? extends T> type)
Codecspublic io.r2dbc.postgresql.client.EncodedParameter encode(Object value)
Codecspublic io.r2dbc.postgresql.client.EncodedParameter encodeNull(Class<?> type)
Codecsnull value.encodeNull in interface Codecstype - the type to encodepublic Class<?> preferredType(int dataType, io.r2dbc.postgresql.message.Format format)
CodecspreferredType in interface CodecsdataType - the data type fo the dataformat - the format of the dataCopyright © 2023. All rights reserved.