Class OneToOneDecoder
- java.lang.Object
-
- org.jboss.netty.handler.codec.oneone.OneToOneDecoder
-
- All Implemented Interfaces:
ChannelHandler
,ChannelUpstreamHandler
- Direct Known Subclasses:
Base64Decoder
,ProtobufDecoder
,SpdyHttpDecoder
,StringDecoder
,WebSocketFrameAggregator
,ZlibDecoder
public abstract class OneToOneDecoder extends java.lang.Object implements ChannelUpstreamHandler
Transforms a received message into another message. Please note that this decoder must be used with a properFrameDecoder
such asDelimiterBasedFrameDecoder
or you must implement proper framing mechanism by yourself if you are using a stream-based transport such as TCP/IP. 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 Modifier Constructor Description protected
OneToOneDecoder()
Creates a new instance with the current system character set.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.Object
decode(ChannelHandlerContext ctx, Channel channel, java.lang.Object msg)
Transforms the specified received message into another message and return the transformed message.void
handleUpstream(ChannelHandlerContext ctx, ChannelEvent evt)
Handles the specified upstream event.
-
-
-
Method Detail
-
handleUpstream
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent evt) throws java.lang.Exception
Description copied from interface:ChannelUpstreamHandler
Handles the specified upstream event.- Specified by:
handleUpstream
in interfaceChannelUpstreamHandler
- Parameters:
ctx
- the context object for this handlerevt
- the upstream event to process or intercept- Throws:
java.lang.Exception
-
decode
protected abstract java.lang.Object decode(ChannelHandlerContext ctx, Channel channel, java.lang.Object msg) throws java.lang.Exception
Transforms the specified received message into another message and return the transformed message. Returnnull
if the received message is supposed to be discarded.- Throws:
java.lang.Exception
-
-