001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 package org.apache.directory.shared.asn1.codec.stateful; 021 022 023 import org.apache.directory.shared.asn1.codec.DecoderException; 024 025 026 /** 027 * A decoder which decodes encoded data as it arrives in peices while 028 * maintaining the state of the decode operation between the arrival of encoded 029 * chunks. As chunks of encoded data arrive the decoder processes each chunk of 030 * encoded data and maintains decoding state in between arrivals: it is hence 031 * stateful and should be associated with a single channel or encoded data 032 * producer. When an arbitrary unit of encoding, to be determined by the 033 * encoding scheme, has been decoded, the <code>decode()</code> method of the 034 * registered DecoderCallback is called. 035 * 036 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 037 * @version $Rev: 664290 $ 038 */ 039 public interface StatefulDecoder 040 { 041 /** 042 * Decodes a piece of encoded data. The nature of this call, synchronous 043 * verses asynchonous, with respect to driving the actual decoding of the 044 * encoded data argument is determined by an implementation. A return from 045 * this method does not guarantee any callbacks: zero or more callbacks may 046 * occur during this call. 047 * 048 * @param encoded an object representing a piece of encoded data 049 * @throws DecoderException if the encoded element can't be decoded 050 */ 051 void decode( Object encoded ) throws DecoderException; 052 053 054 /** 055 * Sets the callback for this StatefulDecoder. 056 * 057 * @param cb 058 * the callback to inform of a complete decode operation 059 */ 060 void setCallback( DecoderCallback cb ); 061 062 063 /** 064 * Monitors all kinds of events that occur during processing. 065 * 066 * @param monitor 067 * to set for this StatefulDecoder 068 */ 069 void setDecoderMonitor( DecoderMonitor monitor ); 070 }