org.apache.mina.filter.codec.statemachine
Class DecodingStateProtocolDecoder

java.lang.Object
  extended by org.apache.mina.filter.codec.statemachine.DecodingStateProtocolDecoder
All Implemented Interfaces:
ProtocolDecoder

public class DecodingStateProtocolDecoder
extends java.lang.Object
implements ProtocolDecoder

ProtocolDecoder which uses a DecodingState to decode data. Use a DecodingStateMachine as DecodingState to create a state machine which can decode your protocol.

NOTE: This is a stateful decoder. You should create one instance per session.

Author:
Apache MINA Project

Constructor Summary
DecodingStateProtocolDecoder(DecodingState state)
          Creates a new instance using the specified DecodingState instance.
 
Method Summary
 void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
          Decodes binary or protocol-specific content into higher-level message objects.
 void dispose(IoSession session)
          Releases all resources related with this decoder.
 void finishDecode(IoSession session, ProtocolDecoderOutput out)
          Invoked when the specified session is closed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DecodingStateProtocolDecoder

public DecodingStateProtocolDecoder(DecodingState state)
Creates a new instance using the specified DecodingState instance.

Parameters:
state - the DecodingState.
Throws:
java.lang.IllegalArgumentException - if the specified state is null.
Method Detail

decode

public void decode(IoSession session,
                   IoBuffer in,
                   ProtocolDecoderOutput out)
            throws java.lang.Exception
Decodes binary or protocol-specific content into higher-level message objects. MINA invokes ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput) method with read data, and then the decoder implementation puts decoded messages into ProtocolDecoderOutput.

Specified by:
decode in interface ProtocolDecoder
Throws:
java.lang.Exception - if the read data violated protocol specification

finishDecode

public void finishDecode(IoSession session,
                         ProtocolDecoderOutput out)
                  throws java.lang.Exception
Invoked when the specified session is closed. This method is useful when you deal with the protocol which doesn't specify the length of a message such as HTTP response without content-length header. Implement this method to process the remaining data that ProtocolDecoder.decode(IoSession, IoBuffer, ProtocolDecoderOutput) method didn't process completely.

Specified by:
finishDecode in interface ProtocolDecoder
Throws:
java.lang.Exception - if the read data violated protocol specification

dispose

public void dispose(IoSession session)
             throws java.lang.Exception
Releases all resources related with this decoder.

Specified by:
dispose in interface ProtocolDecoder
Throws:
java.lang.Exception - if failed to dispose all resources


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