|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jabb.netty.XmlDecoder
public class XmlDecoder
A decoder for Netty to handle XML messages.
使得Netty能够对XML文本消息进行分段的decoder。
The usage is as the following:
使用方法如下:
and then you can use aChannelPipelinepipeline = ...; // construct a decoder XmlDecoder xmlDecoder = new XmlDecoder( 10000, // maximum length of the XML messages "env:Envelope", // top level tag of the XML messages CharsetUtil.UTF_8); // character encoding of the messages // setup the pipeline to use the decoder pipeline.addLast("frameDecoder", xmlDecoder.getFrameDecoder()); pipeline.addLast("stringDecoder", xmlDecoder.getStringDecoder());
String instead of a ChannelBuffer
when processing messages:
void messageReceived(ChannelHandlerContextctx,MessageEvente) { String msg = (String) e.getMessage(); System.out.print("The XML body is '" + msg + "'\n"); }
| Nested Class Summary | |
|---|---|
protected static class |
XmlDecoder.XmlStringDecoder
Further process the messages already processed by FrameDecoder to make it clean XML text messages. 把经过FrameDecoder处理过后的消息,进一步加工为头尾完整干净的XML文本。 |
| Field Summary | |
|---|---|
protected static byte[] |
endTagEndingByte
|
protected org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder |
frameDecoder
|
protected static char[] |
startTagEndingChar
|
protected XmlDecoder.XmlStringDecoder |
stringDecoder
|
| Constructor Summary | |
|---|---|
XmlDecoder(int maxFrameLength,
String topLevelTagName,
Charset charset)
Constructor after which both its getFrameDecoder() and getStringDecoder() methods should be
called to get two decoders for Netty.创建一个实例,创建好之后,它的 getFrameDecoder()方法和getStringDecoder()方法都应该被调用
以获得给Netty用的两个decoder。 |
|
| Method Summary | |
|---|---|
protected org.jboss.netty.buffer.ChannelBuffer[] |
buildDelimiters(String tagName,
Charset charset)
Creates delimiters that will be used to construct DelimiterBasedFrameDecoder.根据XML标签的名称,生成适合 DelimiterBasedFrameDecoder用的delimiters。 |
org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder |
getFrameDecoder()
Get the frame decoder to be used by Netty. 获得给Netty用的frame decoder。 |
org.jboss.netty.handler.codec.oneone.OneToOneDecoder |
getStringDecoder()
Get the string decoder to be used by Netty. 获得给Netty用的string decoder。 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static char[] startTagEndingChar
protected static byte[] endTagEndingByte
protected org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder frameDecoder
protected XmlDecoder.XmlStringDecoder stringDecoder
| Constructor Detail |
|---|
public XmlDecoder(int maxFrameLength,
String topLevelTagName,
Charset charset)
getFrameDecoder() and getStringDecoder() methods should be
called to get two decoders for Netty.getFrameDecoder()方法和getStringDecoder()方法都应该被调用
以获得给Netty用的两个decoder。
maxFrameLength - Maximum length of XML text messages that might be received.topLevelTagName - Top level XML tag that marks the beginning and ending of XML messages.charset - Character set that the text messages are encoded in.| Method Detail |
|---|
protected org.jboss.netty.buffer.ChannelBuffer[] buildDelimiters(String tagName,
Charset charset)
DelimiterBasedFrameDecoder.DelimiterBasedFrameDecoder用的delimiters。
tagName - Name of the top level XML tag (not including <, /, etc).charset - Character set encoding of the messages to be processed.public org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder getFrameDecoder()
Always use this method together with getStringDecoder().
这个方法总是与getStringDecoder()方法结合起来一起用。
public org.jboss.netty.handler.codec.oneone.OneToOneDecoder getStringDecoder()
Always use this method together with getFrameDecoder().
这个方法总是与getFrameDecoder()方法结合起来一起用。
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||