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    
021    package org.apache.directory.shared.asn1.codec;
022    
023    
024    /**
025     * <p>
026     * Provides the highest level of abstraction for Decoders. This is the sister
027     * interface of {@link Encoder}. All Decoders implement this common generic
028     * interface.
029     * </p>
030     * <p>
031     * Allows a user to pass a generic Object to any Decoder implementation in the
032     * codec package.
033     * </p>
034     * <p>
035     * One of the two interfaces at the center of the codec package.
036     * </p>
037     * 
038     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
039     * @version $Id: Decoder.java 437004 2006-08-25 22:53:17Z elecharny $
040     */
041    public interface Decoder
042    {
043    
044        /**
045         * Decodes an "encoded" Object and returns a "decoded" Object. Note that the
046         * implementation of this interface will try to cast the Object parameter to
047         * the specific type expected by a particular Decoder implementation. If a
048         * {@link java.lang.ClassCastException} occurs this decode method will throw
049         * a DecoderException.
050         * 
051         * @param pObject
052         *            an object to "decode"
053         * @return a 'decoded" object
054         * @throws DecoderException
055         *             a decoder exception can be thrown for any number of reasons.
056         *             Some good candidates are that the parameter passed to this
057         *             method is null, a param cannot be cast to the appropriate
058         *             type for a specific encoder.
059         */
060        Object decode( Object pObject ) throws DecoderException;
061    }