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 021package org.apache.directory.api.asn1; 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 */ 040public interface Decoder 041{ 042 043 /** 044 * Decodes an "encoded" Object and returns a "decoded" Object. Note that the 045 * implementation of this interface will try to cast the Object parameter to 046 * the specific type expected by a particular Decoder implementation. If a 047 * {@link java.lang.ClassCastException} occurs this decode method will throw 048 * a DecoderException. 049 * 050 * @param object an object to "decode" 051 * @return a 'decoded" object 052 * @throws DecoderException a decoder exception can be thrown for any number of reasons. 053 * Some good candidates are that the parameter passed to this method is null, a param 054 * cannot be cast to the appropriate type for a specific encoder. 055 */ 056 Object decode( Object object ) throws DecoderException; 057}