public abstract class ByteToMessageCodec<I> extends ChannelDuplexHandler
ByteToMessageDecoder and MessageToByteEncoder.
Be aware that sub-classes of ByteToMessageCodec MUST NOT
annotated with @Sharable.ChannelHandler.Sharable| 限定符 | 构造器和说明 |
|---|---|
protected |
ByteToMessageCodec()
see
ByteToMessageCodec(boolean) with true as boolean parameter. |
protected |
ByteToMessageCodec(boolean preferDirect)
Create a new instance which will try to detect the types to match out of the type parameter of the class.
|
protected |
ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType)
see
ByteToMessageCodec(Class, boolean) with true as boolean value. |
protected |
ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType,
boolean preferDirect)
Create a new instance
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
acceptOutboundMessage(java.lang.Object msg)
Returns
true if and only if the specified message can be encoded by this codec. |
void |
channelInactive(ChannelHandlerContext ctx)
Calls
ChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline. |
void |
channelRead(ChannelHandlerContext ctx,
java.lang.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,
ByteBuf in,
java.util.List<java.lang.Object> out) |
protected void |
decodeLast(ChannelHandlerContext ctx,
ByteBuf in,
java.util.List<java.lang.Object> out) |
protected abstract void |
encode(ChannelHandlerContext ctx,
I msg,
ByteBuf out) |
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.
|
void |
write(ChannelHandlerContext ctx,
java.lang.Object msg,
ChannelPromise promise)
Calls
ChannelOutboundInvoker.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline. |
bind, close, connect, deregister, disconnect, flush, readchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexceptionCaughtprotected ByteToMessageCodec()
ByteToMessageCodec(boolean) with true as boolean parameter.protected ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType)
ByteToMessageCodec(Class, boolean) with true as boolean value.protected ByteToMessageCodec(boolean preferDirect)
protected ByteToMessageCodec(java.lang.Class<? extends I> outboundMessageType, boolean preferDirect)
public boolean acceptOutboundMessage(java.lang.Object msg)
throws java.lang.Exception
true if and only if the specified message can be encoded by this codec.msg - the messagejava.lang.Exceptionpublic void channelRead(ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelRead(Object) to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelRead 在接口中 ChannelInboundHandlerchannelRead 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionpublic void write(ChannelHandlerContext ctx, java.lang.Object msg, ChannelPromise promise) throws java.lang.Exception
ChannelDuplexHandlerChannelOutboundInvoker.write(Object, ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.write 在接口中 ChannelOutboundHandlerwrite 在类中 ChannelDuplexHandlerctx - the ChannelHandlerContext for which the write operation is mademsg - the message to writepromise - the ChannelPromise to notify once the operation completesjava.lang.Exception - thrown if an error occurspublic void channelReadComplete(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelReadComplete() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelReadComplete 在接口中 ChannelInboundHandlerchannelReadComplete 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionpublic void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelInboundHandlerAdapterChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline.
Sub-classes may override this method to change behavior.channelInactive 在接口中 ChannelInboundHandlerchannelInactive 在类中 ChannelInboundHandlerAdapterjava.lang.Exceptionpublic void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapterhandlerAdded 在接口中 ChannelHandlerhandlerAdded 在类中 ChannelHandlerAdapterjava.lang.Exceptionpublic void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
ChannelHandlerAdapterhandlerRemoved 在接口中 ChannelHandlerhandlerRemoved 在类中 ChannelHandlerAdapterjava.lang.Exceptionprotected abstract void encode(ChannelHandlerContext ctx, I msg, ByteBuf out) throws java.lang.Exception
java.lang.ExceptionMessageToByteEncoder.encode(ChannelHandlerContext, Object, ByteBuf)protected abstract void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
java.lang.ExceptionByteToMessageDecoder.decode(ChannelHandlerContext, ByteBuf, List)protected void decodeLast(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
java.lang.ExceptionByteToMessageDecoder.decodeLast(ChannelHandlerContext, ByteBuf, List)