Class MessageToMessageDecoder<I>

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Direct Known Subclasses:
Base64Decoder, ByteArrayDecoder, DatagramDnsQueryDecoder, DatagramDnsResponseDecoder, DatagramPacketDecoder, HttpContentDecoder, MessageAggregator, RedisArrayAggregator, SctpInboundByteStreamHandler, SctpMessageCompletionHandler, SctpMessageToMessageDecoder, SpdyHttpDecoder, StringDecoder, WebSocketExtensionDecoder, WebSocketProtocolHandler

public abstract class MessageToMessageDecoder<I> extends ChannelInboundHandlerAdapter
ChannelInboundHandlerAdapter which decodes from one message to an other message. For example here is an implementation which decodes a String to an Integer which represent the length of the String.
     public class StringToIntegerDecoder extends
             MessageToMessageDecoder<String> {

         @Override
         public void decode(ChannelHandlerContext ctx, String message,
                            List<Object> out) throws Exception {
             out.add(message.length());
         }
     }
 
Be aware that you need to call ReferenceCounted.retain() on messages that are just passed through if they are of type ReferenceCounted. This is needed as the MessageToMessageDecoder will call ReferenceCounted.release() on decoded messages.