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

java.lang.Object
  extended by org.apache.mina.examples.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.

Version:
$Rev: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
Author:
The Apache Directory Project

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

Constructor Detail

AbstractMessageDecoder

protected AbstractMessageDecoder(int type)
Method Detail

decodable

public MessageDecoderResult decodable(ProtocolSession session,
                                      ByteBuffer 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(ProtocolSession session,
                                   ByteBuffer in,
                                   ProtocolDecoderOutput out)
                            throws ProtocolViolationException
Description copied from interface: MessageDecoder
Decodes binary or protocol-specific content into higher-level message objects. MINA invokes MessageDecoder.decode(ProtocolSession, ByteBuffer, 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:
ProtocolViolationException - if the read data violated protocol specification

decodeBody

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


Copyright © 2004-2005 . All Rights Reserved.