public abstract class MessageToMessageEncoder<I>
extends io.netty.channel.ChannelOutboundMessageHandlerAdapter<I>
ChannelOutboundMessageHandlerAdapter which encodes from one message to an other message
For example here is an implementation which decodes an Integer to an String.
public class IntegerToStringEncoder extends
MessageToMessageEncoder<Integer> {
public StringToIntegerDecoder() {
super(String.class);
}
@Override
public Object encode(ChannelHandlerContext ctx, Integer message)
throws Exception {
return message.toString();
}
}
| Constructor and Description |
|---|
MessageToMessageEncoder() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Object |
encode(io.netty.channel.ChannelHandlerContext ctx,
I msg)
Encode from one message to an other.
|
void |
flush(io.netty.channel.ChannelHandlerContext ctx,
I msg) |
acceptOutboundMessage, beginFlush, endFlush, flush, freeOutboundBuffer, isCloseOnFailedFlush, newOutboundBuffer, setCloseOnFailedFlushbind, close, connect, deregister, disconnect, read, sendFileafterAdd, afterRemove, beforeAdd, beforeRemove, exceptionCaughtclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic final void flush(io.netty.channel.ChannelHandlerContext ctx,
I msg)
throws Exception
Exceptionprotected abstract Object encode(io.netty.channel.ChannelHandlerContext ctx, I msg) throws Exception
MessageBuf has nothing
left or till this method returns null.ctx - the ChannelHandlerContext which this MessageToMessageEncoder belongs tomsg - the message to encode to an other onenull if more messages are needed be cause the implementation
needs to do some kind of aggragationException - is thrown if an error accourCopyright © 2008-2013 The Netty Project. All Rights Reserved.