Class AbstractBinaryMemcacheEncoder<M extends BinaryMemcacheMessage>
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageEncoder<java.lang.Object>
-
- io.netty.handler.codec.memcache.AbstractMemcacheObjectEncoder<M>
-
- io.netty.handler.codec.memcache.binary.AbstractBinaryMemcacheEncoder<M>
-
- All Implemented Interfaces:
ChannelHandler,ChannelOutboundHandler
- Direct Known Subclasses:
BinaryMemcacheRequestEncoder,BinaryMemcacheResponseEncoder
@UnstableApi public abstract class AbstractBinaryMemcacheEncoder<M extends BinaryMemcacheMessage> extends AbstractMemcacheObjectEncoder<M>
AMessageToByteEncoderthat encodes binary memcache messages into bytes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private static intMINIMUM_HEADER_SIZEEvery binary memcache message has at least a 24 bytes header.
-
Constructor Summary
Constructors Constructor Description AbstractBinaryMemcacheEncoder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static voidencodeExtras(ByteBuf buf, ByteBuf extras)Encode the extras.protected abstract voidencodeHeader(ByteBuf buf, M msg)Encode the header.private static voidencodeKey(ByteBuf buf, ByteBuf key)Encode the key.protected ByteBufencodeMessage(ChannelHandlerContext ctx, M msg)Take the givenMemcacheMessageand encode it into a writableByteBuf.private static intverifyLength(ByteBuf buf, int expectedLength, java.lang.String name)The header is written from the lengths recorded in the message, so the readable bytes of the key and extras must still equal those recorded lengths.-
Methods inherited from class io.netty.handler.codec.memcache.AbstractMemcacheObjectEncoder
acceptOutboundMessage, encode
-
Methods inherited from class io.netty.handler.codec.MessageToMessageEncoder
write
-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, read
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
-
-
-
Field Detail
-
MINIMUM_HEADER_SIZE
private static final int MINIMUM_HEADER_SIZE
Every binary memcache message has at least a 24 bytes header.- See Also:
- Constant Field Values
-
-
Method Detail
-
encodeMessage
protected ByteBuf encodeMessage(ChannelHandlerContext ctx, M msg)
Description copied from class:AbstractMemcacheObjectEncoderTake the givenMemcacheMessageand encode it into a writableByteBuf.- Specified by:
encodeMessagein classAbstractMemcacheObjectEncoder<M extends BinaryMemcacheMessage>- Parameters:
ctx- the channel handler context.msg- the message to encode.- Returns:
- the
ByteBufrepresentation of the message.
-
verifyLength
private static int verifyLength(ByteBuf buf, int expectedLength, java.lang.String name)
The header is written from the lengths recorded in the message, so the readable bytes of the key and extras must still equal those recorded lengths. Otherwise the header would not describe the bytes that follow it.
-
encodeExtras
private static void encodeExtras(ByteBuf buf, ByteBuf extras)
Encode the extras.- Parameters:
buf- theByteBufto write into.extras- the extras to encode.
-
encodeKey
private static void encodeKey(ByteBuf buf, ByteBuf key)
Encode the key.- Parameters:
buf- theByteBufto write into.key- the key to encode.
-
-