org.jboss.netty.handler.codec.frame
类 LengthFieldPrepender

java.lang.Object
  继承者 org.jboss.netty.handler.codec.oneone.OneToOneEncoder
      继承者 org.jboss.netty.handler.codec.frame.LengthFieldPrepender
所有已实现的接口:
ChannelDownstreamHandler, ChannelHandler

@ChannelHandler.Sharable
public class LengthFieldPrepender
extends OneToOneEncoder

An encoder that prepends the length of the message. The length value is prepended as a binary form. It is encoded in either big endian or little endian depending on the default ByteOrder of the current ChannelBufferFactory.

For example, LengthFieldPrepender(2) will encode the following 12-bytes string:

 +----------------+
 | "HELLO, WORLD" |
 +----------------+
 
into the following:
 +--------+----------------+
 + 0x000C | "HELLO, WORLD" |
 +--------+----------------+
 
If you turned on the lengthIncludesLengthFieldLength flag in the constructor, the encoded data would look like the following (12 (original data) + 2 (prepended data) = 14 (0xE)):
 +--------+----------------+
 + 0x000E | "HELLO, WORLD" |
 +--------+----------------+
 


嵌套类摘要
 
从接口 org.jboss.netty.channel.ChannelHandler 继承的嵌套类/接口
ChannelHandler.Sharable
 
构造方法摘要
LengthFieldPrepender(int lengthFieldLength)
          Creates a new instance.
LengthFieldPrepender(int lengthFieldLength, boolean lengthIncludesLengthFieldLength)
          Creates a new instance.
 
方法摘要
 
从类 org.jboss.netty.handler.codec.oneone.OneToOneEncoder 继承的方法
handleDownstream
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

LengthFieldPrepender

public LengthFieldPrepender(int lengthFieldLength)
Creates a new instance.

参数:
lengthFieldLength - the length of the prepended length field. Only 1, 2, 3, 4, and 8 are allowed.
抛出:
java.lang.IllegalArgumentException - if lengthFieldLength is not 1, 2, 3, 4, or 8

LengthFieldPrepender

public LengthFieldPrepender(int lengthFieldLength,
                            boolean lengthIncludesLengthFieldLength)
Creates a new instance.

参数:
lengthFieldLength - the length of the prepended length field. Only 1, 2, 3, 4, and 8 are allowed.
lengthIncludesLengthFieldLength - if true, the length of the prepended length field is added to the value of the prepended length field.
抛出:
java.lang.IllegalArgumentException - if lengthFieldLength is not 1, 2, 3, 4, or 8