Class OneToOneEncoder
java.lang.Object
org.jboss.netty.handler.codec.oneone.OneToOneEncoder
- All Implemented Interfaces:
ChannelDownstreamHandler
,ChannelHandler
- Direct Known Subclasses:
Base64Encoder
,CompatibleMarshallingEncoder
,CompatibleObjectEncoder
,HttpMessageEncoder
,LengthFieldPrepender
,MarshallingEncoder
,NumberEncoder
,ObjectEncoder
,OneToOneStrictEncoder
,ProtobufEncoder
,ProtobufVarint32LengthFieldPrepender
,SocksMessageEncoder
,StringEncoder
,WebSocket00FrameEncoder
,WebSocket08FrameEncoder
Transforms a write request into another write request. A typical setup for
TCP/IP would be:
ChannelPipeline
pipeline = ...; // Decoders pipeline.addLast("frameDecoder", newDelimiterBasedFrameDecoder
(80,Delimiters.nulDelimiter()
)); pipeline.addLast("customDecoder", newOneToOneDecoder
() { ... }); // Encoder pipeline.addLast("customEncoder", newOneToOneEncoder
() { ... });
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected abstract Object
encode
(ChannelHandlerContext ctx, Channel channel, Object msg) Transforms the specified message into another message and return the transformed message.void
Handles the specified downstream event.
-
Constructor Details
-
OneToOneEncoder
protected OneToOneEncoder()
-
-
Method Details
-
handleDownstream
Description copied from interface:ChannelDownstreamHandler
Handles the specified downstream event.- Specified by:
handleDownstream
in interfaceChannelDownstreamHandler
- Parameters:
ctx
- the context object for this handlerevt
- the downstream event to process or intercept- Throws:
Exception
-
doEncode
- Throws:
Exception
-
encode
protected abstract Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception Transforms the specified message into another message and return the transformed message. Note that you can not returnnull
, unlike you can inOneToOneDecoder.decode(ChannelHandlerContext, Channel, Object)
; you must return something, at leastChannelBuffers.EMPTY_BUFFER
.- Throws:
Exception
-