Class Base64Encoder

All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler

@Sharable public class Base64Encoder extends MessageToMessageEncoder<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());
  • Field Details

    • breakLines

      private final boolean breakLines
    • dialect

      private final Base64Dialect dialect
  • Constructor Details

    • Base64Encoder

      public Base64Encoder()
    • Base64Encoder

      public Base64Encoder(boolean breakLines)
    • Base64Encoder

      public Base64Encoder(boolean breakLines, Base64Dialect dialect)
  • Method Details

    • encode

      protected void encode(ChannelHandlerContext ctx, ByteBuf msg, java.util.List<java.lang.Object> out) throws java.lang.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<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:
      java.lang.Exception - is thrown if an error occurs