GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec
  • MessageToMessageDecoder

This view

  • Original page
  • New address

GeezerVison is showing netty.io — MessageToMessageDecoder (Netty API Reference (4.1.141.Final))

Class MessageToMessageDecoder<I>

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.MessageToMessageDecoder<I>
All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
Direct Known Subclasses:
Base64Decoder, ByteArrayDecoder, DatagramDnsQueryDecoder, DatagramDnsResponseDecoder, DatagramPacketDecoder, HttpContentDecoder, MessageAggregator, ProtobufDecoder, ProtobufDecoderNano, RedisArrayAggregator, SctpInboundByteStreamHandler, SctpMessageCompletionHandler, SctpMessageToMessageDecoder, SpdyHttpDecoder, StringDecoder, WebSocketClientProtocolHandler, WebSocketExtensionDecoder, WebSocketServerProtocolHandler

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.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface ChannelHandler

    ChannelHandler.Sharable
    Modifier and Type
    Interface
    Description
    static @interface 
    ChannelHandler.Sharable
    Indicates that the same instance of the annotated ChannelHandler can be added to one or more ChannelPipelines multiple times without a race condition.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MessageToMessageDecoder()
    Create a new instance which will try to detect the types to match out of the type parameter of the class.
    protected
    MessageToMessageDecoder(Class<? extends I> inboundMessageType)
    Create a new instance
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    acceptInboundMessage(Object msg)
    Returns true if the given message should be handled.
    void
    channelRead(ChannelHandlerContext ctx, Object msg)
    Calls ChannelHandlerContext.fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelReadComplete(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelReadComplete() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    protected abstract void
    decode(ChannelHandlerContext ctx, I msg, List<Object> out)
    Decode from one message to an other.

    Methods inherited from class ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
    Modifier and Type
    Method
    Description
    void
    channelActive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelInactive(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelInactive() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelRegistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelRegistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelUnregistered(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelUnregistered() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    channelWritabilityChanged(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.fireChannelWritabilityChanged() to forward to the next ChannelInboundHandler in the ChannelPipeline.
    void
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Calls ChannelHandlerContext.fireExceptionCaught(Throwable) to forward to the next ChannelHandler in the ChannelPipeline.
    void
    userEventTriggered(ChannelHandlerContext ctx, Object evt)
    Calls ChannelHandlerContext.fireUserEventTriggered(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    void
    handlerAdded(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    void
    handlerRemoved(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    boolean
    isSharable()
    Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MessageToMessageDecoder

      protected MessageToMessageDecoder()
      Create a new instance which will try to detect the types to match out of the type parameter of the class.
    • MessageToMessageDecoder

      protected MessageToMessageDecoder(Class<? extends I> inboundMessageType)
      Create a new instance
      Parameters:
      inboundMessageType - The type of messages to match and so decode
  • Method Details

    • acceptInboundMessage

      public boolean acceptInboundMessage(Object msg) throws Exception
      Returns true if the given message should be handled. If false it will be passed to the next ChannelInboundHandler in the ChannelPipeline.
      Throws:
      Exception
    • channelRead

      public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
      Description copied from class: ChannelInboundHandlerAdapter
      Calls ChannelHandlerContext.fireChannelRead(Object) to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      channelRead in interface ChannelInboundHandler
      Overrides:
      channelRead in class ChannelInboundHandlerAdapter
      Throws:
      Exception
    • channelReadComplete

      public void channelReadComplete(ChannelHandlerContext ctx) throws Exception
      Description copied from class: ChannelInboundHandlerAdapter
      Calls ChannelHandlerContext.fireChannelReadComplete() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      channelReadComplete in interface ChannelInboundHandler
      Overrides:
      channelReadComplete in class ChannelInboundHandlerAdapter
      Throws:
      Exception
    • decode

      protected abstract void decode(ChannelHandlerContext ctx, I msg, List<Object> out) throws Exception
      Decode from one message to an other. This method will be called for each written message that can be handled by this decoder.
      Parameters:
      ctx - the ChannelHandlerContext which this MessageToMessageDecoder belongs to
      msg - the message to decode to an other one
      out - the List to which decoded messages should be added
      Throws:
      Exception - is thrown if an error occurs
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.