Class Base64Encoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler

    @Sharable
    public class Base64Encoder
    extends MessageToMessageEncoder<io.netty.buffer.ByteBuf>
    Encodes a ByteBuf into a Base64-encoded ByteBuf. A typical setup for TCP/IP would be:
     ChannelPipeline pipeline = ...;
    
     // Decoders
     pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(80, Delimiters.nulDelimiter()));
     pipeline.addLast("base64Decoder", new Base64Decoder());
    
     // Encoder
     pipeline.addLast("base64Encoder", new Base64Encoder());
     
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void encode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, List<Object> out)
      Encode from one message to an other.
      • 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 interface io.netty.channel.ChannelHandler

        exceptionCaught, handlerAdded, handlerRemoved
    • Constructor Detail

      • Base64Encoder

        public Base64Encoder()
      • Base64Encoder

        public Base64Encoder​(boolean breakLines)
      • Base64Encoder

        public Base64Encoder​(boolean breakLines,
                             Base64Dialect dialect)
    • Method Detail

      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf msg,
                              List<Object> out)
                       throws Exception
        Description copied from class: MessageToMessageEncoder
        Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
        Specified by:
        encode in class MessageToMessageEncoder<io.netty.buffer.ByteBuf>
        Parameters:
        ctx - the ChannelHandlerContext which this MessageToMessageEncoder belongs to
        msg - the message to encode to an other one
        out - the List into which the encoded msg should be added needs to do some kind of aggregation
        Throws:
        Exception - is thrown if an error occurs