Top Description Constructors Methods
io.netty.handler.codec.protobuf

public Class ProtobufVarint32LengthFieldPrepender

extends MessageToByteEncoder<ByteBuf>
Class Inheritance
Annotations
@Sharable
Imports
com.google.protobuf.CodedOutputStream, com.google.protobuf.nano.CodedOutputByteBufferNano, io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandler.Sharable, .ChannelHandlerContext, io.netty.handler.codec.MessageToByteEncoder

An encoder that prepends the Google Protocol Buffers Base 128 Varints integer length field. For example:
BEFORE ENCODE (300 bytes)       AFTER ENCODE (302 bytes)
+---------------+               +--------+---------------+
| Protobuf Data |-------------->| Length | Protobuf Data |
|  (300 bytes)  |               | 0xAC02 |  (300 bytes)  |
+---------------+               +--------+---------------+
*
See Also
CodedOutputStream, CodedOutputByteBufferNano

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static int

Returns:

size of value encoded as protobuf varint32.
computeRawVarint32Size
(final int
which is to be encoded.
value
)

Computes size of protobuf varint32 after encoding.

protected void
encode(ChannelHandlerContext ctx, ByteBuf
the message to encode
msg
,
ByteBuf
the ByteBuf into which the encoded message will be written
out
)

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf.
pack-priv static void
writeRawVarint32(ByteBuf
to be written to
out
,
int
to be written
value
)

Writes protobuf varint32 to (@link ByteBuf).

Inherited from io.netty.handler.codec.MessageToByteEncoder:
acceptOutboundMessageallocateBufferisPreferDirectwrite

Constructor Detail

ProtobufVarint32LengthFieldPrependerback to summary
public ProtobufVarint32LengthFieldPrepender()

Method Detail

computeRawVarint32Sizeback to summary
pack-priv static int computeRawVarint32Size(final int value)

Computes size of protobuf varint32 after encoding.

Parameters
value:int

which is to be encoded.

Returns:int

size of value encoded as protobuf varint32.

encodeback to summary
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception

Implements abstract io.netty.handler.codec.MessageToByteEncoder.encode.

Doc from io.netty.handler.codec.MessageToByteEncoder.encode.

Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToByteEncoder belongs to

msg:ByteBuf

the message to encode

out:ByteBuf

the ByteBuf into which the encoded message will be written

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
writeRawVarint32back to summary
pack-priv static void writeRawVarint32(ByteBuf out, int value)

Writes protobuf varint32 to (@link ByteBuf).

Parameters
out:ByteBuf

to be written to

value:int

to be written