View Javadoc

1   /*
2    *   @(#) $Id: ProtocolDecoder.java 210062 2005-07-11 03:52:38Z trustin $
3    *
4    *   Copyright 2004 The Apache Software Foundation
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   *
18   */
19  package org.apache.mina.protocol;
20  
21  import org.apache.mina.common.ByteBuffer;
22  
23  /***
24   * Decodes binary or protocol-specific data into higher-level message objects.
25   * MINA invokes {@link #decode(ProtocolSession, ByteBuffer, ProtocolDecoderOutput)}
26   * method with read data, and then the decoder implementation puts decoded
27   * messages into {@link ProtocolDecoderOutput} by calling
28   * {@link ProtocolDecoderOutput#write(Object)}.
29   * <p>
30   * Please refer to
31   * <a href="../../../../../xref-examples/org/apache/mina/examples/reverser/TextLineDecoder.html"><code>TextLineDecoder</code></a>
32   * example. 
33   * 
34   * @author Trustin Lee (trustin@apache.org)
35   * @version $Rev: 210062 $, $Date: 2005-07-11 12:52:38 +0900 $
36   */
37  public interface ProtocolDecoder
38  {
39      /***
40       * Decodes binary or protocol-specific content into higher-level message objects.
41       * MINA invokes {@link #decode(ProtocolSession, ByteBuffer, ProtocolDecoderOutput)}
42       * method with read data, and then the decoder implementation puts decoded
43       * messages into {@link ProtocolDecoderOutput}.
44       * 
45       * @throws ProtocolViolationException if the read data violated protocol
46       *                                    specification 
47       */
48      void decode( ProtocolSession session, ByteBuffer in,
49                   ProtocolDecoderOutput out ) throws ProtocolViolationException;
50  }