org.apache.mina.example.sumup.codec
Class AbstractMessageDecoder

java.lang.Object
  extended by org.apache.mina.example.sumup.codec.AbstractMessageDecoder
All Implemented Interfaces:
MessageDecoder
Direct Known Subclasses:
AddMessageDecoder, ResultMessageDecoder

public abstract class AbstractMessageDecoder
extends Object
implements MessageDecoder

A MessageDecoder that decodes message header and forwards the decoding of body to a subclass.

Author:
Apache MINA Project

Field Summary
 
Fields inherited from interface org.apache.mina.filter.codec.demux.MessageDecoder
NEED_DATA, NOT_OK, OK
 
Constructor Summary
protected AbstractMessageDecoder(int type)
           
 
Method Summary
 MessageDecoderResult decodable(IoSession session, IoBuffer in)
          Checks the specified buffer is decodable by this decoder.
 MessageDecoderResult decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
          Decodes binary or protocol-specific content into higher-level message objects.
protected abstract  AbstractMessage decodeBody(IoSession session, IoBuffer in)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.mina.filter.codec.demux.MessageDecoder
finishDecode
 

Constructor Detail

AbstractMessageDecoder

protected AbstractMessageDecoder(int type)
Method Detail

decodable

public MessageDecoderResult decodable(IoSession session,
                                      IoBuffer in)
Description copied from interface: MessageDecoder
Checks the specified buffer is decodable by this decoder.

Specified by:
decodable in interface MessageDecoder
Returns:
MessageDecoder.OK if this decoder can decode the specified buffer. MessageDecoder.NOT_OK if this decoder cannot decode the specified buffer. MessageDecoder.NEED_DATA if more data is required to determine if the specified buffer is decodable (MessageDecoder.OK) or not decodable MessageDecoder.NOT_OK.

decode

public MessageDecoderResult decode(IoSession session,
                                   IoBuffer in,
                                   ProtocolDecoderOutput out)
                            throws Exception
Description copied from interface: MessageDecoder
Decodes binary or protocol-specific content into higher-level message objects. MINA invokes MessageDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput) method with read data, and then the decoder implementation puts decoded messages into ProtocolDecoderOutput.

Specified by:
decode in interface MessageDecoder
Returns:
MessageDecoder.OK if you finished decoding messages successfully. MessageDecoder.NEED_DATA if you need more data to finish decoding current message. MessageDecoder.NOT_OK if you cannot decode current message due to protocol specification violation.
Throws:
Exception - if the read data violated protocol specification

decodeBody

protected abstract AbstractMessage decodeBody(IoSession session,
                                              IoBuffer in)
Returns:
null if the whole body is not read yet


Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.