public class XmlFrameDecoder extends ByteToMessageDecoder
+-----+-----+-----------+
| <an | Xml | Element/> |
+-----+-----+-----------+
这个解码器会输出一个单帧:
+-----------------+
| <anXmlElement/> |
+-----------------+
给定一个输入的字节数组,像这样分成5个帧:
+-----+-----+-----------+-----+----------------------------------+
| <an | Xml | Element/> | <ro | ot><child>content</child></root> |
+-----+-----+-----------+-----+----------------------------------+
这个解码器会输出两个帧:
+-----------------+-------------------------------------+
| <anXmlElement/> | <root><child>content</child></root> |
+-----------------+-------------------------------------+
请注意,这个解码器不适用于xml流协议,例如XMPP ,其中一个初始xml元素打开流并且只在会话结束时关闭,尽管这个类可能允许这种类型的消息流进行小的修改。
ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
Constructor and Description |
---|
XmlFrameDecoder(int maxFrameLength) |
Modifier and Type | Method and Description |
---|---|
protected void |
decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out)
解码从一个 ByteBuf 到另一个。
|
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
ensureNotSharable, handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded
protected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoder
decode
在
ByteToMessageDecoder
ctx
- 此ByteToMessageDecoder
所属的ChannelHandlerContext
in
- 从中读取数据的ByteBuf
out
- 应该添加解码消息的
List
java.lang.Exception
- 发生错误时抛出
Copyright © 2008–2018 The Netty Project. All rights reserved.