View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.asn1.codec.stateful ;
18  
19  
20  import org.apache.asn1.codec.DecoderException;
21  
22  
23  /***
24   * A decoder which decodes encoded data as it arrives in peices while
25   * maintaining the state of the decode operation between the arrival of
26   * encoded chunks.
27   *
28   * As chunks of encoded data arrive the decoder processes each chunk of encoded
29   * data and maintains decoding state in between arrivals: it is hence stateful 
30   * and should be associated with a single channel or encoded data producer.  
31   * When an arbitrary unit of encoding, to be determined by the encoding scheme,
32   * has been decoded, the <code>decode()</code> method of the registered
33   * DecoderCallback is called.
34   *
35   * @author <a href="mailto:commons-dev@jakarta.apache.org">Jakarta Commons</a>
36   * @version $Rev: 161723 $
37   */
38  public interface StatefulDecoder
39  {
40      /***
41       * Decodes a peice of encoded data.  The nature of this call, synchronous
42       * verses asynchonous, with respect to driving the actual decoding of the 
43       * encoded data argument is determined by an implementation.  A return from
44       * this method does not guarrantee any callbacks: zero or more callbacks 
45       * may occur during this call.
46       *
47       * @param encoded an object representing a peice of encoded data
48       */
49      void decode( Object encoded ) throws DecoderException ;
50  
51      /***
52       * Sets the callback for this StatefulDecoder.
53       * 
54       * @param cb the callback to inform of a complete decode operation
55       */
56      void setCallback( DecoderCallback cb ) ;
57      
58      /***
59       * Monitors all kinds of events that occur during processing.
60       * 
61       * @param monitor to set for this StatefulDecoder
62       */
63      void setDecoderMonitor( DecoderMonitor monitor ) ;
64  }