- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.handler.codec.MessageToMessageEncoder<Buffer>
-
- io.netty5.handler.codec.base64.Base64Encoder
-
- All Implemented Interfaces:
ChannelHandler
public class Base64Encoder extends MessageToMessageEncoder<Buffer>
Encodes aBuffer
into a Base64-encodedBuffer
. A typical setup for TCP/IP would be:ChannelPipeline
pipeline = ...; // Decoders pipeline.addLast("frameDecoder", newDelimiterBasedFrameDecoder
(80,Delimiters.nulDelimiter()
)); pipeline.addLast("base64Decoder", newBase64Decoder
()); // Encoder pipeline.addLast("base64Encoder", newBase64Encoder
());
-
-
Constructor Summary
Constructors Constructor Description Base64Encoder()
Base64Encoder(boolean breakLines)
Base64Encoder(boolean breakLines, Base64Dialect dialect)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
encode(ChannelHandlerContext ctx, Buffer msg, List<Object> out)
Encode from one message to another.boolean
isSharable()
Returnstrue
if this handler is sharable and thus can be added to more than oneChannelPipeline
.-
Methods inherited from class io.netty5.handler.codec.MessageToMessageEncoder
acceptOutboundMessage, encodeAndClose, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelRead, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
-
-
-
-
Constructor Detail
-
Base64Encoder
public Base64Encoder()
-
Base64Encoder
public Base64Encoder(boolean breakLines)
-
Base64Encoder
public Base64Encoder(boolean breakLines, Base64Dialect dialect)
-
-
Method Detail
-
isSharable
public boolean isSharable()
Description copied from interface:ChannelHandler
Returnstrue
if this handler is sharable and thus can be added to more than oneChannelPipeline
. By default, this method returnsfalse
. If this method returnsfalse
, you have to create a new handler instance every time you add it to a pipeline because it has unshared state such as member variables.
-
encode
protected void encode(ChannelHandlerContext ctx, Buffer msg, List<Object> out) throws Exception
Description copied from class:MessageToMessageEncoder
Encode from one message to another. This method will be called for each written message that can be handled by this encoder.The message will be disposed of after this call.
Subclasses that wish to sometimes pass messages through, should instead override the
MessageToMessageEncoder.encodeAndClose(ChannelHandlerContext, Object, List)
method.- Overrides:
encode
in classMessageToMessageEncoder<Buffer>
- Parameters:
ctx
- theChannelHandlerContext
which thisMessageToMessageEncoder
belongs to.msg
- the message to encode to another one.out
- theList
into which produced output messages should be added.- Throws:
Exception
- is thrown if an error occurs.
-
-