Package io.netty.handler.codec
Class ByteToMessageCodec.Encoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<I>
io.netty.handler.codec.ByteToMessageCodec.Encoder
- All Implemented Interfaces:
ChannelHandler
,ChannelOutboundHandler
- Enclosing class:
ByteToMessageCodec<I>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the given message should be handled.protected void
encode
(ChannelHandlerContext ctx, I msg, ByteBuf out) Encode a message into aByteBuf
.Methods inherited from class io.netty.handler.codec.MessageToByteEncoder
allocateBuffer, isPreferDirect, 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
-
Constructor Details
-
Encoder
Encoder(boolean preferDirect)
-
-
Method Details
-
acceptOutboundMessage
Description copied from class:MessageToByteEncoder
Returnstrue
if the given message should be handled. Iffalse
it will be passed to the nextChannelOutboundHandler
in theChannelPipeline
.- Overrides:
acceptOutboundMessage
in classMessageToByteEncoder<I>
- Throws:
Exception
-
encode
Description copied from class:MessageToByteEncoder
Encode a message into aByteBuf
. This method will be called for each written message that can be handled by this encoder.- Specified by:
encode
in classMessageToByteEncoder<I>
- Parameters:
ctx
- theChannelHandlerContext
which thisMessageToByteEncoder
belongs tomsg
- the message to encodeout
- theByteBuf
into which the encoded message will be written- Throws:
Exception
- is thrown if an error occurs
-